xref: /freebsd/contrib/llvm-project/libcxx/include/__ranges/empty_view.h (revision 38a52bd3b5cac3da6f7f6eef3dd050e6aa08ebb3)
1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
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
7 //
8 //===----------------------------------------------------------------------===//
9 #ifndef _LIBCPP___RANGES_EMPTY_VIEW_H
10 #define _LIBCPP___RANGES_EMPTY_VIEW_H
11 
12 #include <__config>
13 #include <__ranges/enable_borrowed_range.h>
14 #include <__ranges/view_interface.h>
15 #include <type_traits>
16 
17 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18 #pragma GCC system_header
19 #endif
20 
21 _LIBCPP_BEGIN_NAMESPACE_STD
22 
23 #if !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
24 
25 namespace ranges {
26   template<class _Tp>
27     requires is_object_v<_Tp>
28   class empty_view : public view_interface<empty_view<_Tp>> {
29   public:
30     _LIBCPP_HIDE_FROM_ABI static constexpr _Tp* begin() noexcept { return nullptr; }
31     _LIBCPP_HIDE_FROM_ABI static constexpr _Tp* end() noexcept { return nullptr; }
32     _LIBCPP_HIDE_FROM_ABI static constexpr _Tp* data() noexcept { return nullptr; }
33     _LIBCPP_HIDE_FROM_ABI static constexpr size_t size() noexcept { return 0; }
34     _LIBCPP_HIDE_FROM_ABI static constexpr bool empty() noexcept { return true; }
35   };
36 
37   template<class _Tp>
38   inline constexpr bool enable_borrowed_range<empty_view<_Tp>> = true;
39 } // namespace ranges
40 
41 #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_INCOMPLETE_RANGES)
42 
43 _LIBCPP_END_NAMESPACE_STD
44 
45 #endif // _LIBCPP___RANGES_EMPTY_VIEW_H
46