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 // <string> 11 12 // template<> struct char_traits<char32_t> 13 14 // static size_t length(const char_type* s); 15 // constexpr in C++17 16 17 #include <string> 18 #include <cassert> 19 20 #include "test_macros.h" 21 22 #if TEST_STD_VER > 14 test_constexpr()23constexpr bool test_constexpr() 24 { 25 return std::char_traits<char32_t>::length(U"") == 0 26 && std::char_traits<char32_t>::length(U"abcd") == 4; 27 } 28 #endif 29 main()30int main() 31 { 32 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS 33 #if TEST_STD_VER >= 11 34 assert(std::char_traits<char32_t>::length(U"") == 0); 35 assert(std::char_traits<char32_t>::length(U"a") == 1); 36 assert(std::char_traits<char32_t>::length(U"aa") == 2); 37 assert(std::char_traits<char32_t>::length(U"aaa") == 3); 38 assert(std::char_traits<char32_t>::length(U"aaaa") == 4); 39 #endif 40 41 #if TEST_STD_VER > 14 42 static_assert(test_constexpr(), "" ); 43 #endif 44 #endif // _LIBCPP_HAS_NO_UNICODE_CHARS 45 } 46