• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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<char>
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()23 constexpr bool test_constexpr()
24 {
25     return std::char_traits<char>::length("") == 0
26         && std::char_traits<char>::length("abcd") == 4;
27 }
28 #endif
29 
30 
main()31 int main()
32 {
33     assert(std::char_traits<char>::length("") == 0);
34     assert(std::char_traits<char>::length("a") == 1);
35     assert(std::char_traits<char>::length("aa") == 2);
36     assert(std::char_traits<char>::length("aaa") == 3);
37     assert(std::char_traits<char>::length("aaaa") == 4);
38 
39 #if TEST_STD_VER > 14
40     static_assert(test_constexpr(), "" );
41 #endif
42 }
43