Debian Codegraph @

libcxx/test/std/strings/string.view/string.view.hash/enabled_hashes.pass.cpp

raw
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 // UNSUPPORTED: c++03
10 // UNSUPPORTED: !stdlib=libc++ && (c++11 || c++14)
11
12 // <string_view>
13
14 // Test that <string_view> provides all of the arithmetic, enum, and pointer
15 // hash specializations.
16
17 #include <string_view>
18
19 #include "constexpr_char_traits.h"
20 #include "poisoned_hash_helper.h"
21 #include "test_macros.h"
22
23 struct MyChar {
24 char c;
25 };
26
27 template <>
28 struct std::char_traits<MyChar> {
29 using char_type = MyChar;
30 using int_type = std::char_traits<char>::int_type;
31 using off_type = std::char_traits<char>::off_type;
32 using pos_type = std::char_traits<char>::pos_type;
33 using state_type = std::char_traits<char>::state_type;
34
35 static void assign(char_type&, const char_type&);
36 static bool eq(char_type, char_type);
37 static bool lt(char_type, char_type);
38
39 static int compare(const char_type*, const char_type*, std::size_t);
40 static std::size_t length(const char_type*);
41 static const char_type* find(const char_type*, std::size_t, const char_type&);
42 static char_type* move(char_type*, const char_type*, std::size_t);
43 static char_type* copy(char_type*, const char_type*, std::size_t);
44 static char_type* assign(char_type*, std::size_t, char_type);
45
46 static int_type not_eof(int_type);
47 static char_type to_char_type(int_type);
48 static int_type to_int_type(char_type);
49 static bool eq_int_type(int_type, int_type);
50 static int_type eof();
51 };
52
53 int main(int, char**) {
54 test_library_hash_specializations_available();
55 {
56 test_hash_enabled_for_type<std::string_view>();
57 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
58 test_hash_enabled_for_type<std::wstring_view>();
59 #endif
60 #ifndef TEST_HAS_NO_CHAR8_T
61 test_hash_enabled_for_type<std::u8string_view>();
62 #endif
63 test_hash_enabled_for_type<std::u16string_view>();
64 test_hash_enabled_for_type<std::u32string_view>();
65 test_hash_disabled_for_type<std::basic_string_view<MyChar, std::char_traits<MyChar>>>();
66 test_hash_disabled_for_type<std::basic_string_view<char, constexpr_char_traits<char>>>();
67 }
68
69 return 0;
70 }