1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// <locale>
10
11// template <class charT>
12// class collate
13// : public locale::facet {
14// public:
15// typedef charT char_type;
16// typedef basic_string<charT>string_type;
17//
18// static locale::id id;
19// };
20
21#include <locale>
22#include <type_traits>
23#include <cassert>
24
25#include "test_macros.h"
26
27int main(int, char**)
28{
29 std::locale l = std::locale::classic();
30 {
31 assert(std::has_facet<std::collate<char> >(l));
32 const std::collate<char>& f = std::use_facet<std::collate<char> >(l);
33 ((void)f); // Prevent unused warning
34 {
35 (void)std::collate<char>::id;
36 }
37 static_assert((std::is_same<std::collate<char>::char_type, char>::value), "");
38 static_assert((std::is_same<std::collate<char>::string_type, std::string>::value), "");
39 static_assert((std::is_base_of<std::locale::facet, std::collate<char> >::value), "");
40 }
41#ifndef TEST_HAS_NO_WIDE_CHARACTERS
42 {
43 assert(std::has_facet<std::collate<wchar_t> >(l));
44 const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l);
45 ((void)f); // Prevent unused warning
46 {
47 (void)std::collate<wchar_t>::id;
48 }
49 static_assert((std::is_same<std::collate<wchar_t>::char_type, wchar_t>::value), "");
50 static_assert((std::is_same<std::collate<wchar_t>::string_type, std::wstring>::value), "");
51 static_assert((std::is_base_of<std::locale::facet, std::collate<wchar_t> >::value), "");
52 }
53#endif
54
55 return 0;
56}
57

source code of libcxx/test/std/localization/locale.categories/category.collate/locale.collate/types.pass.cpp