diff --git a/sprout/functional/hash/hash.hpp b/sprout/functional/hash/hash.hpp index 3adb75c9..d10bddaf 100644 --- a/sprout/functional/hash/hash.hpp +++ b/sprout/functional/hash/hash.hpp @@ -11,7 +11,7 @@ namespace sprout { // // hash // - template + template struct hash { public: typedef T argument_type; diff --git a/sprout/iterator/amplitude_spectrum_iterator.hpp b/sprout/iterator/amplitude_spectrum_iterator.hpp index 58af95c0..8cbbf5dd 100644 --- a/sprout/iterator/amplitude_spectrum_iterator.hpp +++ b/sprout/iterator/amplitude_spectrum_iterator.hpp @@ -10,14 +10,23 @@ namespace sprout { // // amplitude_value // - template + template class amplitude_value { public: typedef typename T::value_type result_type; typedef T argument_type; public: - SPROUT_CONSTEXPR amplitude_value() {} - SPROUT_CONSTEXPR typename T::value_type operator()(T const& value) const { + SPROUT_CONSTEXPR typename T::value_type + operator()(T const& value) const { + return sprout::amplitude_spectrum_value(value); + } + }; + template<> + class amplitude_value { + public: + template + SPROUT_CONSTEXPR typename T::value_type + operator()(T const& value) const { return sprout::amplitude_spectrum_value(value); } }; diff --git a/sprout/iterator/phase_spectrum_iterator.hpp b/sprout/iterator/phase_spectrum_iterator.hpp index 189bf5da..11fc18b3 100644 --- a/sprout/iterator/phase_spectrum_iterator.hpp +++ b/sprout/iterator/phase_spectrum_iterator.hpp @@ -10,14 +10,23 @@ namespace sprout { // // phase_value // - template + template class phase_value { public: typedef typename T::value_type result_type; typedef T argument_type; public: - SPROUT_CONSTEXPR phase_value() {} - SPROUT_CONSTEXPR typename T::value_type operator()(T const& value) const { + SPROUT_CONSTEXPR typename T::value_type + operator()(T const& value) const { + return sprout::phase_spectrum_value(value); + } + }; + template<> + class phase_value { + public: + template + SPROUT_CONSTEXPR typename T::value_type + operator()(T const& value) const { return sprout::phase_spectrum_value(value); } }; diff --git a/sprout/iterator/replace_if_iterator.hpp b/sprout/iterator/replace_if_iterator.hpp index a1cc3a72..720c1a9d 100644 --- a/sprout/iterator/replace_if_iterator.hpp +++ b/sprout/iterator/replace_if_iterator.hpp @@ -19,8 +19,7 @@ namespace sprout { T new_; public: SPROUT_CONSTEXPR replace_value_if(Predicate pred, T const& new_value) - : pred_(pred) - , new_(new_value) + : pred_(pred), new_(new_value) {} SPROUT_CONSTEXPR T operator()(T const& value) const { return pred_(value) ? new_ : value; diff --git a/sprout/iterator/replace_iterator.hpp b/sprout/iterator/replace_iterator.hpp index 927012ee..f80da170 100644 --- a/sprout/iterator/replace_iterator.hpp +++ b/sprout/iterator/replace_iterator.hpp @@ -12,16 +12,16 @@ namespace sprout { class replace_value { public: typedef T result_type; - typedef T const& argument_type; + typedef T argument_type; private: T old_; T new_; public: SPROUT_CONSTEXPR replace_value(T const& old_value, T const& new_value) - : old_(old_value) - , new_(new_value) + : old_(old_value), new_(new_value) {} - SPROUT_CONSTEXPR T operator()(T const& value) const { + SPROUT_CONSTEXPR T + operator()(T const& value) const { return (value == old_) ? new_ : value; } }; diff --git a/sprout/math/gcd.hpp b/sprout/math/gcd.hpp index 515e10ea..db5c6801 100644 --- a/sprout/math/gcd.hpp +++ b/sprout/math/gcd.hpp @@ -215,15 +215,24 @@ namespace sprout { // // gcd_evaluator // - template + template class gcd_evaluator { public: typedef IntType result_type; typedef IntType first_argument_type; typedef IntType second_argument_type; public: - SPROUT_CONSTEXPR result_type - operator()(first_argument_type const& a, second_argument_type const& b) const { + SPROUT_CONSTEXPR IntType + operator()(IntType const& a, IntType const& b) const { + return sprout::math::detail::gcd_optimal(a, b); + } + }; + template<> + class gcd_evaluator { + public: + template + SPROUT_CONSTEXPR IntType + operator()(IntType const& a, IntType const& b) const { return sprout::math::detail::gcd_optimal(a, b); } }; diff --git a/sprout/math/lcm.hpp b/sprout/math/lcm.hpp index 16efdb11..a40eb1f7 100644 --- a/sprout/math/lcm.hpp +++ b/sprout/math/lcm.hpp @@ -74,15 +74,24 @@ namespace sprout { // // lcm_evaluator // - template + template class lcm_evaluator { public: typedef IntType result_type; typedef IntType first_argument_type; typedef IntType second_argument_type; public: - SPROUT_CONSTEXPR result_type - operator()(first_argument_type const& a, second_argument_type const& b) const { + SPROUT_CONSTEXPR IntType + operator()(IntType const& a, IntType const& b) const { + return sprout::math::detail::lcm_optimal(a, b); + } + }; + template<> + class lcm_evaluator { + public: + template + SPROUT_CONSTEXPR IntType + operator()(IntType const& a, IntType const& b) const { return sprout::math::detail::lcm_optimal(a, b); } }; diff --git a/sprout/range/adaptor/amplitude_spectrum.hpp b/sprout/range/adaptor/amplitude_spectrum.hpp index d3fe7929..ad1d205e 100644 --- a/sprout/range/adaptor/amplitude_spectrum.hpp +++ b/sprout/range/adaptor/amplitude_spectrum.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -14,18 +15,6 @@ namespace sprout { namespace adaptors { - namespace detail { - template - class amplitude_spectrum_value { - public: - typedef typename T::value_type result_type; - typedef T argument_type; - public: - SPROUT_CONSTEXPR result_type operator()(T const& value) const { - return sprout::amplitude_spectrum_value(value); - } - }; - } // namespace detail // // amplitude_spectrum_range // @@ -34,7 +23,7 @@ namespace sprout { : public sprout::adaptors::detail::adapted_range_default< Range, sprout::transform_iterator< - sprout::adaptors::detail::amplitude_spectrum_value::value_type>, + sprout::amplitude_value::value_type>, typename sprout::container_traits::iterator > > @@ -43,7 +32,7 @@ namespace sprout { typedef sprout::adaptors::detail::adapted_range_default< Range, sprout::transform_iterator< - sprout::adaptors::detail::amplitude_spectrum_value::value_type>, + sprout::amplitude_value::value_type>, typename sprout::container_traits::iterator > > base_type; diff --git a/sprout/range/adaptor/phase_spectrum.hpp b/sprout/range/adaptor/phase_spectrum.hpp index a1fd79a8..287868c5 100644 --- a/sprout/range/adaptor/phase_spectrum.hpp +++ b/sprout/range/adaptor/phase_spectrum.hpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -14,18 +15,6 @@ namespace sprout { namespace adaptors { - namespace detail { - template - class phase_spectrum_value { - public: - typedef typename T::value_type result_type; - typedef T argument_type; - public: - SPROUT_CONSTEXPR result_type operator()(T const& value) const { - return sprout::phase_spectrum_value(value); - } - }; - } // namespace detail // // phase_spectrum_range // @@ -34,7 +23,7 @@ namespace sprout { : public sprout::adaptors::detail::adapted_range_default< Range, sprout::transform_iterator< - sprout::adaptors::detail::phase_spectrum_value::value_type>, + sprout::phase_value::value_type>, typename sprout::container_traits::iterator > > @@ -43,7 +32,7 @@ namespace sprout { typedef sprout::adaptors::detail::adapted_range_default< Range, sprout::transform_iterator< - sprout::adaptors::detail::phase_spectrum_value::value_type>, + sprout::phase_value::value_type>, typename sprout::container_traits::iterator > > base_type;