types.pass.cpp revision 83e2c4d877fe2d7793868b1c6a5d9525a7c4d431
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// 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 28#include "platform_support.h" // locale name macros 29 30int main() 31{ 32 { 33 std::locale l(LOCALE_en_US_UTF_8); 34 { 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} 72