[PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass
[llvm-project.git] / libcxx / test / std / containers / views / span.cons / default.pass.cpp
blob98a58c703a4e41731019b638551bebdcb50b453b
1 // -*- C++ -*-
2 //===------------------------------ span ---------------------------------===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===---------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
11 // <span>
13 // constexpr span() noexcept;
15 #include <span>
16 #include <cassert>
17 #include <string>
18 #include <type_traits>
20 #include "test_macros.h"
22 void checkCV()
24 // Types the same (dynamic sized)
26 std::span< int> s1;
27 std::span<const int> s2;
28 std::span< volatile int> s3;
29 std::span<const volatile int> s4;
30 assert(s1.size() + s2.size() + s3.size() + s4.size() == 0);
33 // Types the same (static sized)
35 std::span< int,0> s1;
36 std::span<const int,0> s2;
37 std::span< volatile int,0> s3;
38 std::span<const volatile int,0> s4;
39 assert(s1.size() + s2.size() + s3.size() + s4.size() == 0);
44 template <typename T>
45 constexpr bool testConstexprSpan()
47 std::span<const T> s1;
48 std::span<const T, 0> s2;
49 return
50 s1.data() == nullptr && s1.size() == 0
51 && s2.data() == nullptr && s2.size() == 0;
55 template <typename T>
56 void testRuntimeSpan()
58 ASSERT_NOEXCEPT(T{});
59 std::span<const T> s1;
60 std::span<const T, 0> s2;
61 assert(s1.data() == nullptr && s1.size() == 0);
62 assert(s2.data() == nullptr && s2.size() == 0);
66 struct A{};
68 int main(int, char**)
70 static_assert(testConstexprSpan<int>(), "");
71 static_assert(testConstexprSpan<long>(), "");
72 static_assert(testConstexprSpan<double>(), "");
73 static_assert(testConstexprSpan<A>(), "");
75 testRuntimeSpan<int>();
76 testRuntimeSpan<long>();
77 testRuntimeSpan<double>();
78 testRuntimeSpan<std::string>();
79 testRuntimeSpan<A>();
81 checkCV();
83 static_assert( std::is_default_constructible_v<std::span<int, std::dynamic_extent>>, "");
84 static_assert( std::is_default_constructible_v<std::span<int, 0>>, "");
85 static_assert(!std::is_default_constructible_v<std::span<int, 2>>, "");
87 return 0;