add math fmod

fix math cos
This commit is contained in:
bolero-MURAKAMI 2012-12-02 17:06:37 +09:00
parent d57b6e2b18
commit 18b479e3ac
15 changed files with 123 additions and 89 deletions

View file

@ -26,6 +26,8 @@ namespace sprout {
// //
// operator| // operator|
// //
// ???
#if !defined(__clang__)
template<typename Range> template<typename Range>
inline SPROUT_CONSTEXPR auto inline SPROUT_CONSTEXPR auto
operator|(Range&& lhs, sprout::compost::effects::vocal_cancelled_forwarder const& rhs) operator|(Range&& lhs, sprout::compost::effects::vocal_cancelled_forwarder const& rhs)
@ -44,6 +46,7 @@ namespace sprout {
) )
; ;
} }
#endif
} // namespace effects } // namespace effects
using sprout::compost::effects::vocal_cancelled; using sprout::compost::effects::vocal_cancelled;

View file

@ -7,10 +7,6 @@
# error should define COMPOST_DEF_LOAD_SOURCE_FILE. # error should define COMPOST_DEF_LOAD_SOURCE_FILE.
#endif #endif
#ifndef COMPOST_DEF_LOAD_SOURCE_DATA_INDEX
# define COMPOST_DEF_LOAD_SOURCE_DATA_INDEX -1
#endif
#define COMPOST_LOAD_IDENTIFIER_DETAIL_CAT(id, suffix) COMPOST_LOAD_IDENTIFIER_DETAIL_CAT_I(id, suffix) #define COMPOST_LOAD_IDENTIFIER_DETAIL_CAT(id, suffix) COMPOST_LOAD_IDENTIFIER_DETAIL_CAT_I(id, suffix)
#define COMPOST_LOAD_IDENTIFIER_DETAIL_CAT_I(id, suffix) COMPOST_LOAD_IDENTIFIER_DETAIL_CAT_II(id ## suffix) #define COMPOST_LOAD_IDENTIFIER_DETAIL_CAT_I(id, suffix) COMPOST_LOAD_IDENTIFIER_DETAIL_CAT_II(id ## suffix)
#define COMPOST_LOAD_IDENTIFIER_DETAIL_CAT_II(res) res #define COMPOST_LOAD_IDENTIFIER_DETAIL_CAT_II(res) res
@ -27,6 +23,12 @@
# define COMPOST_LOAD_INFO_IDENTIFIER COMPOST_LOAD_DETAIL_IDENTIFIER(info) # define COMPOST_LOAD_INFO_IDENTIFIER COMPOST_LOAD_DETAIL_IDENTIFIER(info)
#endif #endif
#ifdef COMPOST_DEF_LOAD_SOURCE_INDEX
# define COMPOST_LOAD_SOURCE_INDEX COMPOST_DEF_LOAD_SOURCE_INDEX
#else
# define COMPOST_LOAD_SOURCE_INDEX 0
#endif
SPROUT_STATIC_CONSTEXPR sprout::compost::sources::version_type COMPOST_LOAD_DETAIL_IDENTIFIER(version) = SPROUT_STATIC_CONSTEXPR sprout::compost::sources::version_type COMPOST_LOAD_DETAIL_IDENTIFIER(version) =
# define COMPOST_LOADING_SOURCE_VERSION # define COMPOST_LOADING_SOURCE_VERSION
# include COMPOST_DEF_LOAD_SOURCE_FILE # include COMPOST_DEF_LOAD_SOURCE_FILE
@ -46,14 +48,13 @@ SPROUT_STATIC_CONSTEXPR sprout::compost::sources::sound_type<
> COMPOST_LOAD_IDENTIFIER( > COMPOST_LOAD_IDENTIFIER(
COMPOST_LOAD_INFO_IDENTIFIER, COMPOST_LOAD_INFO_IDENTIFIER,
# define COMPOST_LOADING_SOURCE_DATA # define COMPOST_LOADING_SOURCE_DATA
# define COMPOST_LOADING_SOURCE_DATA_INDEX COMPOST_DEF_LOAD_SOURCE_DATA_INDEX
# include COMPOST_DEF_LOAD_SOURCE_FILE # include COMPOST_DEF_LOAD_SOURCE_FILE
# undef COMPOST_LOADING_SOURCE_DATA_INDEX
# undef COMPOST_LOADING_SOURCE_DATA # undef COMPOST_LOADING_SOURCE_DATA
); );
#undef COMPOST_LOAD_IDENTIFIER #undef COMPOST_LOAD_IDENTIFIER
#undef COMPOST_LOAD_INFO_IDENTIFIER #undef COMPOST_LOAD_INFO_IDENTIFIER
#undef COMPOST_LOAD_SOURCE_INDEX
#undef COMPOST_LOAD_DETAIL_IDENTIFIER #undef COMPOST_LOAD_DETAIL_IDENTIFIER
@ -66,3 +67,6 @@ SPROUT_STATIC_CONSTEXPR sprout::compost::sources::sound_type<
#ifdef COMPOST_DEF_LOAD_INFO_IDENTIFIER #ifdef COMPOST_DEF_LOAD_INFO_IDENTIFIER
# undef COMPOST_DEF_LOAD_INFO_IDENTIFIER # undef COMPOST_DEF_LOAD_INFO_IDENTIFIER
#endif #endif
#ifdef COMPOST_DEF_LOAD_SOURCE_INDEX
# undef COMPOST_DEF_LOAD_SOURCE_INDEX
#endif

