Parent Directory
|
Revision Log
pstade 2008 begins
1 #ifndef PSTADE_OVEN_SUB_RANGE_HPP 2 #define PSTADE_OVEN_SUB_RANGE_HPP 3 #include "./detail/prefix.hpp" 4 5 6 // PStade.Oven 7 // 8 // Copyright Shunsuke Sogame 2005-2007. 9 // Distributed under the Boost Software License, Version 1.0. 10 // (See accompanying file LICENSE_1_0.txt or copy at 11 // http://www.boost.org/LICENSE_1_0.txt) 12 13 14 // Note: 15 // 16 // The template-constructor is now explicit, 17 // which seems politically correct and enables 'to_base_range'. 18 19 20 #include <pstade/disable_if_copy.hpp> 21 #include <pstade/enable_if.hpp> 22 #include <pstade/implicitly_defined.hpp> 23 #include <pstade/is_convertible.hpp> 24 #include <pstade/radish/reset_assignment.hpp> 25 #include "./iter_range.hpp" 26 #include "./lightweight_copyable.hpp" 27 #include "./range_constant_iterator.hpp" 28 #include "./range_constantable.hpp" 29 30 31 namespace pstade { namespace oven { 32 33 34 template< class Range > 35 struct sub_range; 36 37 38 namespace sub_range_detail { 39 40 41 template< class Range > 42 struct super_ : 43 iter_range_of<Range, 44 radish::swappable < sub_range<Range>, 45 range_constantable < sub_range<Range>, typename range_constant_iterator<Range>::type, 46 lightweight_copyable< sub_range<Range> > > > 47 > 48 { }; 49 50 51 } // namespace sub_range_detail 52 53 54 template< class Range > 55 struct sub_range : 56 sub_range_detail::super_<Range>::type 57 { 58 private: 59 typedef sub_range self_t; 60 typedef typename sub_range_detail::super_<Range>::type super_t; 61 62 public: 63 typedef self_t type; 64 typedef super_t base; 65 typedef typename range_constant_iterator<Range>::type const_iterator; 66 67 public: 68 // structors 69 sub_range() 70 { } 71 72 sub_range(Range& rng) : 73 super_t(rng) 74 { } 75 76 template< class It, class Ij > 77 sub_range(iter_range<It, Ij> const& rng, 78 typename enable_if< is_convertible<iter_range<It, Ij>, super_t> >::type = 0 79 ) : 80 super_t(rng) 81 { } 82 83 template< class Iterator > 84 sub_range(Iterator first, Iterator last) : 85 super_t(first, last) 86 { } 87 88 template< class Range_ > 89 explicit sub_range(Range_& rng, typename disable_if_copy<self_t, Range_>::type = 0) : 90 super_t(rng) 91 { } 92 93 template< class Range_ > 94 explicit sub_range(Range_ const& rng) : 95 super_t(rng) 96 { } 97 98 // assignments 99 typedef sub_range pstade_radish_this_type; 100 #include PSTADE_RADISH_RESET_ASSIGNMENT() 101 102 // swappable 103 void swap(self_t& other) 104 { 105 super_t::swap(other); 106 } 107 108 // workaround 109 PSTADE_IMPLICITLY_DEFINED_COPY_TO_BASE(sub_range, super_t) 110 }; 111 112 113 } } // namespace pstade::oven 114 115 116 #endif