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