Revert "[libc] Use best-fit binary trie to make malloc logarithmic" (#117065)
[llvm-project.git] / libcxx / test / std / ranges / range.factories / range.single.view / empty.pass.cpp
blob7e6ff015ea9a4138668a9c4e6fb49c273062ef68
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 // static constexpr bool empty() noexcept;
13 #include <cassert>
14 #include <concepts>
15 #include <ranges>
16 #include <utility>
18 #include "test_macros.h"
20 struct Empty {};
21 struct BigType {
22 char buffer[64] = {10};
25 template <typename T>
26 constexpr void test_empty(T value) {
27 using SingleView = std::ranges::single_view<T>;
30 std::same_as<bool> decltype(auto) result = SingleView::empty();
31 assert(result == false);
32 static_assert(noexcept(SingleView::empty()));
36 SingleView sv{value};
38 std::same_as<bool> decltype(auto) result = std::ranges::empty(sv);
39 assert(result == false);
40 static_assert(noexcept(std::ranges::empty(sv)));
43 const SingleView sv{value};
45 std::same_as<bool> decltype(auto) result = std::ranges::empty(sv);
46 assert(result == false);
47 static_assert(noexcept(std::ranges::empty(std::as_const(sv))));
51 constexpr bool test() {
52 test_empty<int>(92);
53 test_empty<Empty>(Empty{});
54 test_empty<BigType>(BigType{});
56 return true;
59 int main(int, char**) {
60 test();
61 static_assert(test());
63 return 0;