fix adaptors

This commit is contained in:
bolero-MURAKAMI 2012-12-01 14:34:54 +09:00
parent 86818d73cb
commit d57b6e2b18
20 changed files with 489 additions and 556 deletions

View file

@ -10,6 +10,7 @@
#include <sprout/iterator/distance.hpp>
#include <sprout/iterator/type_traits/common.hpp>
#include <sprout/utility/swap.hpp>
#include <sprout/utility/limited.hpp>
#include <sprout/type_traits/arithmetic_promote.hpp>
#include HDR_ITERATOR_SSCRISK_CEL_OR_SPROUT
@ -266,8 +267,8 @@ namespace sprout {
{
return lhs.is_in_left() && rhs.is_in_left() ? rhs.base() - lhs.base()
: !lhs.is_in_left() && !rhs.is_in_left() ? rhs.base2() - lhs.base2()
: lhs.is_in_left() ? (lhs.left_end() - lhs.base()) + (rhs.base2() - rhs.right_begin())
: (lhs.base2() - lhs.right_begin()) + (rhs.left_end() - rhs.base())
: lhs.is_in_left() ? sprout::limited::plus(lhs.left_end() - lhs.base(), rhs.base2() - rhs.right_begin())
: sprout::limited::plus(lhs.base2() - lhs.right_begin(), rhs.left_end() - rhs.base())
;
}
template<typename LIterator, typename RIterator>

View file

@ -8,7 +8,7 @@
#include <sprout/container/functions.hpp>
#include <sprout/iterator/next.hpp>
#include <sprout/iterator/alternate_iterator.hpp>
#include <sprout/range/range_container.hpp>
#include <sprout/range/adaptor/detail/jointed_range_default.hpp>
#include <sprout/range/algorithm/copy.hpp>
#include <sprout/type_traits/lvalue_reference.hpp>
#include <sprout/utility/forward.hpp>
@ -23,29 +23,29 @@ namespace sprout {
//
template<typename LRange, typename RRange>
class alternated_range
: public sprout::range::range_container<
: public sprout::adaptors::detail::jointed_range_default<
LRange, RRange,
sprout::alternate_iterator<
typename sprout::container_traits<LRange>::iterator,
typename sprout::container_traits<RRange>::iterator
>
>
, public sprout::detail::container_nosy_static_size<LRange>
, public sprout::detail::container_nosy_fixed_size<LRange>
{
public:
typedef LRange range_type;
typedef RRange range2_type;
typedef sprout::range::range_container<
typedef sprout::adaptors::detail::jointed_range_default<
LRange, RRange,
sprout::alternate_iterator<
typename sprout::container_traits<LRange>::iterator,
typename sprout::container_traits<RRange>::iterator
>
> base_type;
typedef typename base_type::range1_type range1_type;
typedef typename base_type::range2_type range2_type;
typedef typename base_type::iterator iterator;
public:
alternated_range() = default;
alternated_range(alternated_range const&) = default;
SPROUT_CONSTEXPR alternated_range(range_type& range1, range2_type& range2)
SPROUT_CONSTEXPR alternated_range(range1_type& range1, range2_type& range2)
: base_type(
iterator(sprout::begin(range1), sprout::begin(range2)),
iterator(
@ -124,28 +124,9 @@ namespace sprout {
// container_construct_traits
//
template<typename LRange, typename RRange>
struct container_construct_traits<sprout::adaptors::alternated_range<LRange, RRange> > {
public:
typedef typename sprout::container_construct_traits<LRange>::copied_type copied_type;
public:
template<typename Cont>
static SPROUT_CONSTEXPR copied_type deep_copy(Cont&& cont) {
return sprout::range::fixed::copy(sprout::forward<Cont>(cont), sprout::pit<copied_type>());
}
template<typename... Args>
static SPROUT_CONSTEXPR copied_type make(Args&&... args) {
return sprout::make<copied_type>(sprout::forward<Args>(args)...);
}
template<typename Cont, typename... Args>
static SPROUT_CONSTEXPR copied_type remake(
Cont&& cont,
typename sprout::container_traits<sprout::adaptors::alternated_range<LRange, RRange> >::difference_type size,
Args&&... args
)
{
return sprout::remake<copied_type>(sprout::forward<Cont>(cont), size, sprout::forward<Args>(args)...);
}
};
struct container_construct_traits<sprout::adaptors::alternated_range<LRange, RRange> >
: public sprout::container_construct_traits<typename sprout::adaptors::alternated_range<LRange, RRange>::base_type>
{};
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ADAPTOR_ALTERNATED_HPP

View file

@ -8,6 +8,7 @@
#include <sprout/container/functions.hpp>
#include <sprout/iterator/value_iterator.hpp>
#include <sprout/range/range_container.hpp>
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
#include <sprout/range/algorithm/copy.hpp>
#include <sprout/type_traits/lvalue_reference.hpp>
#include <sprout/utility/forward.hpp>
@ -26,21 +27,20 @@ namespace sprout {
//
template<typename T = sprout::blank_t, typename Range = void>
class blanked_range
: public sprout::range::range_container<
: public sprout::adaptors::detail::adapted_range_default<
Range,
sprout::value_iterator<T>
>
, public sprout::detail::container_nosy_static_size<Range>
, public sprout::detail::container_nosy_fixed_size<Range>
{
public:
typedef Range range_type;
typedef sprout::range::range_container<
typedef sprout::adaptors::detail::adapted_range_default<
Range,
sprout::value_iterator<T>
> base_type;
typedef typename base_type::range_type range_type;
typedef typename base_type::iterator iterator;
typedef typename base_type::value_type value_type;
typedef typename base_type::difference_type difference_type;
typedef typename base_type::size_type size_type;
public:
blanked_range() = default;
blanked_range(blanked_range const&) = default;
@ -162,28 +162,9 @@ namespace sprout {
// container_construct_traits
//
template<typename T, typename Range>
struct container_construct_traits<sprout::adaptors::blanked_range<T, Range> > {
public:
typedef typename sprout::container_construct_traits<Range>::copied_type copied_type;
public:
template<typename Cont>
static SPROUT_CONSTEXPR copied_type deep_copy(Cont&& cont) {
return sprout::range::fixed::copy(sprout::forward<Cont>(cont), sprout::pit<copied_type>());
}
template<typename... Args>
static SPROUT_CONSTEXPR copied_type make(Args&&... args) {
return sprout::make<copied_type>(sprout::forward<Args>(args)...);
}
template<typename Cont, typename... Args>
static SPROUT_CONSTEXPR copied_type remake(
Cont&& cont,
typename sprout::container_traits<sprout::adaptors::blanked_range<T, Range> >::difference_type size,
Args&&... args
)
{
return sprout::remake<copied_type>(sprout::forward<Cont>(cont), size, sprout::forward<Args>(args)...);
}
};
struct container_construct_traits<sprout::adaptors::blanked_range<T, Range> >
: public sprout::container_construct_traits<typename sprout::adaptors::blanked_range<T, Range>::base_type>
{};
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ADAPTOR_BLANKED_HPP

View file

@ -8,6 +8,7 @@
#include <sprout/container/functions.hpp>
#include <sprout/iterator/counting_iterator.hpp>
#include <sprout/range/range_container.hpp>
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
#include <sprout/range/algorithm/copy.hpp>
#include <sprout/type_traits/lvalue_reference.hpp>
#include <sprout/utility/forward.hpp>
@ -20,20 +21,19 @@ namespace sprout {
//
template<typename Incrementable, typename Range = void>
class counting_range
: public sprout::range::range_container<
: public sprout::adaptors::detail::adapted_range_default<
Range,
sprout::counting_iterator<Incrementable>
>
, public sprout::detail::container_nosy_static_size<Range>
, public sprout::detail::container_nosy_fixed_size<Range>
{
public:
typedef Range range_type;
typedef sprout::range::range_container<
typedef sprout::adaptors::detail::adapted_range_default<
Range,
sprout::counting_iterator<Incrementable>
> base_type;
typedef typename base_type::range_type range_type;
typedef typename base_type::iterator iterator;
typedef typename base_type::value_type value_type;
typedef typename base_type::difference_type difference_type;
public:
counting_range() = default;
counting_range(counting_range const&) = default;
@ -77,7 +77,6 @@ namespace sprout {
> base_type;
typedef typename base_type::iterator iterator;
typedef typename base_type::value_type value_type;
typedef typename base_type::difference_type difference_type;
public:
counting_range() = default;
counting_range(counting_range const&) = default;
@ -146,28 +145,9 @@ namespace sprout {
// container_construct_traits
//
template<typename Incrementable, typename Range>
struct container_construct_traits<sprout::adaptors::counting_range<Incrementable, Range> > {
public:
typedef typename sprout::container_construct_traits<Range>::copied_type copied_type;
public:
template<typename Cont>
static SPROUT_CONSTEXPR copied_type deep_copy(Cont&& cont) {
return sprout::range::fixed::copy(sprout::forward<Cont>(cont), sprout::pit<copied_type>());
}
template<typename... Args>
static SPROUT_CONSTEXPR copied_type make(Args&&... args) {
return sprout::make<copied_type>(sprout::forward<Args>(args)...);
}
template<typename Cont, typename... Args>
static SPROUT_CONSTEXPR copied_type remake(
Cont&& cont,
typename sprout::container_traits<sprout::adaptors::counting_range<Incrementable, Range> >::difference_type size,
Args&&... args
)
{
return sprout::remake<copied_type>(sprout::forward<Cont>(cont), size, sprout::forward<Args>(args)...);
}
};
struct container_construct_traits<sprout::adaptors::counting_range<Incrementable, Range> >
: public sprout::container_construct_traits<typename sprout::adaptors::counting_range<Incrementable, Range>::base_type>
{};
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ADAPTOR_COUNTING_HPP

View file

@ -0,0 +1,206 @@
#ifndef SPROUT_RANGE_ADAPTOR_DETAIL_JOINTED_RANGE_DEFAULT_HPP
#define SPROUT_RANGE_ADAPTOR_DETAIL_JOINTED_RANGE_DEFAULT_HPP
#include <sprout/config.hpp>
#include <sprout/pit.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/container/metafunctions.hpp>
#include <sprout/range/range_container.hpp>
#include <sprout/range/algorithm/copy.hpp>
#include <sprout/utility/forward.hpp>
#include <sprout/type_traits/arithmetic_promote.hpp>
namespace sprout {
namespace adaptors {
namespace detail {
template<typename LRange, typename RRange, typename = void>
class jointed_range_size;
template<typename LRange, typename RRange>
class jointed_range_size<
LRange, RRange,
typename std::enable_if<
sprout::detail::has_static_size<sprout::container_traits<LRange> >::value
&& sprout::detail::has_static_size<sprout::container_traits<RRange> >::value
>::type
> {
public:
typedef typename sprout::arithmetic_promote<
typename sprout::container_traits<LRange>::size_type,
typename sprout::container_traits<RRange>::size_type
>::type size_type;
SPROUT_STATIC_CONSTEXPR size_type static_size
= sprout::container_traits<LRange>::static_size + sprout::container_traits<RRange>::static_size
;
static SPROUT_CONSTEXPR size_type fixed_size() {
return static_size;
}
};
template<typename LRange, typename RRange>
class jointed_range_size<
LRange, RRange,
typename std::enable_if<
sprout::detail::has_static_size<sprout::container_traits<LRange> >::value
&& !sprout::detail::has_static_size<sprout::container_traits<RRange> >::value
>::type
> {
public:
typedef typename sprout::container_traits<LRange>::size_type size_type;
SPROUT_STATIC_CONSTEXPR size_type static_size = sprout::container_traits<LRange>::static_size;
static SPROUT_CONSTEXPR size_type fixed_size() {
return static_size;
}
};
template<typename LRange, typename RRange>
SPROUT_CONSTEXPR_OR_CONST typename sprout::adaptors::detail::jointed_range_size<
LRange, RRange,
typename std::enable_if<
sprout::detail::has_static_size<sprout::container_traits<LRange> >::value
&& !sprout::detail::has_static_size<sprout::container_traits<RRange> >::value
>::type
>::size_type
sprout::adaptors::detail::jointed_range_size<
LRange, RRange,
typename std::enable_if<
sprout::detail::has_static_size<sprout::container_traits<LRange> >::value
&& !sprout::detail::has_static_size<sprout::container_traits<RRange> >::value
>::type
>::static_size;
template<typename LRange, typename RRange>
class jointed_range_size<
LRange, RRange,
typename std::enable_if<
!sprout::detail::has_static_size<sprout::container_traits<LRange> >::value
&& sprout::detail::has_static_size<sprout::container_traits<RRange> >::value
>::type
> {
public:
typedef typename sprout::container_traits<RRange>::size_type size_type;
SPROUT_STATIC_CONSTEXPR size_type static_size = sprout::container_traits<RRange>::static_size;
static SPROUT_CONSTEXPR size_type fixed_size() {
return static_size;
}
};
template<typename LRange, typename RRange>
SPROUT_CONSTEXPR_OR_CONST typename sprout::adaptors::detail::jointed_range_size<
LRange, RRange,
typename std::enable_if<
!sprout::detail::has_static_size<sprout::container_traits<LRange> >::value
&& sprout::detail::has_static_size<sprout::container_traits<RRange> >::value
>::type
>::size_type
sprout::adaptors::detail::jointed_range_size<
LRange, RRange,
typename std::enable_if<
!sprout::detail::has_static_size<sprout::container_traits<LRange> >::value
&& sprout::detail::has_static_size<sprout::container_traits<RRange> >::value
>::type
>::static_size;
template<typename LRange, typename RRange>
class jointed_range_size<
LRange, RRange,
typename std::enable_if<
!sprout::detail::has_static_size<sprout::container_traits<LRange> >::value
&& !sprout::detail::has_static_size<sprout::container_traits<RRange> >::value
>::type
> {};
template<
typename LRange, typename RRange,
typename Iterator = typename sprout::container_traits<LRange>::iterator
>
class jointed_range_default
: public sprout::range::range_container<Iterator>
, public sprout::adaptors::detail::jointed_range_size<LRange, RRange>
{
public:
typedef LRange range_type;
typedef LRange range1_type;
typedef RRange range2_type;
typedef sprout::range::range_container<Iterator> base_type;
typedef typename base_type::iterator iterator;
public:
jointed_range_default() = default;
jointed_range_default(jointed_range_default const&) = default;
explicit SPROUT_CONSTEXPR jointed_range_default(iterator const& first, iterator const& last)
: base_type(first, last)
{}
};
template<typename LRange, typename RRange, typename = void>
class jointed_range_copied_type;
template<typename LRange, typename RRange>
class jointed_range_copied_type<
LRange, RRange,
typename std::enable_if<
sprout::containers::is_rebindable_size<LRange>::value
>::type
> {
public:
typedef typename sprout::containers::weak_rebind_size<
typename sprout::container_construct_traits<LRange>::copied_type,
sprout::adaptors::detail::jointed_range_size<LRange, RRange>::static_size
>::type copied_type;
};
template<typename LRange, typename RRange>
class jointed_range_copied_type<
LRange, RRange,
typename std::enable_if<
!sprout::containers::is_rebindable_size<LRange>::value && sprout::containers::is_rebindable_size<RRange>::value
>::type
> {
public:
typedef typename sprout::containers::weak_rebind_size<
typename sprout::container_construct_traits<RRange>::copied_type,
sprout::adaptors::detail::jointed_range_size<LRange, RRange>::static_size
>::type type;
};
template<typename LRange, typename RRange>
class jointed_range_copied_type<
LRange, RRange,
typename std::enable_if<
!sprout::containers::is_rebindable_size<LRange>::value && !sprout::containers::is_rebindable_size<RRange>::value
>::type
> {
public:
typedef typename sprout::container_construct_traits<LRange>::copied_type type;
};
} // namespace detail
} // namespace adaptors
//
// container_construct_traits
//
template<typename LRange, typename RRange, typename Iterator>
struct container_construct_traits<sprout::adaptors::detail::jointed_range_default<LRange, RRange, Iterator> > {
public:
typedef typename sprout::adaptors::detail::jointed_range_copied_type<LRange, RRange>::type copied_type;
public:
template<typename Cont>
static SPROUT_CONSTEXPR copied_type deep_copy(Cont&& cont) {
return sprout::range::fixed::copy(sprout::forward<Cont>(cont), sprout::pit<copied_type>());
}
template<typename... Args>
static SPROUT_CONSTEXPR copied_type make(Args&&... args) {
return sprout::make<copied_type>(sprout::forward<Args>(args)...);
}
template<typename Cont, typename... Args>
static SPROUT_CONSTEXPR copied_type remake(
Cont&& cont,
typename sprout::container_traits<sprout::adaptors::detail::jointed_range_default<LRange, RRange, Iterator> >::difference_type size,
Args&&... args
)
{
return sprout::remake<copied_type>(sprout::forward<Cont>(cont), size, sprout::forward<Args>(args)...);
}
};
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ADAPTOR_DETAIL_JOINTED_RANGE_DEFAULT_HPP

View file

@ -0,0 +1,111 @@
#ifndef SPROUT_RANGE_ADAPTOR_DETAIL_SIZED_RANGE_DEFAULT_HPP
#define SPROUT_RANGE_ADAPTOR_DETAIL_SIZED_RANGE_DEFAULT_HPP
#include <sprout/config.hpp>
#include <sprout/pit.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/container/metafunctions.hpp>
#include <sprout/range/range_container.hpp>
#include <sprout/range/algorithm/copy.hpp>
#include <sprout/utility/forward.hpp>
namespace sprout {
namespace adaptors {
namespace detail {
template<typename Range, typename sprout::container_traits<Range>::size_type Size, typename = void>
class sized_range_size;
template<typename Range, typename sprout::container_traits<Range>::size_type Size>
class sized_range_size<
Range, Size,
typename std::enable_if<sprout::detail::has_static_size<sprout::container_traits<Range> >::value>::type
> {
public:
SPROUT_STATIC_CONSTEXPR typename sprout::container_traits<Range>::size_type static_size
= Size < sprout::container_traits<Range>::static_size ? Size
: sprout::container_traits<Range>::static_size
;
static SPROUT_CONSTEXPR typename sprout::container_traits<Range>::size_type fixed_size() {
return static_size;
}
};
template<typename Range, typename sprout::container_traits<Range>::size_type Size>
SPROUT_CONSTEXPR_OR_CONST typename sprout::container_traits<Range>::size_type
sprout::adaptors::detail::sized_range_size<
Range, Size,
typename std::enable_if<sprout::detail::has_static_size<sprout::container_traits<Range> >::value>::type
>::static_size;
template<typename Range, typename sprout::container_traits<Range>::size_type Size>
class sized_range_size<
Range, Size,
typename std::enable_if<!sprout::detail::has_static_size<sprout::container_traits<Range> >::value>::type
> {
public:
SPROUT_STATIC_CONSTEXPR typename sprout::container_traits<Range>::size_type static_size = Size;
static SPROUT_CONSTEXPR typename sprout::container_traits<Range>::size_type fixed_size() {
return static_size;
}
};
template<typename Range, typename sprout::container_traits<Range>::size_type Size>
SPROUT_CONSTEXPR_OR_CONST typename sprout::container_traits<Range>::size_type
sprout::adaptors::detail::sized_range_size<
Range, Size,
typename std::enable_if<!sprout::detail::has_static_size<sprout::container_traits<Range> >::value>::type
>::static_size;
template<
typename Range, typename sprout::container_traits<Range>::size_type Size,
typename Iterator = typename sprout::container_traits<Range>::iterator
>
class sized_range_default
: public sprout::range::range_container<Iterator>
, public sprout::adaptors::detail::sized_range_size<Range, Size>
{
public:
typedef Range range_type;
typedef sprout::range::range_container<Iterator> base_type;
typedef typename base_type::iterator iterator;
public:
sized_range_default() = default;
sized_range_default(sized_range_default const&) = default;
explicit SPROUT_CONSTEXPR sized_range_default(iterator const& first, iterator const& last)
: base_type(first, last)
{}
};
} // namespace detail
} // namespace adaptors
//
// container_construct_traits
//
template<typename Range, typename sprout::container_traits<Range>::size_type Size, typename Iterator>
struct container_construct_traits<sprout::adaptors::detail::sized_range_default<Range, Size, Iterator> > {
public:
typedef typename sprout::containers::weak_rebind_size<
typename sprout::container_construct_traits<Range>::copied_type,
sprout::adaptors::detail::sized_range_default<Range, Size, Iterator>::static_size
>::type copied_type;
public:
template<typename Cont>
static SPROUT_CONSTEXPR copied_type deep_copy(Cont&& cont) {
return sprout::range::fixed::copy(sprout::forward<Cont>(cont), sprout::pit<copied_type>());
}
template<typename... Args>
static SPROUT_CONSTEXPR copied_type make(Args&&... args) {
return sprout::make<copied_type>(sprout::forward<Args>(args)...);
}
template<typename Cont, typename... Args>
static SPROUT_CONSTEXPR copied_type remake(
Cont&& cont,
typename sprout::container_traits<sprout::adaptors::detail::sized_range_default<Range, Size, Iterator> >::difference_type size,
Args&&... args
)
{
return sprout::remake<copied_type>(sprout::forward<Cont>(cont), size, sprout::forward<Args>(args)...);
}
};
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ADAPTOR_DETAIL_SIZED_RANGE_DEFAULT_HPP

View file

@ -7,7 +7,7 @@
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/iterator/filter_iterator.hpp>
#include <sprout/range/range_container.hpp>
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
#include <sprout/range/algorithm/copy.hpp>
#include <sprout/type_traits/lvalue_reference.hpp>
#include <sprout/utility/forward.hpp>
@ -20,24 +20,24 @@ namespace sprout {
//
template<typename Predicate, typename Range>
class filtered_range
: public sprout::range::range_container<
: public sprout::adaptors::detail::adapted_range_default<
Range,
sprout::filter_iterator<
Predicate,
typename sprout::container_traits<Range>::iterator
>
>
, public sprout::detail::container_nosy_static_size<Range>
, public sprout::detail::container_nosy_fixed_size<Range>
{
public:
typedef Predicate predicate_type;
typedef Range range_type;
typedef sprout::range::range_container<
typedef sprout::adaptors::detail::adapted_range_default<
Range,
sprout::filter_iterator<
Predicate,
typename sprout::container_traits<Range>::iterator
>
> base_type;
typedef typename base_type::range_type range_type;
typedef typename base_type::iterator iterator;
public:
filtered_range() = default;
@ -112,28 +112,9 @@ namespace sprout {
// container_construct_traits
//
template<typename Predicate, typename Range>
struct container_construct_traits<sprout::adaptors::filtered_range<Predicate, Range> > {
public:
typedef typename sprout::container_construct_traits<Range>::copied_type copied_type;
public:
template<typename Cont>
static SPROUT_CONSTEXPR copied_type deep_copy(Cont&& cont) {
return sprout::range::fixed::copy(sprout::forward<Cont>(cont), sprout::pit<copied_type>());
}
template<typename... Args>
static SPROUT_CONSTEXPR copied_type make(Args&&... args) {
return sprout::make<copied_type>(sprout::forward<Args>(args)...);
}
template<typename Cont, typename... Args>
static SPROUT_CONSTEXPR copied_type remake(
Cont&& cont,
typename sprout::container_traits<sprout::adaptors::filtered_range<Predicate, Range> >::difference_type size,
Args&&... args
)
{
return sprout::remake<copied_type>(sprout::forward<Cont>(cont), size, sprout::forward<Args>(args)...);
}
};
struct container_construct_traits<sprout::adaptors::filtered_range<Predicate, Range> >
: public sprout::container_construct_traits<typename sprout::adaptors::filtered_range<Predicate, Range>::base_type>
{};
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ADAPTOR_FILTERED_HPP

View file

@ -7,7 +7,7 @@
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/iterator/indexed_iterator.hpp>
#include <sprout/range/range_container.hpp>
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
#include <sprout/range/algorithm/copy.hpp>
#include <sprout/type_traits/lvalue_reference.hpp>
#include <sprout/utility/forward.hpp>
@ -20,19 +20,18 @@ namespace sprout {
//
template<typename Range>
class indexed_range
: public sprout::range::range_container<
: public sprout::adaptors::detail::adapted_range_default<
Range,
sprout::indexed_iterator<typename sprout::container_traits<Range>::iterator>
>
, public sprout::detail::container_nosy_static_size<Range>
, public sprout::detail::container_nosy_fixed_size<Range>
{
public:
typedef Range range_type;
typedef sprout::range::range_container<
typedef sprout::adaptors::detail::adapted_range_default<
Range,
sprout::indexed_iterator<typename sprout::container_traits<Range>::iterator>
> base_type;
typedef typename base_type::range_type range_type;
typedef typename base_type::iterator iterator;
typedef typename base_type::value_type value_type;
typedef typename iterator::index_type index_type;
public:
indexed_range() = default;
@ -122,28 +121,9 @@ namespace sprout {
// container_construct_traits
//
template<typename Range>
struct container_construct_traits<sprout::adaptors::indexed_range<Range> > {
public:
typedef typename sprout::container_construct_traits<Range>::copied_type copied_type;
public:
template<typename Cont>
static SPROUT_CONSTEXPR copied_type deep_copy(Cont&& cont) {
return sprout::range::fixed::copy(sprout::forward<Cont>(cont), sprout::pit<copied_type>());
}
template<typename... Args>
static SPROUT_CONSTEXPR copied_type make(Args&&... args) {
return sprout::make<copied_type>(sprout::forward<Args>(args)...);
}
template<typename Cont, typename... Args>
static SPROUT_CONSTEXPR copied_type remake(
Cont&& cont,
typename sprout::container_traits<sprout::adaptors::indexed_range<Range> >::difference_type size,
Args&&... args
)
{
return sprout::remake<copied_type>(sprout::forward<Cont>(cont), size, sprout::forward<Args>(args)...);
}
};
struct container_construct_traits<sprout::adaptors::indexed_range<Range> >
: public sprout::container_construct_traits<typename sprout::adaptors::indexed_range<Range>::base_type>
{};
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ADAPTOR_INDEXED_HPP

View file

@ -7,7 +7,7 @@
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/iterator/joint_iterator.hpp>
#include <sprout/range/range_container.hpp>
#include <sprout/range/adaptor/detail/jointed_range_default.hpp>
#include <sprout/range/algorithm/copy.hpp>
#include <sprout/type_traits/lvalue_reference.hpp>
#include <sprout/utility/forward.hpp>
@ -21,29 +21,29 @@ namespace sprout {
//
template<typename LRange, typename RRange>
class jointed_range
: public sprout::range::range_container<
: public sprout::adaptors::detail::jointed_range_default<
LRange, RRange,
sprout::joint_iterator<
typename sprout::container_traits<LRange>::iterator,
typename sprout::container_traits<RRange>::iterator
>
>
, public sprout::detail::container_nosy_static_size<LRange>
, public sprout::detail::container_nosy_fixed_size<LRange>
{
public:
typedef LRange range_type;
typedef RRange range2_type;
typedef sprout::range::range_container<
typedef sprout::adaptors::detail::jointed_range_default<
LRange, RRange,
sprout::joint_iterator<
typename sprout::container_traits<LRange>::iterator,
typename sprout::container_traits<RRange>::iterator
>
> base_type;
typedef typename base_type::range1_type range1_type;
typedef typename base_type::range2_type range2_type;
typedef typename base_type::iterator iterator;
public:
jointed_range() = default;
jointed_range(jointed_range const&) = default;
SPROUT_CONSTEXPR jointed_range(range_type& range1, range2_type& range2)
SPROUT_CONSTEXPR jointed_range(range1_type& range1, range2_type& range2)
: base_type(
iterator(sprout::begin(range1), sprout::end(range1), sprout::begin(range2), sprout::begin(range2)),
iterator(sprout::end(range1), sprout::end(range1), sprout::begin(range2), sprout::end(range2))
@ -119,28 +119,9 @@ namespace sprout {
// container_construct_traits
//
template<typename LRange, typename RRange>
struct container_construct_traits<sprout::adaptors::jointed_range<LRange, RRange> > {
public:
typedef typename sprout::container_construct_traits<LRange>::copied_type copied_type;
public:
template<typename Cont>
static SPROUT_CONSTEXPR copied_type deep_copy(Cont&& cont) {
return sprout::range::fixed::copy(sprout::forward<Cont>(cont), sprout::pit<copied_type>());
}
template<typename... Args>
static SPROUT_CONSTEXPR copied_type make(Args&&... args) {
return sprout::make<copied_type>(sprout::forward<Args>(args)...);
}
template<typename Cont, typename... Args>
static SPROUT_CONSTEXPR copied_type remake(
Cont&& cont,
typename sprout::container_traits<sprout::adaptors::jointed_range<LRange, RRange> >::difference_type size,
Args&&... args
)
{
return sprout::remake<copied_type>(sprout::forward<Cont>(cont), size, sprout::forward<Args>(args)...);
}
};
struct container_construct_traits<sprout::adaptors::jointed_range<LRange, RRange> >
: public sprout::container_construct_traits<typename sprout::adaptors::jointed_range<LRange, RRange>::base_type>
{};
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ADAPTOR_JOINTED_HPP

View file

@ -7,7 +7,7 @@
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/iterator/counting_iterator.hpp>
#include <sprout/range/range_container.hpp>
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
#include <sprout/range/algorithm/copy.hpp>
#include <sprout/type_traits/lvalue_reference.hpp>
#include <sprout/utility/forward.hpp>
@ -20,19 +20,18 @@ namespace sprout {
//
template<typename Range>
class outdirected_range
: public sprout::range::range_container<
: public sprout::adaptors::detail::adapted_range_default<
Range,
sprout::counting_iterator<typename sprout::container_traits<Range>::iterator>
>
, public sprout::detail::container_nosy_static_size<Range>
, public sprout::detail::container_nosy_fixed_size<Range>
{
public:
typedef Range range_type;
typedef sprout::range::range_container<
typedef sprout::adaptors::detail::adapted_range_default<
Range,
sprout::counting_iterator<typename sprout::container_traits<Range>::iterator>
> base_type;
typedef typename base_type::range_type range_type;
typedef typename base_type::iterator iterator;
typedef typename base_type::value_type value_type;
public:
outdirected_range() = default;
outdirected_range(outdirected_range const&) = default;
@ -76,28 +75,9 @@ namespace sprout {
// container_construct_traits
//
template<typename Range>
struct container_construct_traits<sprout::adaptors::outdirected_range<Range> > {
public:
typedef typename sprout::container_construct_traits<Range>::copied_type copied_type;
public:
template<typename Cont>
static SPROUT_CONSTEXPR copied_type deep_copy(Cont&& cont) {
return sprout::range::fixed::copy(sprout::forward<Cont>(cont), sprout::pit<copied_type>());
}
template<typename... Args>
static SPROUT_CONSTEXPR copied_type make(Args&&... args) {
return sprout::make<copied_type>(sprout::forward<Args>(args)...);
}
template<typename Cont, typename... Args>
static SPROUT_CONSTEXPR copied_type remake(
Cont&& cont,
typename sprout::container_traits<sprout::adaptors::outdirected_range<Range> >::difference_type size,
Args&&... args
)
{
return sprout::remake<copied_type>(sprout::forward<Cont>(cont), size, sprout::forward<Args>(args)...);
}
};
struct container_construct_traits<sprout::adaptors::outdirected_range<Range> >
: public sprout::container_construct_traits<typename sprout::adaptors::outdirected_range<Range>::base_type>
{};
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ADAPTOR_OUTDIRECTED_HPP

View file

@ -7,7 +7,7 @@
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/iterator/transform_iterator.hpp>
#include <sprout/range/range_container.hpp>
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
#include <sprout/range/algorithm/copy.hpp>
#include <sprout/type_traits/lvalue_reference.hpp>
#include <sprout/utility/forward.hpp>
@ -39,23 +39,23 @@ namespace sprout {
//
template<typename Range>
class replaced_range
: public sprout::range::range_container<
: public sprout::adaptors::detail::adapted_range_default<
Range,
sprout::transform_iterator<
sprout::adaptors::detail::replace_value<typename sprout::container_traits<Range>::value_type>,
typename sprout::container_traits<Range>::iterator
>
>
, public sprout::detail::container_nosy_static_size<Range>
, public sprout::detail::container_nosy_fixed_size<Range>
{
public:
typedef Range range_type;
typedef sprout::range::range_container<
typedef sprout::adaptors::detail::adapted_range_default<
Range,
sprout::transform_iterator<
sprout::adaptors::detail::replace_value<typename sprout::container_traits<Range>::value_type>,
typename sprout::container_traits<Range>::iterator
>
> base_type;
typedef typename base_type::range_type range_type;
typedef typename base_type::iterator iterator;
typedef typename base_type::value_type value_type;
public:
@ -133,28 +133,9 @@ namespace sprout {
// container_construct_traits
//
template<typename Range>
struct container_construct_traits<sprout::adaptors::replaced_range<Range> > {
public:
typedef typename sprout::container_construct_traits<Range>::copied_type copied_type;
public:
template<typename Cont>
static SPROUT_CONSTEXPR copied_type deep_copy(Cont&& cont) {
return sprout::range::fixed::copy(sprout::forward<Cont>(cont), sprout::pit<copied_type>());
}
template<typename... Args>
static SPROUT_CONSTEXPR copied_type make(Args&&... args) {
return sprout::make<copied_type>(sprout::forward<Args>(args)...);
}
template<typename Cont, typename... Args>
static SPROUT_CONSTEXPR copied_type remake(
Cont&& cont,
typename sprout::container_traits<sprout::adaptors::replaced_range<Range> >::difference_type size,
Args&&... args
)
{
return sprout::remake<copied_type>(sprout::forward<Cont>(cont), size, sprout::forward<Args>(args)...);
}
};
struct container_construct_traits<sprout::adaptors::replaced_range<Range> >
: public sprout::container_construct_traits<typename sprout::adaptors::replaced_range<Range>::base_type>
{};
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ADAPTOR_REPLACED_HPP

View file

@ -7,7 +7,7 @@
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/iterator/transform_iterator.hpp>
#include <sprout/range/range_container.hpp>
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
#include <sprout/range/algorithm/copy.hpp>
#include <sprout/type_traits/lvalue_reference.hpp>
#include <sprout/utility/forward.hpp>
@ -40,29 +40,30 @@ namespace sprout {
//
template<typename Predicate, typename Range>
class replaced_if_range
: public sprout::range::range_container<
: public sprout::adaptors::detail::adapted_range_default<
Range,
sprout::transform_iterator<
sprout::adaptors::detail::replace_value_if<Predicate, typename sprout::container_traits<Range>::value_type>,
typename sprout::container_traits<Range>::iterator
>
>
, public sprout::detail::container_nosy_static_size<Range>
, public sprout::detail::container_nosy_fixed_size<Range>
{
public:
typedef Range range_type;
typedef sprout::range::range_container<
typedef Predicate predicate_type;
typedef sprout::adaptors::detail::adapted_range_default<
Range,
sprout::transform_iterator<
sprout::adaptors::detail::replace_value_if<Predicate, typename sprout::container_traits<Range>::value_type>,
typename sprout::container_traits<Range>::iterator
>
> base_type;
typedef typename base_type::range_type range_type;
typedef typename base_type::iterator iterator;
typedef typename base_type::value_type value_type;
public:
replaced_if_range() = default;
replaced_if_range(replaced_if_range const&) = default;
explicit SPROUT_CONSTEXPR replaced_if_range(range_type& range, Predicate pred, value_type const& new_value)
explicit SPROUT_CONSTEXPR replaced_if_range(range_type& range, predicate_type pred, value_type const& new_value)
: base_type(
iterator(sprout::begin(range), typename iterator::functor_type(pred, new_value)),
iterator(sprout::end(range), typename iterator::functor_type(pred, new_value))
@ -137,28 +138,9 @@ namespace sprout {
// container_construct_traits
//
template<typename Predicate, typename Range>
struct container_construct_traits<sprout::adaptors::replaced_if_range<Predicate, Range> > {
public:
typedef typename sprout::container_construct_traits<Range>::copied_type copied_type;
public:
template<typename Cont>
static SPROUT_CONSTEXPR copied_type deep_copy(Cont&& cont) {
return sprout::range::fixed::copy(sprout::forward<Cont>(cont), sprout::pit<copied_type>());
}
template<typename... Args>
static SPROUT_CONSTEXPR copied_type make(Args&&... args) {
return sprout::make<copied_type>(sprout::forward<Args>(args)...);
}
template<typename Cont, typename... Args>
static SPROUT_CONSTEXPR copied_type remake(
Cont&& cont,
typename sprout::container_traits<sprout::adaptors::replaced_if_range<Predicate, Range> >::difference_type size,
Args&&... args
)
{
return sprout::remake<copied_type>(sprout::forward<Cont>(cont), size, sprout::forward<Args>(args)...);
}
};
struct container_construct_traits<sprout::adaptors::replaced_if_range<Predicate, Range> >
: public sprout::container_construct_traits<typename sprout::adaptors::replaced_if_range<Predicate, Range>::base_type>
{};
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ADAPTOR_REPLACED_IF_HPP

View file

@ -8,6 +8,7 @@
#include <sprout/container/functions.hpp>
#include <sprout/iterator/sawtooth_iterator.hpp>
#include <sprout/range/range_container.hpp>
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
#include <sprout/range/algorithm/copy.hpp>
#include <sprout/type_traits/lvalue_reference.hpp>
#include <sprout/utility/forward.hpp>
@ -20,20 +21,19 @@ namespace sprout {
//
template<typename Value, typename Range = void>
class sawtooth_wave_range
: public sprout::range::range_container<
: public sprout::adaptors::detail::adapted_range_default<
Range,
sprout::sawtooth_iterator<Value>
>
, public sprout::detail::container_nosy_static_size<Range>
, public sprout::detail::container_nosy_fixed_size<Range>
{
public:
typedef Range range_type;
typedef sprout::range::range_container<
typedef sprout::adaptors::detail::adapted_range_default<
Range,
sprout::sawtooth_iterator<Value>
> base_type;
typedef typename base_type::range_type range_type;
typedef typename base_type::iterator iterator;
typedef typename base_type::value_type value_type;
typedef typename base_type::difference_type difference_type;
public:
sawtooth_wave_range() = default;
sawtooth_wave_range(sawtooth_wave_range const&) = default;
@ -71,7 +71,6 @@ namespace sprout {
> base_type;
typedef typename base_type::iterator iterator;
typedef typename base_type::value_type value_type;
typedef typename base_type::difference_type difference_type;
public:
sawtooth_wave_range() = default;
sawtooth_wave_range(sawtooth_wave_range const&) = default;
@ -144,29 +143,10 @@ namespace sprout {
//
// container_construct_traits
//
template<typename Value, typename Range>
struct container_construct_traits<sprout::adaptors::sawtooth_wave_range<Value, Range> > {
public:
typedef typename sprout::container_construct_traits<Range>::copied_type copied_type;
public:
template<typename Cont>
static SPROUT_CONSTEXPR copied_type deep_copy(Cont&& cont) {
return sprout::range::fixed::copy(sprout::forward<Cont>(cont), sprout::pit<copied_type>());
}
template<typename... Args>
static SPROUT_CONSTEXPR copied_type make(Args&&... args) {
return sprout::make<copied_type>(sprout::forward<Args>(args)...);
}
template<typename Cont, typename... Args>
static SPROUT_CONSTEXPR copied_type remake(
Cont&& cont,
typename sprout::container_traits<sprout::adaptors::sawtooth_wave_range<Value, Range> >::difference_type size,
Args&&... args
)
{
return sprout::remake<copied_type>(sprout::forward<Cont>(cont), size, sprout::forward<Args>(args)...);
}
};
template<typename Range, typename Value>
struct container_construct_traits<sprout::adaptors::sawtooth_wave_range<Value, Range> >
: public sprout::container_construct_traits<typename sprout::adaptors::sawtooth_wave_range<Value, Range>::base_type>
{};
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ADAPTOR_SAWTOOTH_WAVE_HPP

View file

@ -8,6 +8,7 @@
#include <sprout/container/functions.hpp>
#include <sprout/iterator/sinusoid_iterator.hpp>
#include <sprout/range/range_container.hpp>
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
#include <sprout/range/algorithm/copy.hpp>
#include <sprout/type_traits/lvalue_reference.hpp>
#include <sprout/utility/forward.hpp>
@ -20,20 +21,19 @@ namespace sprout {
//
template<typename Value, typename Range = void>
class sinusoidal_range
: public sprout::range::range_container<
: public sprout::adaptors::detail::adapted_range_default<
Range,
sprout::sinusoid_iterator<Value>
>
, public sprout::detail::container_nosy_static_size<Range>
, public sprout::detail::container_nosy_fixed_size<Range>
{
public:
typedef Range range_type;
typedef sprout::range::range_container<
typedef sprout::adaptors::detail::adapted_range_default<
Range,
sprout::sinusoid_iterator<Value>
> base_type;
typedef typename base_type::range_type range_type;
typedef typename base_type::iterator iterator;
typedef typename base_type::value_type value_type;
typedef typename base_type::difference_type difference_type;
public:
sinusoidal_range() = default;
sinusoidal_range(sinusoidal_range const&) = default;
@ -71,7 +71,6 @@ namespace sprout {
> base_type;
typedef typename base_type::iterator iterator;
typedef typename base_type::value_type value_type;
typedef typename base_type::difference_type difference_type;
public:
sinusoidal_range() = default;
sinusoidal_range(sinusoidal_range const&) = default;
@ -144,29 +143,10 @@ namespace sprout {
//
// container_construct_traits
//
template<typename Value, typename Range>
struct container_construct_traits<sprout::adaptors::sinusoidal_range<Value, Range> > {
public:
typedef typename sprout::container_construct_traits<Range>::copied_type copied_type;
public:
template<typename Cont>
static SPROUT_CONSTEXPR copied_type deep_copy(Cont&& cont) {
return sprout::range::fixed::copy(sprout::forward<Cont>(cont), sprout::pit<copied_type>());
}
template<typename... Args>
static SPROUT_CONSTEXPR copied_type make(Args&&... args) {
return sprout::make<copied_type>(sprout::forward<Args>(args)...);
}
template<typename Cont, typename... Args>
static SPROUT_CONSTEXPR copied_type remake(
Cont&& cont,
typename sprout::container_traits<sprout::adaptors::sinusoidal_range<Value, Range> >::difference_type size,
Args&&... args
)
{
return sprout::remake<copied_type>(sprout::forward<Cont>(cont), size, sprout::forward<Args>(args)...);
}
};
template<typename Range, typename Value>
struct container_construct_traits<sprout::adaptors::sinusoidal_range<Value, Range> >
: public sprout::container_construct_traits<typename sprout::adaptors::sinusoidal_range<Value, Range>::base_type>
{};
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ADAPTOR_SINUSOIDAL_HPP

View file

@ -7,7 +7,7 @@
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/iterator/size_enum_iterator.hpp>
#include <sprout/range/range_container.hpp>
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
#include <sprout/range/algorithm/copy.hpp>
#include <sprout/type_traits/lvalue_reference.hpp>
#include <sprout/utility/forward.hpp>
@ -20,21 +20,21 @@ namespace sprout {
//
template<typename Range, bool Separated = false>
class size_enumed_range
: public sprout::range::range_container<
: public sprout::adaptors::detail::adapted_range_default<
Range,
sprout::size_enum_iterator<
typename sprout::container_traits<Range>::iterator
>
>
, public sprout::detail::container_nosy_static_size<Range>
, public sprout::detail::container_nosy_fixed_size<Range>
{
public:
typedef Range range_type;
typedef sprout::range::range_container<
typedef sprout::adaptors::detail::adapted_range_default<
Range,
sprout::size_enum_iterator<
typename sprout::container_traits<Range>::iterator
>
> base_type;
typedef typename base_type::range_type range_type;
typedef typename base_type::iterator iterator;
public:
size_enumed_range() = default;
@ -49,21 +49,21 @@ namespace sprout {
template<typename Range>
class size_enumed_range<Range, true>
: public sprout::range::range_container<
: public sprout::adaptors::detail::adapted_range_default<
Range,
sprout::size_enum_iterator<
typename sprout::container_traits<Range>::iterator, true
>
>
, public sprout::detail::container_nosy_static_size<Range>
, public sprout::detail::container_nosy_fixed_size<Range>
{
public:
typedef Range range_type;
typedef sprout::range::range_container<
typedef sprout::adaptors::detail::adapted_range_default<
Range,
sprout::size_enum_iterator<
typename sprout::container_traits<Range>::iterator, true
>
> base_type;
typedef typename base_type::range_type range_type;
typedef typename base_type::iterator iterator;
typedef typename base_type::value_type value_type;
public:
@ -164,28 +164,9 @@ namespace sprout {
// container_construct_traits
//
template<typename Range, bool Separated>
struct container_construct_traits<sprout::adaptors::size_enumed_range<Range, Separated> > {
public:
typedef typename sprout::container_construct_traits<Range>::copied_type copied_type;
public:
template<typename Cont>
static SPROUT_CONSTEXPR copied_type deep_copy(Cont&& cont) {
return sprout::range::fixed::copy(sprout::forward<Cont>(cont), sprout::pit<copied_type>());
}
template<typename... Args>
static SPROUT_CONSTEXPR copied_type make(Args&&... args) {
return sprout::make<copied_type>(sprout::forward<Args>(args)...);
}
template<typename Cont, typename... Args>
static SPROUT_CONSTEXPR copied_type remake(
Cont&& cont,
typename sprout::container_traits<sprout::adaptors::size_enumed_range<Range> >::difference_type size,
Args&&... args
)
{
return sprout::remake<copied_type>(sprout::forward<Cont>(cont), size, sprout::forward<Args>(args)...);
}
};
struct container_construct_traits<sprout::adaptors::size_enumed_range<Range, Separated> >
: public sprout::container_construct_traits<typename sprout::adaptors::size_enumed_range<Range, Separated>::base_type>
{};
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ADAPTOR_SIZE_ENUMED_HPP

View file

@ -7,8 +7,7 @@
#include <sprout/pit.hpp>
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/container/metafunctions.hpp>
#include <sprout/range/range_container.hpp>
#include <sprout/range/adaptor/detail/sized_range_default.hpp>
#include <sprout/range/algorithm/copy.hpp>
#include <sprout/type_traits/lvalue_reference.hpp>
#include <sprout/utility/forward.hpp>
@ -16,73 +15,25 @@
namespace sprout {
namespace adaptors {
namespace detail {
template<typename Range, typename sprout::container_traits<Range>::size_type Size, typename = void>
class sized_impl;
template<typename Range, typename sprout::container_traits<Range>::size_type Size>
class sized_impl<
Range, Size,
typename std::enable_if<sprout::detail::has_static_size<sprout::container_traits<Range> >::value>::type
> {
public:
SPROUT_STATIC_CONSTEXPR typename sprout::container_traits<Range>::size_type
static_size = Size < sprout::container_traits<Range>::static_size ? Size
: sprout::container_traits<Range>::static_size
;
static SPROUT_CONSTEXPR typename sprout::container_traits<Range>::size_type fixed_size() {
return static_size;
}
};
template<typename Range, typename sprout::container_traits<Range>::size_type Size>
SPROUT_CONSTEXPR_OR_CONST typename sprout::container_traits<Range>::size_type sized_impl<
Range, Size,
typename std::enable_if<sprout::detail::has_static_size<sprout::container_traits<Range> >::value>::type
>::static_size;
template<typename Range, typename sprout::container_traits<Range>::size_type Size>
class sized_impl<
Range, Size,
typename std::enable_if<!sprout::detail::has_static_size<sprout::container_traits<Range> >::value>::type
> {
public:
SPROUT_STATIC_CONSTEXPR typename sprout::container_traits<Range>::size_type static_size = Size;
static SPROUT_CONSTEXPR typename sprout::container_traits<Range>::size_type fixed_size() {
return static_size;
}
};
template<typename Range, typename sprout::container_traits<Range>::size_type Size>
SPROUT_CONSTEXPR_OR_CONST typename sprout::container_traits<Range>::size_type sized_impl<
Range, Size,
typename std::enable_if<!sprout::detail::has_static_size<sprout::container_traits<Range> >::value>::type
>::static_size;
} // namespace detail
//
// sized_range
//
template<typename Range, typename sprout::container_traits<Range>::size_type Size>
class sized_range
: public sprout::range::range_container<
typename sprout::container_traits<Range>::iterator
>
, public sprout::adaptors::detail::sized_impl<Range, Size>
: public sprout::adaptors::detail::sized_range_default<Range, Size>
{
public:
typedef Range range_type;
typedef sprout::range::range_container<
typename sprout::container_traits<Range>::iterator
> base_type;
private:
typedef sprout::adaptors::detail::sized_impl<Range, Size> sized_impl_type;
typedef sprout::adaptors::detail::sized_range_default<Range, Size> base_type;
typedef typename base_type::range_type range_type;
typedef typename base_type::size_type size_type;
public:
sized_range() = default;
sized_range(sized_range const&) = default;
explicit SPROUT_CONSTEXPR sized_range(range_type& range)
: base_type(
sprout::begin(range),
sized_impl_type::static_size < static_cast<typename sprout::container_traits<Range>::size_type>(sprout::size(range))
? sprout::next(sprout::begin(range), sized_impl_type::static_size)
base_type::static_size < static_cast<size_type>(sprout::size(range))
? sprout::next(sprout::begin(range), base_type::static_size)
: sprout::end(range)
)
{}
@ -126,33 +77,9 @@ namespace sprout {
// container_construct_traits
//
template<typename Range, typename sprout::container_traits<Range>::size_type Size>
struct container_construct_traits<sprout::adaptors::sized_range<Range, Size> > {
private:
typedef typename sprout::container_construct_traits<Range>::copied_type range_copied_type;
public:
typedef typename sprout::containers::weak_rebind_size<
range_copied_type,
sprout::adaptors::sized_range<Range, Size>::static_size
>::type copied_type;
public:
template<typename Cont>
static SPROUT_CONSTEXPR copied_type deep_copy(Cont&& cont) {
return sprout::range::fixed::copy(sprout::forward<Cont>(cont), sprout::pit<copied_type>());
}
template<typename... Args>
static SPROUT_CONSTEXPR copied_type make(Args&&... args) {
return sprout::make<copied_type>(sprout::forward<Args>(args)...);
}
template<typename Cont, typename... Args>
static SPROUT_CONSTEXPR copied_type remake(
Cont&& cont,
typename sprout::container_traits<sprout::adaptors::sized_range<Range, Size> >::difference_type size,
Args&&... args
)
{
return sprout::remake<copied_type>(sprout::forward<Cont>(cont), size, sprout::forward<Args>(args)...);
}
};
struct container_construct_traits<sprout::adaptors::sized_range<Range, Size> >
: public sprout::container_construct_traits<typename sprout::adaptors::sized_range<Range, Size>::base_type>
{};
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ADAPTOR_SIZED_HPP

View file

@ -8,6 +8,7 @@
#include <sprout/container/functions.hpp>
#include <sprout/iterator/square_iterator.hpp>
#include <sprout/range/range_container.hpp>
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
#include <sprout/range/algorithm/copy.hpp>
#include <sprout/type_traits/lvalue_reference.hpp>
#include <sprout/utility/forward.hpp>
@ -20,20 +21,19 @@ namespace sprout {
//
template<typename Value, typename Range = void>
class square_wave_range
: public sprout::range::range_container<
: public sprout::adaptors::detail::adapted_range_default<
Range,
sprout::square_iterator<Value>
>
, public sprout::detail::container_nosy_static_size<Range>
, public sprout::detail::container_nosy_fixed_size<Range>
{
public:
typedef Range range_type;
typedef sprout::range::range_container<
typedef sprout::adaptors::detail::adapted_range_default<
Range,
sprout::square_iterator<Value>
> base_type;
typedef typename base_type::range_type range_type;
typedef typename base_type::iterator iterator;
typedef typename base_type::value_type value_type;
typedef typename base_type::difference_type difference_type;
public:
square_wave_range() = default;
square_wave_range(square_wave_range const&) = default;
@ -75,7 +75,6 @@ namespace sprout {
> base_type;
typedef typename base_type::iterator iterator;
typedef typename base_type::value_type value_type;
typedef typename base_type::difference_type difference_type;
public:
square_wave_range() = default;
square_wave_range(square_wave_range const&) = default;
@ -154,29 +153,10 @@ namespace sprout {
//
// container_construct_traits
//
template<typename Value, typename Range>
struct container_construct_traits<sprout::adaptors::square_wave_range<Value, Range> > {
public:
typedef typename sprout::container_construct_traits<Range>::copied_type copied_type;
public:
template<typename Cont>
static SPROUT_CONSTEXPR copied_type deep_copy(Cont&& cont) {
return sprout::range::fixed::copy(sprout::forward<Cont>(cont), sprout::pit<copied_type>());
}
template<typename... Args>
static SPROUT_CONSTEXPR copied_type make(Args&&... args) {
return sprout::make<copied_type>(sprout::forward<Args>(args)...);
}
template<typename Cont, typename... Args>
static SPROUT_CONSTEXPR copied_type remake(
Cont&& cont,
typename sprout::container_traits<sprout::adaptors::square_wave_range<Value, Range> >::difference_type size,
Args&&... args
)
{
return sprout::remake<copied_type>(sprout::forward<Cont>(cont), size, sprout::forward<Args>(args)...);
}
};
template<typename Range, typename Value>
struct container_construct_traits<sprout::adaptors::square_wave_range<Value, Range> >
: public sprout::container_construct_traits<typename sprout::adaptors::square_wave_range<Value, Range>::base_type>
{};
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ADAPTOR_SQUARE_WAVE_HPP

View file

@ -7,7 +7,7 @@
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/iterator/step_iterator.hpp>
#include <sprout/range/range_container.hpp>
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
#include <sprout/range/algorithm/copy.hpp>
#include <sprout/type_traits/lvalue_reference.hpp>
#include <sprout/utility/forward.hpp>
@ -21,19 +21,18 @@ namespace sprout {
//
template<typename Range>
class steps_range
: public sprout::range::range_container<
: public sprout::adaptors::detail::adapted_range_default<
Range,
sprout::step_iterator<typename sprout::container_traits<Range>::iterator>
>
, public sprout::detail::container_nosy_static_size<Range>
, public sprout::detail::container_nosy_fixed_size<Range>
{
public:
typedef Range range_type;
typedef sprout::range::range_container<
typedef sprout::adaptors::detail::adapted_range_default<
Range,
sprout::step_iterator<typename sprout::container_traits<Range>::iterator>
> base_type;
typedef typename base_type::range_type range_type;
typedef typename base_type::iterator iterator;
typedef typename base_type::value_type value_type;
typedef typename base_type::difference_type difference_type;
public:
steps_range() = default;
@ -127,28 +126,9 @@ namespace sprout {
// container_construct_traits
//
template<typename Range>
struct container_construct_traits<sprout::adaptors::steps_range<Range> > {
public:
typedef typename sprout::container_construct_traits<Range>::copied_type copied_type;
public:
template<typename Cont>
static SPROUT_CONSTEXPR copied_type deep_copy(Cont&& cont) {
return sprout::range::fixed::copy(sprout::forward<Cont>(cont), sprout::pit<copied_type>());
}
template<typename... Args>
static SPROUT_CONSTEXPR copied_type make(Args&&... args) {
return sprout::make<copied_type>(sprout::forward<Args>(args)...);
}
template<typename Cont, typename... Args>
static SPROUT_CONSTEXPR copied_type remake(
Cont&& cont,
typename sprout::container_traits<sprout::adaptors::steps_range<Range> >::difference_type size,
Args&&... args
)
{
return sprout::remake<copied_type>(sprout::forward<Cont>(cont), size, sprout::forward<Args>(args)...);
}
};
struct container_construct_traits<sprout::adaptors::steps_range<Range> >
: public sprout::container_construct_traits<typename sprout::adaptors::steps_range<Range>::base_type>
{};
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ADAPTOR_STEPS_HPP

View file

@ -8,6 +8,7 @@
#include <sprout/container/functions.hpp>
#include <sprout/iterator/triangle_iterator.hpp>
#include <sprout/range/range_container.hpp>
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
#include <sprout/range/algorithm/copy.hpp>
#include <sprout/type_traits/lvalue_reference.hpp>
#include <sprout/utility/forward.hpp>
@ -20,20 +21,19 @@ namespace sprout {
//
template<typename Value, typename Range = void>
class triangle_wave_range
: public sprout::range::range_container<
: public sprout::adaptors::detail::adapted_range_default<
Range,
sprout::triangle_iterator<Value>
>
, public sprout::detail::container_nosy_static_size<Range>
, public sprout::detail::container_nosy_fixed_size<Range>
{
public:
typedef Range range_type;
typedef sprout::range::range_container<
typedef sprout::adaptors::detail::adapted_range_default<
Range,
sprout::triangle_iterator<Value>
> base_type;
typedef typename base_type::range_type range_type;
typedef typename base_type::iterator iterator;
typedef typename base_type::value_type value_type;
typedef typename base_type::difference_type difference_type;
public:
triangle_wave_range() = default;
triangle_wave_range(triangle_wave_range const&) = default;
@ -71,7 +71,6 @@ namespace sprout {
> base_type;
typedef typename base_type::iterator iterator;
typedef typename base_type::value_type value_type;
typedef typename base_type::difference_type difference_type;
public:
triangle_wave_range() = default;
triangle_wave_range(triangle_wave_range const&) = default;
@ -144,29 +143,10 @@ namespace sprout {
//
// container_construct_traits
//
template<typename Value, typename Range>
struct container_construct_traits<sprout::adaptors::triangle_wave_range<Value, Range> > {
public:
typedef typename sprout::container_construct_traits<Range>::copied_type copied_type;
public:
template<typename Cont>
static SPROUT_CONSTEXPR copied_type deep_copy(Cont&& cont) {
return sprout::range::fixed::copy(sprout::forward<Cont>(cont), sprout::pit<copied_type>());
}
template<typename... Args>
static SPROUT_CONSTEXPR copied_type make(Args&&... args) {
return sprout::make<copied_type>(sprout::forward<Args>(args)...);
}
template<typename Cont, typename... Args>
static SPROUT_CONSTEXPR copied_type remake(
Cont&& cont,
typename sprout::container_traits<sprout::adaptors::triangle_wave_range<Value, Range> >::difference_type size,
Args&&... args
)
{
return sprout::remake<copied_type>(sprout::forward<Cont>(cont), size, sprout::forward<Args>(args)...);
}
};
template<typename Range, typename Value>
struct container_construct_traits<sprout::adaptors::triangle_wave_range<Value, Range> >
: public sprout::container_construct_traits<typename sprout::adaptors::triangle_wave_range<Value, Range>::base_type>
{};
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ADAPTOR_TRIANGLE_WAVE_HPP

View file

@ -7,7 +7,7 @@
#include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp>
#include <sprout/iterator/valued_iterator.hpp>
#include <sprout/range/range_container.hpp>
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
#include <sprout/range/algorithm/copy.hpp>
#include <sprout/type_traits/lvalue_reference.hpp>
#include <sprout/utility/forward.hpp>
@ -20,19 +20,18 @@ namespace sprout {
//
template<typename Range, typename T>
class valued_range
: public sprout::range::range_container<
: public sprout::adaptors::detail::adapted_range_default<
Range,
sprout::valued_iterator<typename sprout::container_traits<Range>::iterator, T>
>
, public sprout::detail::container_nosy_static_size<Range>
, public sprout::detail::container_nosy_fixed_size<Range>
{
public:
typedef Range range_type;
typedef sprout::range::range_container<
typedef sprout::adaptors::detail::adapted_range_default<
Range,
sprout::valued_iterator<typename sprout::container_traits<Range>::iterator, T>
> base_type;
typedef typename base_type::range_type range_type;
typedef typename base_type::iterator iterator;
typedef typename base_type::value_type value_type;
typedef typename iterator::param_type param_type;
public:
valued_range() = default;
@ -110,28 +109,9 @@ namespace sprout {
// container_construct_traits
//
template<typename Range, typename T>
struct container_construct_traits<sprout::adaptors::valued_range<Range, T> > {
public:
typedef typename sprout::container_construct_traits<Range>::copied_type copied_type;
public:
template<typename Cont>
static SPROUT_CONSTEXPR copied_type deep_copy(Cont&& cont) {
return sprout::range::fixed::copy(sprout::forward<Cont>(cont), sprout::pit<copied_type>());
}
template<typename... Args>
static SPROUT_CONSTEXPR copied_type make(Args&&... args) {
return sprout::make<copied_type>(sprout::forward<Args>(args)...);
}
template<typename Cont, typename... Args>
static SPROUT_CONSTEXPR copied_type remake(
Cont&& cont,
typename sprout::container_traits<sprout::adaptors::valued_range<Range, T> >::difference_type size,
Args&&... args
)
{
return sprout::remake<copied_type>(sprout::forward<Cont>(cont), size, sprout::forward<Args>(args)...);
}
};
struct container_construct_traits<sprout::adaptors::valued_range<Range, T> >
: public sprout::container_construct_traits<typename sprout::adaptors::valued_range<Range, T>::base_type>
{};
} // namespace sprout
#endif // #ifndef SPROUT_RANGE_ADAPTOR_VALUED_HPP