Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:09:55

0001 /// \file
0002 // Range v3 library
0003 //
0004 //  Copyright Eric Niebler 2014-present
0005 //
0006 //  Use, modification and distribution is subject to the
0007 //  Boost Software License, Version 1.0. (See accompanying
0008 //  file LICENSE_1_0.txt or copy at
0009 //  http://www.boost.org/LICENSE_1_0.txt)
0010 //
0011 // Project home: https://github.com/ericniebler/range-v3
0012 //
0013 
0014 #ifndef RANGES_V3_VIEW_EMPTY_HPP
0015 #define RANGES_V3_VIEW_EMPTY_HPP
0016 
0017 #include <range/v3/range_fwd.hpp>
0018 
0019 #include <range/v3/view/interface.hpp>
0020 
0021 #include <range/v3/detail/prologue.hpp>
0022 
0023 namespace ranges
0024 {
0025     /// \addtogroup group-views
0026     /// @{
0027     template<typename T>
0028     struct empty_view : view_interface<empty_view<T>, (cardinality)0>
0029     {
0030         static_assert(std::is_object<T>::value,
0031                       "The template parameter to empty_view must be an object type.");
0032         empty_view() = default;
0033         static constexpr T * begin() noexcept
0034         {
0035             return nullptr;
0036         }
0037         static constexpr T * end() noexcept
0038         {
0039             return nullptr;
0040         }
0041         static constexpr std::size_t size() noexcept
0042         {
0043             return 0u;
0044         }
0045         static constexpr T * data() noexcept
0046         {
0047             return nullptr;
0048         }
0049         RANGES_DEPRECATED(
0050             "Replace views::empty<T>() with views::empty<T>. "
0051             "It is now a variable template.")
0052         empty_view operator()() const
0053         {
0054             return *this;
0055         }
0056     };
0057 
0058     template<typename T>
0059     RANGES_INLINE_VAR constexpr bool enable_borrowed_range<empty_view<T>> = true;
0060 
0061     namespace views
0062     {
0063         template<typename T>
0064         RANGES_INLINE_VAR constexpr empty_view<T> empty{};
0065     }
0066 
0067     namespace cpp20
0068     {
0069         namespace views
0070         {
0071             using ranges::views::empty;
0072         }
0073         template(typename T)(
0074             requires std::is_object<T>::value) //
0075             using empty_view = ranges::empty_view<T>;
0076     } // namespace cpp20
0077 
0078     /// @}
0079 } // namespace ranges
0080 
0081 #include <range/v3/detail/epilogue.hpp>
0082 #include <range/v3/detail/satisfy_boost_range.hpp>
0083 RANGES_SATISFY_BOOST_RANGE(::ranges::empty_view)
0084 
0085 #endif