-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1cd6359
commit 8ba9ed6
Showing
3 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
libcxx/test/std/ranges/range.factories/range.single.view/empty.pass.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
// UNSUPPORTED: c++03, c++11, c++14, c++17 | ||
|
||
// static constexpr bool empty() noexcept; | ||
|
||
#include <cassert> | ||
#include <concepts> | ||
#include <ranges> | ||
#include <utility> | ||
|
||
#include "test_macros.h" | ||
|
||
struct Empty {}; | ||
struct BigType { | ||
char buffer[64] = {10}; | ||
}; | ||
|
||
template <typename T> | ||
constexpr void test_empty(T value) { | ||
using SingleView = std::ranges::single_view<T>; | ||
|
||
{ | ||
std::same_as<bool> decltype(auto) result = SingleView::empty(); | ||
assert(result == false); | ||
static_assert(noexcept(SingleView::empty())); | ||
} | ||
|
||
{ | ||
SingleView sv{value}; | ||
|
||
std::same_as<bool> decltype(auto) result = std::ranges::empty(sv); | ||
assert(result == false); | ||
static_assert(noexcept(std::ranges::empty(sv))); | ||
} | ||
{ | ||
const SingleView sv{value}; | ||
|
||
std::same_as<bool> decltype(auto) result = std::ranges::empty(sv); | ||
assert(result == false); | ||
static_assert(noexcept(std::ranges::empty(std::as_const(sv)))); | ||
} | ||
} | ||
|
||
constexpr bool test() { | ||
test_empty<int>(92); | ||
test_empty<Empty>(Empty{}); | ||
test_empty<BigType>(BigType{}); | ||
|
||
return true; | ||
} | ||
|
||
int main(int, char**) { | ||
test(); | ||
static_assert(test()); | ||
|
||
return 0; | ||
} |