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