blob: 03e8dfcef97fb1f496f1eac3b01c2e6dc47c81db [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnantf5256e12010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00007//
8//===----------------------------------------------------------------------===//
9
10// <locale>
11
12// template <class CharT>
13// class ctype_byname
14// : public ctype<CharT>
15// {
Howard Hinnant22a74dc2010-08-22 00:39:25 +000016// 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();
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000022// };
23
24#include <locale>
25#include <type_traits>
26#include <cassert>
27
Marshall Clow83e2c4d2013-01-05 03:21:01 +000028#include "platform_support.h" // locale name macros
Howard Hinnantc0d0cba2011-10-03 15:23:59 +000029
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000030int main()
31{
32 {
Howard Hinnantc0d0cba2011-10-03 15:23:59 +000033 std::locale l(LOCALE_en_US_UTF_8);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000034 {
35 assert(std::has_facet<std::ctype_byname<char> >(l));
36 assert(&std::use_facet<std::ctype<char> >(l)
37 == &std::use_facet<std::ctype_byname<char> >(l));
38 }
39 {
40 assert(std::has_facet<std::ctype_byname<wchar_t> >(l));
41 assert(&std::use_facet<std::ctype<wchar_t> >(l)
42 == &std::use_facet<std::ctype_byname<wchar_t> >(l));
43 }
44 }
45 {
46 std::locale l("");
47 {
48 assert(std::has_facet<std::ctype_byname<char> >(l));
49 assert(&std::use_facet<std::ctype<char> >(l)
50 == &std::use_facet<std::ctype_byname<char> >(l));
51 }
52 {
53 assert(std::has_facet<std::ctype_byname<wchar_t> >(l));
54 assert(&std::use_facet<std::ctype<wchar_t> >(l)
55 == &std::use_facet<std::ctype_byname<wchar_t> >(l));
56 }
57 }
58 {
59 std::locale l("C");
60 {
61 assert(std::has_facet<std::ctype_byname<char> >(l));
62 assert(&std::use_facet<std::ctype<char> >(l)
63 == &std::use_facet<std::ctype_byname<char> >(l));
64 }
65 {
66 assert(std::has_facet<std::ctype_byname<wchar_t> >(l));
67 assert(&std::use_facet<std::ctype<wchar_t> >(l)
68 == &std::use_facet<std::ctype_byname<wchar_t> >(l));
69 }
70 }
71}