[PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass
[llvm-project.git] / libcxx / test / std / strings / string.view / string.view.cons / implicit_deduction_guides.pass.cpp
blobd17ece6df18cfd022b22c3ab2e63275e4d2e126e
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: c++03, c++11, c++14
10 // UNSUPPORTED: libcpp-no-deduction-guides
12 // <string_view>
14 // Test that the constructors offered by std::basic_string_view are formulated
15 // so they're compatible with implicit deduction guides.
17 #include <string_view>
18 #include <cassert>
20 #include "test_macros.h"
21 #include "constexpr_char_traits.h"
23 // Overloads
24 // ---------------
25 // (1) basic_string_view() - NOT TESTED
26 // (2) basic_string_view(const basic_string_view&)
27 // (3) basic_string_view(const CharT*, size_type)
28 // (4) basic_string_view(const CharT*)
29 int main(int, char**)
31 { // Testing (1)
32 // Nothing to do. Cannot deduce without any arguments.
34 { // Testing (2)
35 const std::string_view sin("abc");
36 std::basic_string_view s(sin);
37 ASSERT_SAME_TYPE(decltype(s), std::string_view);
38 assert(s == "abc");
40 using WSV = std::basic_string_view<wchar_t, constexpr_char_traits<wchar_t>>;
41 const WSV win(L"abcdef");
42 std::basic_string_view w(win);
43 ASSERT_SAME_TYPE(decltype(w), WSV);
44 assert(w == L"abcdef");
46 { // Testing (3)
47 std::basic_string_view s("abc", 2);
48 ASSERT_SAME_TYPE(decltype(s), std::string_view);
49 assert(s == "ab");
51 std::basic_string_view w(L"abcdef", 4);
52 ASSERT_SAME_TYPE(decltype(w), std::wstring_view);
53 assert(w == L"abcd");
55 { // Testing (4)
56 std::basic_string_view s("abc");
57 ASSERT_SAME_TYPE(decltype(s), std::string_view);
58 assert(s == "abc");
60 std::basic_string_view w(L"abcdef");
61 ASSERT_SAME_TYPE(decltype(w), std::wstring_view);
62 assert(w == L"abcdef");
65 return 0;