1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // REQUIRES: locale.en_US.UTF-8
10 
11 // <streambuf>
12 
13 // template <class charT, class traits = char_traits<charT> >
14 // class basic_streambuf;
15 
16 // basic_streambuf& operator=(const basic_streambuf& rhs);
17 
18 #include <streambuf>
19 #include <cassert>
20 
21 #include "platform_support.h" // locale name macros
22 
23 template <class CharT>
24 struct test
25     : public std::basic_streambuf<CharT>
26 {
27     typedef std::basic_streambuf<CharT> base;
28     test() {}
29 
30     test& operator=(const test& t)
31     {
32         base::operator=(t);
33         assert(this->eback() == t.eback());
34         assert(this->gptr()  == t.gptr());
35         assert(this->egptr() == t.egptr());
36         assert(this->pbase() == t.pbase());
37         assert(this->pptr()  == t.pptr());
38         assert(this->epptr() == t.epptr());
39         assert(this->getloc() == t.getloc());
40         return *this;
41     }
42 
43     void setg(CharT* gbeg, CharT* gnext, CharT* gend)
44     {
45         base::setg(gbeg, gnext, gend);
46     }
47     void setp(CharT* pbeg, CharT* pend)
48     {
49         base::setp(pbeg, pend);
50     }
51 };
52 
53 int main(int, char**)
54 {
55     {
56         test<char> t;
57         test<char> t2;
58         t2 = t;
59     }
60     {
61         test<wchar_t> t;
62         test<wchar_t> t2;
63         t2 = t;
64     }
65     {
66         char g1, g2, g3, p1, p3;
67         test<char> t;
68         t.setg(&g1, &g2, &g3);
69         t.setp(&p1, &p3);
70         test<char> t2;
71         t2 = t;
72     }
73     {
74         wchar_t g1, g2, g3, p1, p3;
75         test<wchar_t> t;
76         t.setg(&g1, &g2, &g3);
77         t.setp(&p1, &p3);
78         test<wchar_t> t2;
79         t2 = t;
80     }
81     std::locale::global(std::locale(LOCALE_en_US_UTF_8));
82     {
83         test<char> t;
84         test<char> t2;
85         t2 = t;
86     }
87     {
88         test<wchar_t> t;
89         test<wchar_t> t2;
90         t2 = t;
91     }
92 
93   return 0;
94 }
95