Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / test / std / ranges / range.factories / range.single.view / begin.pass.cpp
blobe14da8d01d1f3a5954fc4aa1734b982e4b5b0705
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, c++17
11 // constexpr T* begin() noexcept;
12 // constexpr const T* begin() const noexcept;
14 #include <ranges>
15 #include <cassert>
17 #include "test_macros.h"
19 struct Empty {};
20 struct BigType { char buffer[64] = {10}; };
22 constexpr bool test() {
24 auto sv = std::ranges::single_view<int>(42);
25 assert(*sv.begin() == 42);
27 ASSERT_SAME_TYPE(decltype(sv.begin()), int*);
28 static_assert(noexcept(sv.begin()));
31 const auto sv = std::ranges::single_view<int>(42);
32 assert(*sv.begin() == 42);
34 ASSERT_SAME_TYPE(decltype(sv.begin()), const int*);
35 static_assert(noexcept(sv.begin()));
39 auto sv = std::ranges::single_view<Empty>(Empty());
40 assert(sv.begin() != nullptr);
42 ASSERT_SAME_TYPE(decltype(sv.begin()), Empty*);
45 const auto sv = std::ranges::single_view<Empty>(Empty());
46 assert(sv.begin() != nullptr);
48 ASSERT_SAME_TYPE(decltype(sv.begin()), const Empty*);
52 auto sv = std::ranges::single_view<BigType>(BigType());
53 assert(sv.begin()->buffer[0] == 10);
55 ASSERT_SAME_TYPE(decltype(sv.begin()), BigType*);
58 const auto sv = std::ranges::single_view<BigType>(BigType());
59 assert(sv.begin()->buffer[0] == 10);
61 ASSERT_SAME_TYPE(decltype(sv.begin()), const BigType*);
64 return true;
67 int main(int, char**) {
68 test();
69 static_assert(test());
71 return 0;