Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /// \file
0002 // Range v3 library
0003 //
0004 //  Copyright Eric Niebler 2013-present
0005 //  Copyright Gonzalo Brito Gadeschi
0006 //
0007 //  Use, modification and distribution is subject to the
0008 //  Boost Software License, Version 1.0. (See accompanying
0009 //  file LICENSE_1_0.txt or copy at
0010 //  http://www.boost.org/LICENSE_1_0.txt)
0011 //
0012 // Project home: https://github.com/ericniebler/range-v3
0013 //
0014 
0015 #ifndef RANGES_V3_VIEW_INDICES_HPP
0016 #define RANGES_V3_VIEW_INDICES_HPP
0017 
0018 #include <meta/meta.hpp>
0019 
0020 #include <range/v3/range_fwd.hpp>
0021 
0022 #include <range/v3/range/concepts.hpp>
0023 #include <range/v3/utility/static_const.hpp>
0024 #include <range/v3/view/iota.hpp>
0025 
0026 #include <range/v3/detail/prologue.hpp>
0027 
0028 namespace ranges
0029 {
0030     namespace views
0031     {
0032         /// Half-open range of indices: [from, to).
0033         struct indices_fn : iota_view<std::size_t>
0034         {
0035             indices_fn() = default;
0036 
0037             template(typename Val)(
0038                 requires integral<Val>)
0039             iota_view<Val, Val> operator()(Val to) const
0040             {
0041                 return {Val(), to};
0042             }
0043             template(typename Val)(
0044                 requires integral<Val>)
0045             iota_view<Val, Val> operator()(Val from, Val to) const
0046             {
0047                 return {from, to};
0048             }
0049         };
0050 
0051         /// Inclusive range of indices: [from, to].
0052         struct closed_indices_fn
0053         {
0054             template(typename Val)(
0055                 requires integral<Val>)
0056             closed_iota_view<Val> operator()(Val to) const
0057             {
0058                 return {Val(), to};
0059             }
0060             template(typename Val)(
0061                 requires integral<Val>)
0062             closed_iota_view<Val> operator()(Val from, Val to) const
0063             {
0064                 return {from, to};
0065             }
0066         };
0067 
0068         /// \relates indices_fn
0069         /// \ingroup group-views
0070         RANGES_INLINE_VARIABLE(indices_fn, indices)
0071 
0072         /// \relates closed_indices_fn
0073         /// \ingroup group-views
0074         RANGES_INLINE_VARIABLE(closed_indices_fn, closed_indices)
0075     } // namespace views
0076 } // namespace ranges
0077 
0078 #include <range/v3/detail/epilogue.hpp>
0079 
0080 #endif // RANGES_V3_VIEW_INDICES_HPP