View file

@ -8,6 +8,7 @@
#include <sprout/container/functions.hpp> #include <sprout/container/functions.hpp>
#include <sprout/iterator/generator_iterator.hpp> #include <sprout/iterator/generator_iterator.hpp>
#include <sprout/range/range_container.hpp> #include <sprout/range/range_container.hpp>
#include <sprout/range/adaptor/detail/adapted_range_default.hpp>
#include <sprout/range/algorithm/copy.hpp> #include <sprout/range/algorithm/copy.hpp>
#include <sprout/type_traits/lvalue_reference.hpp> #include <sprout/type_traits/lvalue_reference.hpp>
#include <sprout/utility/forward.hpp> #include <sprout/utility/forward.hpp>
@ -23,24 +24,23 @@ namespace sprout {
// //
template<typename Value, typename UniformRandomNumberGenerator, typename Range = void> template<typename Value, typename UniformRandomNumberGenerator, typename Range = void>
class white_noise_range class white_noise_range
: public sprout::range::range_container< : public sprout::adaptors::detail::adapted_range_default<
Range,
sprout::generator_iterator< sprout::generator_iterator<
sprout::random::random_result<UniformRandomNumberGenerator, sprout::random::normal_distribution<Value> > sprout::random::random_result<UniformRandomNumberGenerator, sprout::random::normal_distribution<Value> >
> >
> >
, public sprout::detail::container_nosy_static_size<Range>
, public sprout::detail::container_nosy_fixed_size<Range>
{ {
public: public:
typedef Range range_type; typedef sprout::adaptors::detail::adapted_range_default<
typedef sprout::range::range_container< Range,
sprout::generator_iterator< sprout::generator_iterator<
sprout::random::random_result<UniformRandomNumberGenerator, sprout::random::normal_distribution<Value> > sprout::random::random_result<UniformRandomNumberGenerator, sprout::random::normal_distribution<Value> >
> >
> base_type; > base_type;
typedef typename base_type::range_type range_type;
typedef typename base_type::iterator iterator; typedef typename base_type::iterator iterator;
typedef typename base_type::value_type value_type; typedef typename base_type::value_type value_type;
typedef typename base_type::difference_type difference_type;
typedef typename iterator::generator_type generator_type; typedef typename iterator::generator_type generator_type;
typedef typename generator_type::engine_type engine_type; typedef typename generator_type::engine_type engine_type;
typedef typename generator_type::distribution_type distribution_type; typedef typename generator_type::distribution_type distribution_type;
@ -57,10 +57,10 @@ namespace sprout {
iterator() iterator()
) )
{} {}
SPROUT_CONSTEXPR engine_type const& engine() const { SPROUT_CONSTEXPR engine_type engine() const {
return base_type::begin().generator().engine(); return base_type::begin().generator().engine();
} }
SPROUT_CONSTEXPR value_type const& sigma() const { SPROUT_CONSTEXPR value_type sigma() const {
return base_type::begin().generator().distribution().sigma(); return base_type::begin().generator().distribution().sigma();
} }
}; };
@ -81,7 +81,6 @@ namespace sprout {
> base_type; > base_type;
typedef typename base_type::iterator iterator; typedef typename base_type::iterator iterator;
typedef typename base_type::value_type value_type; typedef typename base_type::value_type value_type;
typedef typename base_type::difference_type difference_type;
typedef typename iterator::generator_type generator_type; typedef typename iterator::generator_type generator_type;
typedef typename generator_type::engine_type engine_type; typedef typename generator_type::engine_type engine_type;
typedef typename generator_type::distribution_type distribution_type; typedef typename generator_type::distribution_type distribution_type;
@ -97,10 +96,10 @@ namespace sprout {
iterator() iterator()
) )
{} {}
SPROUT_CONSTEXPR engine_type const& engine() const { SPROUT_CONSTEXPR engine_type engine() const {
return base_type::begin().generator().engine(); return base_type::begin().generator().engine();
} }
SPROUT_CONSTEXPR value_type const& sigma() const { SPROUT_CONSTEXPR value_type sigma() const {
return base_type::begin().generator().distribution().sigma(); return base_type::begin().generator().distribution().sigma();
} }
}; };
@ -154,28 +153,9 @@ namespace sprout {
// container_construct_traits // container_construct_traits
// //
template<typename Value, typename UniformRandomNumberGenerator, typename Range> template<typename Value, typename UniformRandomNumberGenerator, typename Range>
struct container_construct_traits<sprout::compost::waves::white_noise_range<Value, UniformRandomNumberGenerator, Range> > { struct container_construct_traits<sprout::compost::waves::white_noise_range<Value, UniformRandomNumberGenerator, Range> >
public: : public sprout::container_construct_traits<typename sprout::compost::waves::white_noise_range<Value, UniformRandomNumberGenerator, Range>::base_type>
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::compost::waves::white_noise_range<Value, UniformRandomNumberGenerator, Range> >::difference_type size,
Args&&... args
)
{
return sprout::remake<copied_type>(sprout::forward<Cont>(cont), size, sprout::forward<Args>(args)...);
}
};
} // namespace sprout } // namespace sprout
#endif // #ifndef SPROUT_COMPOST_WAVES_WHITE_NOISE_HPP #endif // #ifndef SPROUT_COMPOST_WAVES_WHITE_NOISE_HPP

