[CodeGen] Use Register/MCRegister::isPhysical. NFC
[llvm-project.git] / libcxx / test / std / strings / string.view / string.view.access / front.pass.cpp
blob45edd3dc16b070faa1376c0d23d1edf321dd55bf
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: !stdlib=libc++ && (c++03 || c++11 || c++14)
11 // <string_view>
13 // constexpr const _CharT& back();
15 #include <string_view>
16 #include <cassert>
18 #include "test_macros.h"
20 template <typename CharT>
21 bool test(const CharT* s, std::size_t len) {
22 typedef std::basic_string_view<CharT> SV;
23 SV sv(s, len);
24 ASSERT_SAME_TYPE(decltype(sv.front()), typename SV::const_reference);
25 LIBCPP_ASSERT_NOEXCEPT(sv.front());
26 assert(sv.length() == len);
27 assert(sv.front() == s[0]);
28 return &sv.front() == s;
31 int main(int, char**) {
32 assert(test("ABCDE", 5));
33 assert(test("a", 1));
35 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
36 assert(test(L"ABCDE", 5));
37 assert(test(L"a", 1));
38 #endif
40 #if TEST_STD_VER >= 11
41 assert(test(u"ABCDE", 5));
42 assert(test(u"a", 1));
44 assert(test(U"ABCDE", 5));
45 assert(test(U"a", 1));
46 #endif
48 #if TEST_STD_VER >= 11
50 constexpr std::basic_string_view<char> sv("ABC", 2);
51 static_assert(sv.length() == 2, "");
52 static_assert(sv.front() == 'A', "");
54 #endif
56 return 0;