1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
11 // static constexpr size_t size() noexcept;
16 #include "test_macros.h"
18 constexpr bool test() {
20 auto sv
= std::ranges::single_view
<int>(42);
21 assert(sv
.size() == 1);
23 ASSERT_SAME_TYPE(decltype(sv
.size()), std::size_t);
24 static_assert(noexcept(sv
.size()));
27 const auto sv
= std::ranges::single_view
<int>(42);
28 assert(sv
.size() == 1);
30 ASSERT_SAME_TYPE(decltype(sv
.size()), std::size_t);
31 static_assert(noexcept(sv
.size()));
34 auto sv
= std::ranges::single_view
<int>(42);
35 assert(std::ranges::size(sv
) == 1);
37 ASSERT_SAME_TYPE(decltype(std::ranges::size(sv
)), std::size_t);
38 static_assert(noexcept(std::ranges::size(sv
)));
41 const auto sv
= std::ranges::single_view
<int>(42);
42 assert(std::ranges::size(sv
) == 1);
44 ASSERT_SAME_TYPE(decltype(std::ranges::size(sv
)), std::size_t);
45 static_assert(noexcept(std::ranges::size(sv
)));
48 // Test that it's static.
50 assert(std::ranges::single_view
<int>::size() == 1);
52 ASSERT_SAME_TYPE(decltype(std::ranges::single_view
<int>::size()), std::size_t);
53 static_assert(noexcept(std::ranges::single_view
<int>::size()));
59 int main(int, char**) {
61 static_assert(test());