Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <locale> |
| 11 | |
| 12 | // template <class CharT> |
| 13 | // class ctype_byname |
| 14 | // : public ctype<CharT> |
| 15 | // { |
Howard Hinnant | 22a74dc | 2010-08-22 00:39:25 +0000 | [diff] [blame] | 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(); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 22 | // }; |
| 23 | |
| 24 | #include <locale> |
| 25 | #include <type_traits> |
| 26 | #include <cassert> |
| 27 | |
Marshall Clow | 83e2c4d | 2013-01-05 03:21:01 +0000 | [diff] [blame] | 28 | #include "platform_support.h" // locale name macros |
Howard Hinnant | c0d0cba | 2011-10-03 15:23:59 +0000 | [diff] [blame] | 29 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 30 | int main() |
| 31 | { |
| 32 | { |
Howard Hinnant | c0d0cba | 2011-10-03 15:23:59 +0000 | [diff] [blame] | 33 | std::locale l(LOCALE_en_US_UTF_8); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 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 | } |