View file

@ -71,6 +71,12 @@
# define SPROUT_USE_BUILTIN_BIT_OPERATION 0 # define SPROUT_USE_BUILTIN_BIT_OPERATION 0
#endif // #ifndef SPROUT_CONFIG_DISABLE_BUILTIN_BIT_OPERATION #endif // #ifndef SPROUT_CONFIG_DISABLE_BUILTIN_BIT_OPERATION
#ifndef SPROUT_CONFIG_DISABLE_THROW_INT_CONVERSION_OVERFLOW
# define SPROUT_NOTHROW_INT_CONVERSION_OVERFLOW 1
#else // #ifndef SPROUT_CONFIG_DISABLE_THROW_INT_CONVERSION_OVERFLOW
# define SPROUT_NOTHROW_INT_CONVERSION_OVERFLOW 0
#endif // #ifndef SPROUT_CONFIG_DISABLE_THROW_INT_CONVERSION_OVERFLOW
#ifndef SPROUT_CONFIG_DISABLE_SUPPORT_TEMPORARY_CONTAINER_ITERATION #ifndef SPROUT_CONFIG_DISABLE_SUPPORT_TEMPORARY_CONTAINER_ITERATION
# define SPROUT_USE_INDEX_ITERATOR_IMPLEMENTATION 1 # define SPROUT_USE_INDEX_ITERATOR_IMPLEMENTATION 1
#else // #ifndef SPROUT_CONFIG_DISABLE_SUPPORT_TEMPORARY_CONTAINER_ITERATION #else // #ifndef SPROUT_CONFIG_DISABLE_SUPPORT_TEMPORARY_CONTAINER_ITERATION

