2 //===----------------------------------------------------------------------===//
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
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP___RANGES_EMPTY_VIEW_H
11 #define _LIBCPP___RANGES_EMPTY_VIEW_H
14 #include <__cstddef/size_t.h>
15 #include <__ranges/enable_borrowed_range.h>
16 #include <__ranges/view_interface.h>
17 #include <__type_traits/is_object.h>
19 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20 # pragma GCC system_header
23 _LIBCPP_BEGIN_NAMESPACE_STD
25 #if _LIBCPP_STD_VER >= 20
29 requires is_object_v
<_Tp
>
30 class empty_view
: public view_interface
<empty_view
<_Tp
>> {
32 _LIBCPP_HIDE_FROM_ABI
static constexpr _Tp
* begin() noexcept
{ return nullptr; }
33 _LIBCPP_HIDE_FROM_ABI
static constexpr _Tp
* end() noexcept
{ return nullptr; }
34 _LIBCPP_HIDE_FROM_ABI
static constexpr _Tp
* data() noexcept
{ return nullptr; }
35 _LIBCPP_HIDE_FROM_ABI
static constexpr size_t size() noexcept
{ return 0; }
36 _LIBCPP_HIDE_FROM_ABI
static constexpr bool empty() noexcept
{ return true; }
40 inline constexpr bool enable_borrowed_range
<empty_view
<_Tp
>> = true;
45 inline constexpr empty_view
<_Tp
> empty
{};
50 #endif // _LIBCPP_STD_VER >= 20
52 _LIBCPP_END_NAMESPACE_STD
54 #endif // _LIBCPP___RANGES_EMPTY_VIEW_H