Home | History | Annotate | Download | only in streambuf.locales
      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 // locale pubimbue(const locale& loc);
     16 // locale getloc() const;
     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     test() {}
     28 
     29     void imbue(const std::locale&)
     30     {
     31         assert(this->getloc().name() == LOCALE_en_US_UTF_8);
     32     }
     33 };
     34 
     35 int main()
     36 {
     37     {
     38         test<char> t;
     39         assert(t.getloc().name() == "C");
     40     }
     41     std::locale::global(std::locale(LOCALE_en_US_UTF_8));
     42     {
     43         test<char> t;
     44         assert(t.getloc().name() == LOCALE_en_US_UTF_8);
     45         assert(t.pubimbue(std::locale(LOCALE_fr_FR_UTF_8)).name() == "en_US.UTF-8");
     46         assert(t.getloc().name() == LOCALE_fr_FR_UTF_8);
     47     }
     48 }
     49