View file

@ -4,6 +4,7 @@
#include <cstdint> #include <cstdint>
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/tuple/tuple.hpp> #include <sprout/tuple/tuple.hpp>
#include <sprout/math/fmod.hpp>
namespace sprout { namespace sprout {
namespace darkroom { namespace darkroom {
@ -16,11 +17,6 @@ namespace sprout {
public: public:
typedef Element result_type; typedef Element result_type;
typedef Scale unit_type; typedef Scale unit_type;
private:
static SPROUT_CONSTEXPR unit_type
fmod(unit_type const& n, unit_type const& d) {
return n - std::intmax_t(n / d) * d;
}
private: private:
result_type elem1_; result_type elem1_;
result_type elem2_; result_type elem2_;
@ -42,14 +38,14 @@ namespace sprout {
operator()(Unit const& u, Unit const& v) const { operator()(Unit const& u, Unit const& v) const {
return calc_1( return calc_1(
(u < 0 (u < 0
? scale_ + fmod(u, scale_) ? scale_ + sprout::fmod(u, scale_)
: fmod(u, scale_) : sprout::fmod(u, scale_)
) )
- scale_ / 2 - scale_ / 2
, ,
(v < 0 (v < 0
? scale_ + fmod(v, scale_) ? scale_ + sprout::fmod(v, scale_)
: fmod(v, scale_) : sprout::fmod(v, scale_)
) )
- scale_ / 2 - scale_ / 2
); );

View file

@ -29,7 +29,7 @@ namespace sprout {
ceil(FloatType x) { ceil(FloatType x) {
return sprout::math::isinf(x) ? x return sprout::math::isinf(x) ? x
: std::numeric_limits<std::uintmax_t>::max() < x || std::numeric_limits<std::uintmax_t>::max() < -x : std::numeric_limits<std::uintmax_t>::max() < x || std::numeric_limits<std::uintmax_t>::max() < -x
? throw std::domain_error("ceil: Sorry, not implemented.") ? SPROUT_MATH_DETAIL_INT_CONVERSION_OVERFLOW(std::domain_error("ceil: Sorry, not implemented."), x)
: x < 0 ? -static_cast<FloatType>(static_cast<std::uintmax_t>(-x)) : x < 0 ? -static_cast<FloatType>(static_cast<std::uintmax_t>(-x))
: sprout::math::detail::ceil_impl(x, static_cast<FloatType>(static_cast<std::uintmax_t>(x))) : sprout::math::detail::ceil_impl(x, static_cast<FloatType>(static_cast<std::uintmax_t>(x)))
; ;

View file

@ -7,6 +7,8 @@
#include <sprout/config.hpp> #include <sprout/config.hpp>
#include <sprout/math/detail/config.hpp> #include <sprout/math/detail/config.hpp>
#include <sprout/math/factorial.hpp> #include <sprout/math/factorial.hpp>
#include <sprout/math/fmod.hpp>
#include <sprout/math/constants.hpp>
#include <sprout/type_traits/enabler_if.hpp> #include <sprout/type_traits/enabler_if.hpp>
namespace sprout { namespace sprout {
@ -14,9 +16,9 @@ namespace sprout {
namespace detail { namespace detail {
template<typename T> template<typename T>
inline SPROUT_CONSTEXPR T inline SPROUT_CONSTEXPR T
cos_impl(T x, T tmp, std::size_t n, T x2n) { cos_impl_1(T x, T tmp, std::size_t n, T x2n) {
return 2 * n > sprout::math::factorial_limit<T>() ? tmp return 2 * n > sprout::math::factorial_limit<T>() ? tmp
: sprout::math::detail::cos_impl( : sprout::math::detail::cos_impl_1(
x, x,
tmp + (n % 2 ? -1 : 1) * x2n / sprout::math::factorial<T>(2 * n), tmp + (n % 2 ? -1 : 1) * x2n / sprout::math::factorial<T>(2 * n),
n + 1, n + 1,
@ -25,6 +27,19 @@ namespace sprout {
; ;
} }
template<typename FloatType>
inline SPROUT_CONSTEXPR FloatType
cos_impl(FloatType x) {
typedef double type;
return static_cast<FloatType>(sprout::math::detail::cos_impl_1(
static_cast<type>(x),
type(1),
1,
static_cast<type>(x) * static_cast<type>(x)
))
;
}
template< template<
typename FloatType, typename FloatType,
typename sprout::enabler_if<std::is_floating_point<FloatType>::value>::type = sprout::enabler typename sprout::enabler_if<std::is_floating_point<FloatType>::value>::type = sprout::enabler
@ -35,12 +50,7 @@ namespace sprout {
return x == std::numeric_limits<FloatType>::infinity() return x == std::numeric_limits<FloatType>::infinity()
|| x == -std::numeric_limits<FloatType>::infinity() || x == -std::numeric_limits<FloatType>::infinity()
? std::numeric_limits<FloatType>::quiet_NaN() ? std::numeric_limits<FloatType>::quiet_NaN()
: static_cast<FloatType>(sprout::math::detail::cos_impl( : sprout::math::detail::cos_impl(sprout::math::fmod(x, 2 * sprout::math::pi<FloatType>()))
static_cast<type>(x),
type(1),
1,
static_cast<type>(x) * static_cast<type>(x)
))
; ;
} }

View file

@ -12,4 +12,10 @@
# define NS_SPROUT_MATH_DETAIL sprout::math::detail # define NS_SPROUT_MATH_DETAIL sprout::math::detail
#endif // #ifndef SPROUT_USE_BUILTIN_CMATH_FUNCTION #endif // #ifndef SPROUT_USE_BUILTIN_CMATH_FUNCTION
#if SPROUT_NOTHROW_INT_CONVERSION_OVERFLOW
# define SPROUT_MATH_DETAIL_INT_CONVERSION_OVERFLOW(e, x) (x)
#else
# define SPROUT_MATH_DETAIL_INT_CONVERSION_OVERFLOW(e, x) throw (e)
#endif
#endif // #ifndef SPROUT_MATH_DETAIL_CONFIG_HPP #endif // #ifndef SPROUT_MATH_DETAIL_CONFIG_HPP

View file

@ -29,7 +29,7 @@ namespace sprout {
floor(FloatType x) { floor(FloatType x) {
return sprout::math::isinf(x) ? x return sprout::math::isinf(x) ? x
: std::numeric_limits<std::uintmax_t>::max() < x || std::numeric_limits<std::uintmax_t>::max() < -x : std::numeric_limits<std::uintmax_t>::max() < x || std::numeric_limits<std::uintmax_t>::max() < -x
? throw std::domain_error("floor: Sorry, not implemented.") ? SPROUT_MATH_DETAIL_INT_CONVERSION_OVERFLOW(std::domain_error("floor: Sorry, not implemented."), x)
: x < 0 ? sprout::math::detail::floor_impl(x, -static_cast<FloatType>(static_cast<std::uintmax_t>(-x))) : x < 0 ? sprout::math::detail::floor_impl(x, -static_cast<FloatType>(static_cast<std::uintmax_t>(-x)))
: static_cast<FloatType>(static_cast<std::uintmax_t>(x)) : static_cast<FloatType>(static_cast<std::uintmax_t>(x))
; ;

47
sprout/math/fmod.hpp Normal file
View file

@ -0,0 +1,47 @@
#ifndef SPROUT_MATH_FMOD_HPP
#define SPROUT_MATH_FMOD_HPP
#include <cstdint>
#include <type_traits>
#include <stdexcept>
#include <sprout/config.hpp>
#include <sprout/math/isinf.hpp>
#include <sprout/math/trunc.hpp>
#include <sprout/type_traits/enabler_if.hpp>
#include <sprout/type_traits/float_promote.hpp>
namespace sprout {
namespace math {
namespace detail {
template<
typename FloatType,
typename sprout::enabler_if<std::is_floating_point<FloatType>::value>::type = sprout::enabler
>
inline SPROUT_CONSTEXPR FloatType
fmod(FloatType x, FloatType y) {
return y == 0 ? throw std::domain_error("fmod: divide by zero.")
: x - sprout::math::trunc(x / y) * y
;
}
template<
typename ArithmeticType1,
typename ArithmeticType2,
typename sprout::enabler_if<
std::is_arithmetic<ArithmeticType1>::value && std::is_arithmetic<ArithmeticType2>::value
>::type = sprout::enabler
>
inline SPROUT_CONSTEXPR typename sprout::float_promote<ArithmeticType1, ArithmeticType2>::type
fmod(ArithmeticType1 x, ArithmeticType2 y) {
typedef typename sprout::float_promote<ArithmeticType1, ArithmeticType2>::type type;
return sprout::math::detail::fmod(static_cast<type>(x), static_cast<type>(y));
}
} // namespace detail
using sprout::math::detail::fmod;
} // namespace math
using sprout::math::fmod;
} // namespace sprout
#endif // #ifndef SPROUT_MATH_FMOD_HPP

View file

@ -8,5 +8,6 @@
#include <sprout/math/fmax.hpp> #include <sprout/math/fmax.hpp>
#include <sprout/math/fmin.hpp> #include <sprout/math/fmin.hpp>
#include <sprout/math/fdim.hpp> #include <sprout/math/fdim.hpp>
#include <sprout/math/fmod.hpp>
#endif // #ifndef SPROUT_MATH_OPERATIONS_HPP #endif // #ifndef SPROUT_MATH_OPERATIONS_HPP

View file

@ -35,7 +35,7 @@ namespace sprout {
round(FloatType x) { round(FloatType x) {
return sprout::math::isinf(x) ? x return sprout::math::isinf(x) ? x
: std::numeric_limits<std::uintmax_t>::max() < x || std::numeric_limits<std::uintmax_t>::max() < -x : std::numeric_limits<std::uintmax_t>::max() < x || std::numeric_limits<std::uintmax_t>::max() < -x
? throw std::domain_error("round: Sorry, not implemented.") ? SPROUT_MATH_DETAIL_INT_CONVERSION_OVERFLOW(std::domain_error("round: Sorry, not implemented."), x)
: x < 0 ? sprout::math::detail::round_impl_nagative(x, -static_cast<FloatType>(static_cast<std::uintmax_t>(-x))) : x < 0 ? sprout::math::detail::round_impl_nagative(x, -static_cast<FloatType>(static_cast<std::uintmax_t>(-x)))
: sprout::math::detail::round_impl_positive(x, static_cast<FloatType>(static_cast<std::uintmax_t>(x))) : sprout::math::detail::round_impl_positive(x, static_cast<FloatType>(static_cast<std::uintmax_t>(x)))
; ;

View file

@ -21,7 +21,7 @@ namespace sprout {
trunc(FloatType x) { trunc(FloatType x) {
return sprout::math::isinf(x) ? x return sprout::math::isinf(x) ? x
: std::numeric_limits<std::uintmax_t>::max() < x || std::numeric_limits<std::uintmax_t>::max() < -x : std::numeric_limits<std::uintmax_t>::max() < x || std::numeric_limits<std::uintmax_t>::max() < -x
? throw std::domain_error("trunc: Sorry, not implemented.") ? SPROUT_MATH_DETAIL_INT_CONVERSION_OVERFLOW(std::domain_error("trunc: Sorry, not implemented."), x)
: x < 0 ? -static_cast<FloatType>(static_cast<std::uintmax_t>(-x)) : x < 0 ? -static_cast<FloatType>(static_cast<std::uintmax_t>(-x))
: static_cast<FloatType>(static_cast<std::uintmax_t>(x)) : static_cast<FloatType>(static_cast<std::uintmax_t>(x))
; ;

View file

@ -16,7 +16,7 @@ namespace sprout {
inline SPROUT_CONSTEXPR T inline SPROUT_CONSTEXPR T
sawtooth_value(T const& t) { sawtooth_value(T const& t) {
using sprout::floor; using sprout::floor;
return T(2) * (t - floor(t + T(0.5))); return 2 * (t - floor(t + T(0.5)));
} }
template<typename Container, sprout::index_t... Indexes> template<typename Container, sprout::index_t... Indexes>

View file

@ -7,7 +7,7 @@
#include <sprout/container/traits.hpp> #include <sprout/container/traits.hpp>
#include <sprout/container/functions.hpp> #include <sprout/container/functions.hpp>
#include <sprout/iterator/clamp_iterator.hpp> #include <sprout/iterator/clamp_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/range/algorithm/copy.hpp>
#include <sprout/type_traits/lvalue_reference.hpp> #include <sprout/type_traits/lvalue_reference.hpp>
#include <sprout/utility/forward.hpp> #include <sprout/utility/forward.hpp>
@ -24,17 +24,17 @@ namespace sprout {
typename Compare = NS_SSCRISK_CEL_OR_SPROUT::less<typename sprout::container_traits<Range>::value_type> typename Compare = NS_SSCRISK_CEL_OR_SPROUT::less<typename sprout::container_traits<Range>::value_type>
> >
class clamped_range class clamped_range
: public sprout::range::range_container< : public sprout::adaptors::detail::adapted_range_default<
Range,
sprout::clamp_iterator<typename sprout::container_traits<Range>::iterator, Compare> sprout::clamp_iterator<typename sprout::container_traits<Range>::iterator, Compare>
> >
, public sprout::detail::container_nosy_static_size<Range>
, public sprout::detail::container_nosy_fixed_size<Range>
{ {
public: public:
typedef Range range_type; typedef sprout::adaptors::detail::adapted_range_default<
typedef sprout::range::range_container< Range,
sprout::clamp_iterator<typename sprout::container_traits<Range>::iterator, Compare> sprout::clamp_iterator<typename sprout::container_traits<Range>::iterator, Compare>
> base_type; > base_type;
typedef typename base_type::range_type range_type;
typedef typename base_type::iterator iterator; typedef typename base_type::iterator iterator;
typedef typename base_type::value_type value_type; typedef typename base_type::value_type value_type;
typedef typename iterator::compare_type compare_type; typedef typename iterator::compare_type compare_type;
@ -137,28 +137,9 @@ namespace sprout {
// container_construct_traits // container_construct_traits
// //
template<typename Range, typename Compare> template<typename Range, typename Compare>
struct container_construct_traits<sprout::adaptors::clamped_range<Range, Compare> > { struct container_construct_traits<sprout::adaptors::clamped_range<Range, Compare> >
public: : public sprout::container_construct_traits<typename sprout::adaptors::clamped_range<Range, Compare>::base_type>
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::clamped_range<Range, Compare> >::difference_type size,
Args&&... args
)
{
return sprout::remake<copied_type>(sprout::forward<Cont>(cont), size, sprout::forward<Args>(args)...);
}
};
} // namespace sprout } // namespace sprout
#endif // #ifndef SPROUT_RANGE_ADAPTOR_CLAMPED_HPP #endif // #ifndef SPROUT_RANGE_ADAPTOR_CLAMPED_HPP