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, c++11, c++14, c++17, c++20 10 11 // <string_view> 12 13 // constexpr bool contains(charT x) const noexcept; 14 15 #include <string_view> 16 #include <cassert> 17 18 #include "test_macros.h" 19 test()20constexpr bool test() { 21 using SV = std::string_view; 22 23 SV sv1{}; 24 SV sv2{"abcde", 5}; 25 26 ASSERT_NOEXCEPT(sv1.contains('e')); 27 28 assert(!sv1.contains('c')); 29 assert(!sv1.contains('e')); 30 assert(!sv1.contains('x')); 31 assert(sv2.contains('c')); 32 assert(sv2.contains('e')); 33 assert(!sv2.contains('x')); 34 35 return true; 36 } 37 main(int,char **)38int main(int, char**) { 39 test(); 40 static_assert(test()); 41 42 return 0; 43 } 44