• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2019 T. Zachary Laine
2 //
3 // Distributed under the Boost Software License, Version 1.0. (See
4 // accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 #ifndef BOOST_STL_INTERFACES_VIEW_TESTING_HPP
7 #define BOOST_STL_INTERFACES_VIEW_TESTING_HPP
8 
9 #include <boost/stl_interfaces/view_interface.hpp>
10 
11 
12 template<
13     typename Iterator,
14     typename Sentinel,
15     boost::stl_interfaces::element_layout Contiguity>
16 struct subrange
17     : boost::stl_interfaces::
18           view_interface<subrange<Iterator, Sentinel, Contiguity>, Contiguity>
19 {
20     subrange() = default;
subrangesubrange21     constexpr subrange(Iterator it, Sentinel s) : first_(it), last_(s) {}
22 
beginsubrange23     constexpr auto begin() const { return first_; }
endsubrange24     constexpr auto end() const { return last_; }
25 
26 private:
27     Iterator first_;
28     Sentinel last_;
29 };
30 
31 template<
32     boost::stl_interfaces::element_layout Contiguity,
33     typename Iterator,
34     typename Sentinel>
range(Iterator i,Sentinel s)35 auto range(Iterator i, Sentinel s)
36 {
37     return subrange<Iterator, Sentinel, Contiguity>(i, s);
38 }
39 
40 #endif
41