Home | History | Annotate | Download | only in locale.moneypunct.members
      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 // <locale>
     11 
     12 // class moneypunct<charT, International>
     13 
     14 // string_type negative_sign() const;
     15 
     16 // The C++ and C standards are silent.
     17 //   On this one, commen sense is the guideline.
     18 //   If customers complain, I'll endeavor to minimize customer complaints
     19 
     20 #include <locale>
     21 #include <limits>
     22 #include <cassert>
     23 
     24 typedef std::moneypunct<char> F;
     25 
     26 class Fnf
     27     : public std::moneypunct<char, false>
     28 {
     29 public:
     30     explicit Fnf(std::size_t refs = 0)
     31         : std::moneypunct<char, false>(refs) {}
     32 };
     33 
     34 class Fnt
     35     : public std::moneypunct<char, true>
     36 {
     37 public:
     38     explicit Fnt(std::size_t refs = 0)
     39         : std::moneypunct<char, true>(refs) {}
     40 };
     41 
     42 class Fwf
     43     : public std::moneypunct<wchar_t, false>
     44 {
     45 public:
     46     explicit Fwf(std::size_t refs = 0)
     47         : std::moneypunct<wchar_t, false>(refs) {}
     48 };
     49 
     50 class Fwt
     51     : public std::moneypunct<wchar_t, true>
     52 {
     53 public:
     54     explicit Fwt(std::size_t refs = 0)
     55         : std::moneypunct<wchar_t, true>(refs) {}
     56 };
     57 
     58 int main()
     59 {
     60     {
     61         Fnf f(1);
     62         assert(f.negative_sign() == "-");
     63     }
     64     {
     65         Fnt f(1);
     66         assert(f.negative_sign() == "-");
     67     }
     68     {
     69         Fwf f(1);
     70         assert(f.negative_sign() == L"-");
     71     }
     72     {
     73         Fwt f(1);
     74         assert(f.negative_sign() == L"-");
     75     }
     76 }
     77