Header file range/v3/begin_end.hpp

#include <range/v3/range_fwd.hpp>

#include <range/v3/utility/static_const.hpp>

#include <range/v3/utility/dangling.hpp>

#include <range/v3/utility/iterator.hpp>

namespace ranges
{
    inline namespace v3
    {
        namespace adl_begin_end_detail
        {
            using std::begin;
            
            using std::end;
            
            template <typename T>
            decltype(begin(ref.get())) begin(std::reference_wrapper<T> ref);
            
            template <typename T>
            decltype(end(ref.get())) end(std::reference_wrapper<T> ref);
            
            template <typename T, bool RValue>
            decltype(begin(ref.get())) begin(ranges::reference_wrapper<T, RValue> ref);
            
            template <typename T, bool RValue>
            decltype(end(ref.get())) end(ranges::reference_wrapper<T, RValue> ref);
            
            template <typename T>
            decltype(rbegin(ref.get())) rbegin(std::reference_wrapper<T> ref);
            
            template <typename T>
            decltype(rend(ref.get())) rend(std::reference_wrapper<T> ref);
            
            template <typename T, bool RValue>
            decltype(rbegin(ref.get())) rbegin(ranges::reference_wrapper<T, RValue> ref);
            
            template <typename T, bool RValue>
            decltype(rend(ref.get())) rend(ranges::reference_wrapper<T, RValue> ref);
            
            struct begin_fn
            {
                template <typename Rng>
                constexpr detail::decay_t<decltype(begin_fn::impl(static_cast<Rng&&>(rng), 0))> operator()(Rng&& rng) const noexcept(noexcept(begin_fn::impl(static_cast<Rng&&>(rng), 0)));
            };
            
            struct end_fn
            {
                template <typename Rng>
                constexpr detail::decay_t<decltype(end_fn::impl(static_cast<Rng&&>(rng), 0))> operator()(Rng&& rng) const noexcept(noexcept(end_fn::impl(static_cast<Rng&&>(rng), 0)));
            };
            
            struct rbegin_fn
            {
                template <typename Rng>
                constexpr detail::decay_t<decltype(rbegin_fn::impl(static_cast<Rng&&>(rng), 0))> operator()(Rng&& rng) const noexcept(noexcept(rbegin_fn::impl(static_cast<Rng&&>(rng), 0)));
                
                template <typename T, std::size_t N>
                constexpr ranges::reverse_iterator<T*> operator()(T(&) t[N]) const noexcept;
                
                template <typename T>
                constexpr ranges::reverse_iterator<T const*> operator()(std::initializer_list<T> il) const noexcept;
            };
            
            struct rend_fn
            {
                template <typename Rng>
                constexpr detail::decay_t<decltype(rend_fn::impl(static_cast<Rng&&>(rng), 0))> operator()(Rng&& rng) const noexcept(noexcept(rend_fn::impl(static_cast<Rng&&>(rng), 0)));
                
                template <typename T, std::size_t N>
                constexpr ranges::reverse_iterator<T*> operator()(T(&) t[N]) const noexcept;
                
                template <typename T>
                constexpr ranges::reverse_iterator<T const*> operator()(std::initializer_list<T> il) const noexcept;
            };
        }
        
        inline namespace 
        {
            constexpr auto& begin = static_const<begin_fn>::value;
        }
        
        inline namespace 
        {
            constexpr auto& end = static_const<end_fn>::value;
        }
        
        inline namespace 
        {
            constexpr auto& rbegin = static_const<rbegin_fn>::value;
        }
        
        inline namespace 
        {
            constexpr auto& rend = static_const<rend_fn>::value;
        }
        
        namespace adl_begin_end_detail
        {
            struct cbegin_fn
            {
                template <typename Rng>
                constexpr decltype(::ranges::begin(rng)) operator()(Rng const& rng) const noexcept(noexcept(::ranges::begin(rng)));
            };
            
            struct cend_fn
            {
                template <typename Rng>
                constexpr decltype(::ranges::end(rng)) operator()(Rng const& rng) const noexcept(noexcept(::ranges::end(rng)));
            };
            
            struct crbegin_fn
            {
                template <typename Rng>
                constexpr decltype(::ranges::rbegin(rng)) operator()(Rng const& rng) const noexcept(noexcept(::ranges::rbegin(rng)));
            };
            
            struct crend_fn
            {
                template <typename Rng>
                constexpr decltype(::ranges::rend(rng)) operator()(Rng const& rng) const noexcept(noexcept(::ranges::rend(rng)));
            };
        }
        
        inline namespace 
        {
            constexpr auto& cbegin = static_const<cbegin_fn>::value;
        }
        
        inline namespace 
        {
            constexpr auto& cend = static_const<cend_fn>::value;
        }
        
        inline namespace 
        {
            constexpr auto& crbegin = static_const<crbegin_fn>::value;
        }
        
        inline namespace 
        {
            constexpr auto& crend = static_const<crend_fn>::value;
        }
        
        struct safe_begin_fn;
        
        struct safe_end_fn;
        
        inline namespace 
        {
            constexpr auto& safe_begin = static_const<safe_begin_fn>::value;
        }
        
        inline namespace 
        {
            constexpr auto& safe_end = static_const<safe_end_fn>::value;
        }
    }
}

Variable ranges::v3::begin

constexpr auto& begin = static_const<begin_fn>::value;

begin free function


Variable ranges::v3::end

constexpr auto& end = static_const<end_fn>::value;

end free function


Variable ranges::v3::rbegin

constexpr auto& rbegin = static_const<rbegin_fn>::value;

rbegin free function


Variable ranges::v3::rend

constexpr auto& rend = static_const<rend_fn>::value;

rend free function


Variable ranges::v3::cbegin

constexpr auto& cbegin = static_const<cbegin_fn>::value;

begin free function with a const-qualified argument.


Variable ranges::v3::cend

constexpr auto& cend = static_const<cend_fn>::value;

end free function with a const-qualified argument.


Variable ranges::v3::crbegin

constexpr auto& crbegin = static_const<crbegin_fn>::value;

rbegin free function with a const-qualified argument.


Variable ranges::v3::crend

constexpr auto& crend = static_const<crend_fn>::value;

rend free function with a const-qualified argument.


Variable ranges::v3::safe_begin

constexpr auto& safe_begin = static_const<safe_begin_fn>::value;

begin(rng) if rng is an lvalue; otherwise, it returns begin(rng) wrapped in \c ranges::dangling.


Variable ranges::v3::safe_end

constexpr auto& safe_end = static_const<safe_end_fn>::value;

end(rng) if rng is an lvalue; otherwise, it returns end(rng) wrapped in \c ranges::dangling.