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 10 #ifndef _LIBCPP___RANGES_EMPTY_VIEW_H 11 #define _LIBCPP___RANGES_EMPTY_VIEW_H 12 13 #include <__config> 14 #include <__ranges/enable_borrowed_range.h> 15 #include <__ranges/view_interface.h> 16 #include <type_traits> 17 18 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 19 # pragma GCC system_header 20 #endif 21 22 _LIBCPP_BEGIN_NAMESPACE_STD 23 24 #if _LIBCPP_STD_VER > 17 25 26 namespace ranges { 27 template<class _Tp> 28 requires is_object_v<_Tp> 29 class empty_view : public view_interface<empty_view<_Tp>> { 30 public: 31 _LIBCPP_HIDE_FROM_ABI static constexpr _Tp* begin() noexcept { return nullptr; } 32 _LIBCPP_HIDE_FROM_ABI static constexpr _Tp* end() noexcept { return nullptr; } 33 _LIBCPP_HIDE_FROM_ABI static constexpr _Tp* data() noexcept { return nullptr; } 34 _LIBCPP_HIDE_FROM_ABI static constexpr size_t size() noexcept { return 0; } 35 _LIBCPP_HIDE_FROM_ABI static constexpr bool empty() noexcept { return true; } 36 }; 37 38 template<class _Tp> 39 inline constexpr bool enable_borrowed_range<empty_view<_Tp>> = true; 40 41 namespace views { 42 43 template <class _Tp> 44 inline constexpr empty_view<_Tp> empty{}; 45 46 } // namespace views 47 } // namespace ranges 48 49 #endif // _LIBCPP_STD_VER > 17 50 51 _LIBCPP_END_NAMESPACE_STD 52 53 #endif // _LIBCPP___RANGES_EMPTY_VIEW_H 54