Home | History | Annotate | Download | only in string.view.template
      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 // UNSUPPORTED: c++98, c++03, c++11, c++14, c++17
     10 
     11 // <string_view>
     12 
     13 //   constexpr bool starts_with(charT x) const noexcept;
     14 
     15 #include <string_view>
     16 #include <cassert>
     17 
     18 #include "test_macros.h"
     19 #include "constexpr_char_traits.hpp"
     20 
     21 int main()
     22 {
     23     {
     24     typedef std::string_view SV;
     25     SV  sv1 {};
     26     SV  sv2 { "abcde", 5 };
     27 
     28     ASSERT_NOEXCEPT(sv1.starts_with('e'));
     29 
     30     assert (!sv1.starts_with('a'));
     31     assert (!sv1.starts_with('x'));
     32     assert ( sv2.starts_with('a'));
     33     assert (!sv2.starts_with('x'));
     34     }
     35 
     36 #if TEST_STD_VER > 11
     37     {
     38     typedef std::basic_string_view<char, constexpr_char_traits<char>> SV;
     39     constexpr SV  sv1 {};
     40     constexpr SV  sv2 { "abcde", 5 };
     41     static_assert (!sv1.starts_with('a'), "" );
     42     static_assert (!sv1.starts_with('x'), "" );
     43     static_assert ( sv2.starts_with('a'), "" );
     44     static_assert (!sv2.starts_with('x'), "" );
     45     }
     46 #endif
     47 }
     48