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