1fe6060f1SDimitry Andric // -*- C++ -*- 2fe6060f1SDimitry Andric //===----------------------------------------------------------------------===// 3fe6060f1SDimitry Andric // 4fe6060f1SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5fe6060f1SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 6fe6060f1SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7fe6060f1SDimitry Andric // 8fe6060f1SDimitry Andric //===----------------------------------------------------------------------===// 9bdd1243dSDimitry Andric 10fe6060f1SDimitry Andric #ifndef _LIBCPP___RANGES_EMPTY_VIEW_H 11fe6060f1SDimitry Andric #define _LIBCPP___RANGES_EMPTY_VIEW_H 12fe6060f1SDimitry Andric 13fe6060f1SDimitry Andric #include <__config> 1404eeddc0SDimitry Andric #include <__ranges/enable_borrowed_range.h> 15fe6060f1SDimitry Andric #include <__ranges/view_interface.h> 16*06c3fb27SDimitry Andric #include <__type_traits/is_object.h> 17*06c3fb27SDimitry Andric #include <cstddef> 18fe6060f1SDimitry Andric 19fe6060f1SDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 20fe6060f1SDimitry Andric # pragma GCC system_header 21fe6060f1SDimitry Andric #endif 22fe6060f1SDimitry Andric 23fe6060f1SDimitry Andric _LIBCPP_BEGIN_NAMESPACE_STD 24fe6060f1SDimitry Andric 25*06c3fb27SDimitry Andric #if _LIBCPP_STD_VER >= 20 26fe6060f1SDimitry Andric 27fe6060f1SDimitry Andric namespace ranges { 28fe6060f1SDimitry Andric template <class _Tp> 29fe6060f1SDimitry Andric requires is_object_v<_Tp> 30fe6060f1SDimitry Andric class empty_view : public view_interface<empty_view<_Tp>> { 31fe6060f1SDimitry Andric public: begin()32fe6060f1SDimitry Andric _LIBCPP_HIDE_FROM_ABI static constexpr _Tp* begin() noexcept { return nullptr; } end()33fe6060f1SDimitry Andric _LIBCPP_HIDE_FROM_ABI static constexpr _Tp* end() noexcept { return nullptr; } data()34fe6060f1SDimitry Andric _LIBCPP_HIDE_FROM_ABI static constexpr _Tp* data() noexcept { return nullptr; } size()35fe6060f1SDimitry Andric _LIBCPP_HIDE_FROM_ABI static constexpr size_t size() noexcept { return 0; } empty()36fe6060f1SDimitry Andric _LIBCPP_HIDE_FROM_ABI static constexpr bool empty() noexcept { return true; } 37fe6060f1SDimitry Andric }; 3804eeddc0SDimitry Andric 3904eeddc0SDimitry Andric template <class _Tp> 4004eeddc0SDimitry Andric inline constexpr bool enable_borrowed_range<empty_view<_Tp>> = true; 4181ad6265SDimitry Andric 4281ad6265SDimitry Andric namespace views { 4381ad6265SDimitry Andric 4481ad6265SDimitry Andric template <class _Tp> 4581ad6265SDimitry Andric inline constexpr empty_view<_Tp> empty{}; 4681ad6265SDimitry Andric 4781ad6265SDimitry Andric } // namespace views 48fe6060f1SDimitry Andric } // namespace ranges 49fe6060f1SDimitry Andric 50*06c3fb27SDimitry Andric #endif // _LIBCPP_STD_VER >= 20 51fe6060f1SDimitry Andric 52fe6060f1SDimitry Andric _LIBCPP_END_NAMESPACE_STD 53fe6060f1SDimitry Andric 54fe6060f1SDimitry Andric #endif // _LIBCPP___RANGES_EMPTY_VIEW_H 55