types.pass.cpp revision f5256e16dfc425c1d466f6308d4026d529ce9e0b
1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <locale>
11
12// template <class CharT>
13// class ctype_byname
14//     : public ctype<CharT>
15// {
16// public:
17//     explicit ctype_byname(const char*, size_t = 0);
18//     explicit ctype_byname(const string&, size_t = 0);
19//
20// protected:
21//     ~ctype_byname();
22// };
23
24#include <locale>
25#include <type_traits>
26#include <cassert>
27
28int main()
29{
30    {
31        std::locale l("en_US");
32        {
33            assert(std::has_facet<std::ctype_byname<char> >(l));
34            assert(&std::use_facet<std::ctype<char> >(l)
35                == &std::use_facet<std::ctype_byname<char> >(l));
36        }
37        {
38            assert(std::has_facet<std::ctype_byname<wchar_t> >(l));
39            assert(&std::use_facet<std::ctype<wchar_t> >(l)
40                == &std::use_facet<std::ctype_byname<wchar_t> >(l));
41        }
42    }
43    {
44        std::locale l("");
45        {
46            assert(std::has_facet<std::ctype_byname<char> >(l));
47            assert(&std::use_facet<std::ctype<char> >(l)
48                == &std::use_facet<std::ctype_byname<char> >(l));
49        }
50        {
51            assert(std::has_facet<std::ctype_byname<wchar_t> >(l));
52            assert(&std::use_facet<std::ctype<wchar_t> >(l)
53                == &std::use_facet<std::ctype_byname<wchar_t> >(l));
54        }
55    }
56    {
57        std::locale l("C");
58        {
59            assert(std::has_facet<std::ctype_byname<char> >(l));
60            assert(&std::use_facet<std::ctype<char> >(l)
61                == &std::use_facet<std::ctype_byname<char> >(l));
62        }
63        {
64            assert(std::has_facet<std::ctype_byname<wchar_t> >(l));
65            assert(&std::use_facet<std::ctype<wchar_t> >(l)
66                == &std::use_facet<std::ctype_byname<wchar_t> >(l));
67        }
68    }
69}
70