diff --git a/sprout/algorithm/cxx14.hpp b/sprout/algorithm/cxx14.hpp index b792242b..382c0e25 100644 --- a/sprout/algorithm/cxx14.hpp +++ b/sprout/algorithm/cxx14.hpp @@ -41,5 +41,30 @@ #include #include #include +#include +#include +#include +#include +#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include #endif // #ifndef SPROUT_ALGORITHM_CXX14_HPP diff --git a/sprout/algorithm/cxx14/nth_element.hpp b/sprout/algorithm/cxx14/nth_element.hpp new file mode 100644 index 00000000..4571a5df --- /dev/null +++ b/sprout/algorithm/cxx14/nth_element.hpp @@ -0,0 +1,27 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_NTH_ELEMENT_HPP +#define SPROUT_CXX14_ALGORITHM_NTH_ELEMENT_HPP + +#include + +namespace sprout { + // + // 25.4.2 Nth element + // + // !!! TOTO: implementation + template + inline SPROUT_CXX14_CONSTEXPR void + nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last); + + template + inline SPROUT_CXX14_CONSTEXPR void + nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last, Compare comp); +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_NTH_ELEMENT_HPP diff --git a/sprout/algorithm/cxx14/partial_sort.hpp b/sprout/algorithm/cxx14/partial_sort.hpp new file mode 100644 index 00000000..db8da8a6 --- /dev/null +++ b/sprout/algorithm/cxx14/partial_sort.hpp @@ -0,0 +1,27 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_PARTIAL_SORT_HPP +#define SPROUT_CXX14_ALGORITHM_PARTIAL_SORT_HPP + +#include + +namespace sprout { + // + // 25.4.1.3 partial_sort + // + // !!! TOTO: implementation + template + inline SPROUT_CXX14_CONSTEXPR void + partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last); + + template + inline SPROUT_CXX14_CONSTEXPR void + partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last, Compare comp); +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_PARTIAL_SORT_HPP diff --git a/sprout/algorithm/cxx14/partial_sort_copy.hpp b/sprout/algorithm/cxx14/partial_sort_copy.hpp new file mode 100644 index 00000000..e5591230 --- /dev/null +++ b/sprout/algorithm/cxx14/partial_sort_copy.hpp @@ -0,0 +1,27 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_PARTIAL_SORT_COPY_HPP +#define SPROUT_CXX14_ALGORITHM_PARTIAL_SORT_COPY_HPP + +#include + +namespace sprout { + // + // 25.4.1.4 partial_sort_copy + // + // !!! TOTO: implementation + template + inline SPROUT_CXX14_CONSTEXPR RandomAccessIterator + partial_sort_copy(InputIterator first, InputIterator last, RandomAccessIterator result_first, RandomAccessIterator result_last); + + template + inline SPROUT_CXX14_CONSTEXPR RandomAccessIterator + partial_sort_copy(InputIterator first, InputIterator last, RandomAccessIterator result_first, RandomAccessIterator result_last, Compare comp); +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_PARTIAL_SORT_COPY_HPP diff --git a/sprout/algorithm/cxx14/partition_copy.hpp b/sprout/algorithm/cxx14/partition_copy.hpp index 91d97729..93f159ef 100644 --- a/sprout/algorithm/cxx14/partition_copy.hpp +++ b/sprout/algorithm/cxx14/partition_copy.hpp @@ -17,7 +17,16 @@ namespace sprout { // template inline SPROUT_CXX14_CONSTEXPR sprout::pair - partition_copy(InputIterator first, InputIterator last, OutputIterator1 out_true, OutputIterator2 out_false, Predicate pred); // !!! + partition_copy(InputIterator first, InputIterator last, OutputIterator1 out_true, OutputIterator2 out_false, Predicate pred) { + for (; first != last; ++first) { + if (p(*first)) { + *out_true++ = *first; + } else { + *out_false++ = *first; + } + } + return sprout::pair(out_true, out_false); + } } // namespace sprout #endif // #ifndef SPROUT_CXX14_ALGORITHM_PARTITION_COPY_HPP diff --git a/sprout/algorithm/cxx14/shuffle.hpp b/sprout/algorithm/cxx14/shuffle.hpp index 823a3879..e8994ff0 100644 --- a/sprout/algorithm/cxx14/shuffle.hpp +++ b/sprout/algorithm/cxx14/shuffle.hpp @@ -8,7 +8,11 @@ #ifndef SPROUT_CXX14_ALGORITHM_SHUFFLE_HPP #define SPROUT_CXX14_ALGORITHM_SHUFFLE_HPP +#include #include +#include +#include +#include namespace sprout { // @@ -16,7 +20,20 @@ namespace sprout { // template inline SPROUT_CXX14_CONSTEXPR void - shuffle(RandomAccessIterator first, RandomAccessIterator last, UniformRandomNumberGenerator&& g); // !!! + shuffle(RandomAccessIterator first, RandomAccessIterator last, UniformRandomNumberGenerator&& g) { + typedef typename std::iterator_traits::difference_type difference_type; + typedef SPROUT_WORKAROUND_DETAIL_UNIFORM_INT_DISTRIBUTION distribution_type; + typedef typename distribution_type::param_type param_type; + difference_type d = last - first; + if (d > 1) { + distribution_type dist; + for (--last, --d; first < last; ++first, --d) { + difference_type i = dist(g, param_type(0, d)); + if (i != difference_type(0)) + sprout::iter_swap(first, first + i); + } + } + } } // namespace sprout #endif // #ifndef SPROUT_CXX14_ALGORITHM_SHUFFLE_HPP diff --git a/sprout/algorithm/cxx14/sort.hpp b/sprout/algorithm/cxx14/sort.hpp new file mode 100644 index 00000000..e68ced44 --- /dev/null +++ b/sprout/algorithm/cxx14/sort.hpp @@ -0,0 +1,27 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_SORT_HPP +#define SPROUT_CXX14_ALGORITHM_SORT_HPP + +#include + +namespace sprout { + // + // 25.4.1.1 sort + // + // !!! TOTO: implementation + template + inline SPROUT_CXX14_CONSTEXPR void + sort(RandomAccessIterator first, RandomAccessIterator last); + + template + inline SPROUT_CXX14_CONSTEXPR void + sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp); +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_SORT_HPP diff --git a/sprout/algorithm/cxx14/stable_partition.hpp b/sprout/algorithm/cxx14/stable_partition.hpp index 3c7bf00a..fe79a5d2 100644 --- a/sprout/algorithm/cxx14/stable_partition.hpp +++ b/sprout/algorithm/cxx14/stable_partition.hpp @@ -14,9 +14,10 @@ namespace sprout { // // 25.3.13 Partitions // + // !!! TOTO: implementation template inline SPROUT_CXX14_CONSTEXPR BidirectionalIterator - stable_partition(BidirectionalIterator first, BidirectionalIterator last, Predicate pred); // !!! + stable_partition(BidirectionalIterator first, BidirectionalIterator last, Predicate pred); } // namespace sprout #endif // #ifndef SPROUT_CXX14_ALGORITHM_STABLE_PARTITION_HPP diff --git a/sprout/algorithm/cxx14/stable_sort.hpp b/sprout/algorithm/cxx14/stable_sort.hpp new file mode 100644 index 00000000..ce7680ea --- /dev/null +++ b/sprout/algorithm/cxx14/stable_sort.hpp @@ -0,0 +1,27 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_CXX14_ALGORITHM_STABLE_SORT_HPP +#define SPROUT_CXX14_ALGORITHM_STABLE_SORT_HPP + +#include + +namespace sprout { + // + // 25.4.1.2 stable_sort + // + // !!! TOTO: implementation + template + inline SPROUT_CXX14_CONSTEXPR void + stable_sort(RandomAccessIterator first, RandomAccessIterator last); + + template + inline SPROUT_CXX14_CONSTEXPR void + stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp); +} // namespace sprout + +#endif // #ifndef SPROUT_CXX14_ALGORITHM_STABLE_SORT_HPP diff --git a/sprout/algorithm/nth_element.hpp b/sprout/algorithm/nth_element.hpp index 86ec613e..8faffc36 100644 --- a/sprout/algorithm/nth_element.hpp +++ b/sprout/algorithm/nth_element.hpp @@ -11,5 +11,6 @@ #include #include #include +#include #endif // #ifndef SPROUT_ALGORITHM_NTH_ELEMENT_HPP diff --git a/sprout/algorithm/partial_sort.hpp b/sprout/algorithm/partial_sort.hpp index 44ac91db..c862c5e7 100644 --- a/sprout/algorithm/partial_sort.hpp +++ b/sprout/algorithm/partial_sort.hpp @@ -11,5 +11,6 @@ #include #include #include +#include #endif // #ifndef SPROUT_ALGORITHM_PARTIAL_SORT_HPP diff --git a/sprout/algorithm/partial_sort_copy.hpp b/sprout/algorithm/partial_sort_copy.hpp new file mode 100644 index 00000000..8e1aa2a8 --- /dev/null +++ b/sprout/algorithm/partial_sort_copy.hpp @@ -0,0 +1,14 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_ALGORITHM_PARTIAL_SORT_COPY_HPP +#define SPROUT_ALGORITHM_PARTIAL_SORT_COPY_HPP + +#include +#include + +#endif // #ifndef SPROUT_ALGORITHM_PARTIAL_SORT_COPY_HPP diff --git a/sprout/algorithm/sort.hpp b/sprout/algorithm/sort.hpp index 1b755858..b9001e98 100644 --- a/sprout/algorithm/sort.hpp +++ b/sprout/algorithm/sort.hpp @@ -11,5 +11,6 @@ #include #include #include +#include #endif // #ifndef SPROUT_ALGORITHM_SORT_HPP diff --git a/sprout/algorithm/stable_sort.hpp b/sprout/algorithm/stable_sort.hpp index 40e44230..5837e01c 100644 --- a/sprout/algorithm/stable_sort.hpp +++ b/sprout/algorithm/stable_sort.hpp @@ -11,5 +11,6 @@ #include #include #include +#include #endif // #ifndef SPROUT_ALGORITHM_STABLE_SORT_HPP diff --git a/sprout/bitset/bitset.hpp b/sprout/bitset/bitset.hpp index f6d3dded..87959923 100644 --- a/sprout/bitset/bitset.hpp +++ b/sprout/bitset/bitset.hpp @@ -1023,7 +1023,7 @@ namespace sprout { template SPROUT_CXX14_CONSTEXPR void - copy_from_ptr(const Char* s, std::size_t len, std::size_t pos, std::size_t n, Char zero, Char one) { + copy_from_ptr(Char const* s, std::size_t len, std::size_t pos, std::size_t n, Char zero, Char one) { reset(); std::size_t const nbits = std::min(N, std::min(n, len - pos)); for (std::size_t i = nbits; i > 0; --i) { diff --git a/sprout/forward_clist.hpp b/sprout/forward_clist.hpp index 9ac35e3b..36947c59 100644 --- a/sprout/forward_clist.hpp +++ b/sprout/forward_clist.hpp @@ -406,7 +406,7 @@ namespace sprout { position.item->next = nxt; return iterator(nxt); } - template + template SPROUT_CXX14_CONSTEXPR iterator insert_after(const_iterator position, InputIterator first, InputIterator last) { item_holder_type nxt(position.item->next); item_holder_type pos(position.item); diff --git a/sprout/numeric/cxx14.hpp b/sprout/numeric/cxx14.hpp new file mode 100644 index 00000000..870d1102 --- /dev/null +++ b/sprout/numeric/cxx14.hpp @@ -0,0 +1,16 @@ +/*============================================================================= + Copyright (c) 2011-2013 Bolero MURAKAMI + https://github.com/bolero-MURAKAMI/Sprout + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#ifndef SPROUT_NUMERIC_CXX14_HPP +#define SPROUT_NUMERIC_CXX14_HPP + +#include +//#include +//#include +//#include + +#endif // #ifndef SPROUT_NUMERIC_CXX14_HPP diff --git a/sprout/numeric/modifying.hpp b/sprout/numeric/modifying.hpp index 321d2a36..0e171a4b 100644 --- a/sprout/numeric/modifying.hpp +++ b/sprout/numeric/modifying.hpp @@ -11,5 +11,6 @@ #include #include #include +#include #endif // #ifndef SPROUT_NUMERIC_MODIFYIING_HPP diff --git a/sprout/random/additive_combine.hpp b/sprout/random/additive_combine.hpp index a65d0e56..ac411b87 100644 --- a/sprout/random/additive_combine.hpp +++ b/sprout/random/additive_combine.hpp @@ -82,7 +82,7 @@ namespace sprout { SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT { return base1_type::modulus - 1; } - SPROUT_CONSTEXPR sprout::random::random_result operator()() const { + SPROUT_CONSTEXPR sprout::random::random_result const operator()() const { return generate(mlcg1_(), mlcg2_()); } SPROUT_CONSTEXPR base1_type const& base1() const SPROUT_NOEXCEPT { diff --git a/sprout/random/bernoulli_distribution.hpp b/sprout/random/bernoulli_distribution.hpp index 397ee488..5240a3fa 100644 --- a/sprout/random/bernoulli_distribution.hpp +++ b/sprout/random/bernoulli_distribution.hpp @@ -76,9 +76,9 @@ namespace sprout { private: RealType p_; private: - template + template SPROUT_CONSTEXPR sprout::random::random_result generate( - sprout::random::random_result const& rnd + EngineResult const& rnd ) const { return sprout::random::random_result( @@ -113,10 +113,10 @@ namespace sprout { p_ = parm.p(); } template - SPROUT_CONSTEXPR sprout::random::random_result operator()(Engine const& eng) const { + SPROUT_CONSTEXPR sprout::random::random_result const operator()(Engine const& eng) const { return p_ == RealType(0) ? sprout::random::random_result(false, eng, *this) - : generate(eng()) + : generate(eng()) ; } template diff --git a/sprout/random/binomial_distribution.hpp b/sprout/random/binomial_distribution.hpp index 1db6a958..8b66bcdb 100644 --- a/sprout/random/binomial_distribution.hpp +++ b/sprout/random/binomial_distribution.hpp @@ -649,8 +649,7 @@ namespace sprout { init(); } template - SPROUT_CONSTEXPR sprout::random::random_result - operator()(Engine const& eng) const { + SPROUT_CONSTEXPR sprout::random::random_result const operator()(Engine const& eng) const { return use_inversion() ? RealType(0.5) < p_ ? invert2(t_, 1 - p_, eng) : invert(t_, p_, eng) diff --git a/sprout/random/geometric_distribution.hpp b/sprout/random/geometric_distribution.hpp index f08abeef..9ed113c9 100644 --- a/sprout/random/geometric_distribution.hpp +++ b/sprout/random/geometric_distribution.hpp @@ -129,7 +129,7 @@ namespace sprout { log_1mp_ = init_log_1mp(p_); } template - SPROUT_CONSTEXPR sprout::random::random_result operator()(Engine const& eng) const { + SPROUT_CONSTEXPR sprout::random::random_result const operator()(Engine const& eng) const { return generate(eng); } template diff --git a/sprout/random/inversive_congruential.hpp b/sprout/random/inversive_congruential.hpp index 260783b3..8699acce 100644 --- a/sprout/random/inversive_congruential.hpp +++ b/sprout/random/inversive_congruential.hpp @@ -79,7 +79,7 @@ namespace sprout { SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT { return static_max(); } - SPROUT_CONSTEXPR sprout::random::random_result operator()() const { + SPROUT_CONSTEXPR sprout::random::random_result const operator()() const { typedef sprout::random::detail::const_mod do_mod; return generate(do_mod::mult_add(a, do_mod::invert(x_), b)); } diff --git a/sprout/random/linear_congruential.hpp b/sprout/random/linear_congruential.hpp index e7590526..07d7ea1f 100644 --- a/sprout/random/linear_congruential.hpp +++ b/sprout/random/linear_congruential.hpp @@ -82,7 +82,7 @@ namespace sprout { SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT { return static_max(); } - SPROUT_CONSTEXPR sprout::random::random_result operator()() const { + SPROUT_CONSTEXPR sprout::random::random_result const operator()() const { return generate(sprout::random::detail::const_mod::mult_add(a, x_, c)); } friend SPROUT_CONSTEXPR bool operator==(linear_congruential_engine const& lhs, linear_congruential_engine const& rhs) SPROUT_NOEXCEPT { @@ -164,10 +164,8 @@ namespace sprout { SPROUT_CONSTEXPR rand48(lcf_type const& lcf, private_construct_t) : lcf_(lcf) {} - SPROUT_CONSTEXPR sprout::random::random_result generate( - sprout::random::random_result const& lcf_result - ) const - { + template + SPROUT_CONSTEXPR sprout::random::random_result generate(LcfResult const& lcf_result) const { return sprout::random::random_result( lcf_result.result() >> 17, rand48(lcf_result.engine(), private_construct_t()) @@ -186,7 +184,7 @@ namespace sprout { SPROUT_CONSTEXPR result_type max() const { return static_max(); } - SPROUT_CONSTEXPR sprout::random::random_result operator()() const { + SPROUT_CONSTEXPR sprout::random::random_result const operator()() const { return generate(lcf_()); } friend SPROUT_CONSTEXPR bool operator==(rand48 const& lhs, rand48 const& rhs) { diff --git a/sprout/random/linear_feedback_shift.hpp b/sprout/random/linear_feedback_shift.hpp index 2eb8123c..67657b19 100644 --- a/sprout/random/linear_feedback_shift.hpp +++ b/sprout/random/linear_feedback_shift.hpp @@ -78,7 +78,7 @@ namespace sprout { SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT { return static_max(); } - SPROUT_CONSTEXPR sprout::random::random_result operator()() const { + SPROUT_CONSTEXPR sprout::random::random_result const operator()() const { return generate(((x_ & ((wordmask() << (w - k)) & wordmask())) << s) ^ ((((x_ << q) ^ x_) & wordmask()) >> (k - s))); } friend SPROUT_CONSTEXPR bool operator==(linear_feedback_shift_engine const& lhs, linear_feedback_shift_engine const& rhs) SPROUT_NOEXCEPT { diff --git a/sprout/random/mersenne_twister.hpp b/sprout/random/mersenne_twister.hpp index 5d902efd..968c4f0a 100644 --- a/sprout/random/mersenne_twister.hpp +++ b/sprout/random/mersenne_twister.hpp @@ -386,7 +386,7 @@ namespace sprout { SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT { return static_max(); } - SPROUT_CONSTEXPR sprout::random::random_result operator()() const { + SPROUT_CONSTEXPR sprout::random::random_result const operator()() const { return i_ == n ? twist().generate() : generate() diff --git a/sprout/random/normal_distribution.hpp b/sprout/random/normal_distribution.hpp index 6623a3ac..35953f3d 100644 --- a/sprout/random/normal_distribution.hpp +++ b/sprout/random/normal_distribution.hpp @@ -206,7 +206,7 @@ namespace sprout { valid_ = false; } template - SPROUT_CONSTEXPR sprout::random::random_result operator()(Engine const& eng) const { + SPROUT_CONSTEXPR sprout::random::random_result const operator()(Engine const& eng) const { return generate(eng); } template diff --git a/sprout/random/shuffle_order.hpp b/sprout/random/shuffle_order.hpp index 47af9345..58165774 100644 --- a/sprout/random/shuffle_order.hpp +++ b/sprout/random/shuffle_order.hpp @@ -144,7 +144,7 @@ namespace sprout { SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT { return rng_.max(); } - SPROUT_CONSTEXPR sprout::random::random_result operator()() const { + SPROUT_CONSTEXPR sprout::random::random_result const operator()() const { typedef typename std::make_unsigned::type base_unsigned; return generate( base_unsigned(sprout::random::detail::subtract()(max(), min())), diff --git a/sprout/random/uniform_01.hpp b/sprout/random/uniform_01.hpp index 8a0ade70..04bad9d1 100644 --- a/sprout/random/uniform_01.hpp +++ b/sprout/random/uniform_01.hpp @@ -60,22 +60,22 @@ namespace sprout { }; private: #ifdef SPROUT_WORKAROUND_NOT_TERMINATE_RECURSIVE_CONSTEXPR_FUNCTION_TEMPLATE - template + template SPROUT_CONSTEXPR sprout::random::random_result - generate_1(Engine const&, sprout::random::random_result const& rnd, result_type result) const { + generate_1(Engine const&, EngineResult const& rnd, result_type result) const { return result < result_type(1) ? sprout::random::random_result(result, rnd.engine(), *this) : generate(rnd.engine(), rnd.engine()()) ; } - template + template SPROUT_CONSTEXPR sprout::random::random_result - generate_1(Engine const&, sprout::random::random_result const&, result_type) const { + generate_1(Engine const&, EngineResult const&, result_type) const { return sprout::throw_recursive_function_template_instantiation_exeeded(); } - template + template SPROUT_CONSTEXPR sprout::random::random_result - generate(Engine const& eng, sprout::random::random_result const& rnd) const { + generate(Engine const& eng, EngineResult const& rnd) const { typedef typename Engine::result_type base_result; return generate_1( eng, @@ -89,23 +89,23 @@ namespace sprout { ) ); } - template + template SPROUT_CONSTEXPR sprout::random::random_result - generate(Engine const&, sprout::random::random_result const&) const { + generate(Engine const&, EngineResult const&) const { return sprout::throw_recursive_function_template_instantiation_exeeded(); } #else - template + template SPROUT_CONSTEXPR sprout::random::random_result - generate_1(Engine const&, sprout::random::random_result const& rnd, result_type result) const { + generate_1(Engine const&, EngineResult const& rnd, result_type result) const { return result < result_type(1) ? sprout::random::random_result(result, rnd.engine(), *this) : generate(rnd.engine(), rnd.engine()()) ; } - template + template SPROUT_CONSTEXPR sprout::random::random_result - generate(Engine const& eng, sprout::random::random_result const& rnd) const { + generate(Engine const& eng, EngineResult const& rnd) const { typedef typename Engine::result_type base_result; return generate_1( eng, @@ -134,7 +134,7 @@ namespace sprout { } SPROUT_CXX14_CONSTEXPR void param(param_type const&) {} template - SPROUT_CONSTEXPR sprout::random::random_result operator()(Engine const& eng) const { + SPROUT_CONSTEXPR sprout::random::random_result const operator()(Engine const& eng) const { return generate(eng, eng()); } template diff --git a/sprout/random/uniform_int_distribution.hpp b/sprout/random/uniform_int_distribution.hpp index c20c82ca..fdb15118 100644 --- a/sprout/random/uniform_int_distribution.hpp +++ b/sprout/random/uniform_int_distribution.hpp @@ -35,16 +35,16 @@ namespace sprout { template SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result generate_uniform_int(Engine const& eng, T min_value, T max_value, std::true_type); - template - inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result + template + inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result generate_uniform_int_true_3_1( - sprout::random::random_result const& rnd, T min_value, RangeType range, + EngineResult const& rnd, T min_value, RangeType range, BaseResult bmin, BaseUnsigned brange, BaseUnsigned bucket_size ); - template - inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result + template + inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result generate_uniform_int_true_3_1( - sprout::random::random_result const& rnd, T min_value, RangeType range, + EngineResult const& rnd, T min_value, RangeType range, BaseResult bmin, BaseUnsigned brange, BaseUnsigned bucket_size ); template @@ -75,10 +75,10 @@ namespace sprout { { return sprout::throw_recursive_function_template_instantiation_exeeded(); } - template - inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result + template + inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result generate_uniform_int_true_3_1( - sprout::random::random_result const& rnd, T min_value, RangeType range, + EngineResult const& rnd, T min_value, RangeType range, BaseResult bmin, BaseUnsigned brange, BaseUnsigned bucket_size ) { @@ -88,10 +88,10 @@ namespace sprout { sprout::random::detail::subtract()(rnd.result(), bmin) / bucket_size ); } - template - inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result + template + inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result generate_uniform_int_true_3_1( - sprout::random::random_result const&, T, RangeType, + EngineResult const&, T, RangeType, BaseResult, BaseUnsigned, BaseUnsigned ) { @@ -219,15 +219,15 @@ namespace sprout { BaseResult bmin, BaseUnsigned brange, RangeType limit, RangeType result = RangeType(0), RangeType mult = RangeType(1) ); - template - inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result + template + inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result generate_uniform_int_true_2_1_1( - sprout::random::random_result const& rnd, T min_value, RangeType range, + EngineResult const& rnd, T min_value, RangeType range, BaseResult bmin, BaseUnsigned brange, RangeType limit, RangeType result, RangeType mult ) { return mult * RangeType(brange) == range - mult + 1 - ? sprout::random::detail::generate_uniform_int_result{ + ? sprout::random::detail::generate_uniform_int_result{ static_cast( result + static_cast(sprout::random::detail::subtract()(rnd.result(), bmin) * mult) ), @@ -241,10 +241,10 @@ namespace sprout { ) ; } - template - inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result + template + inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result generate_uniform_int_true_2_1_1( - sprout::random::random_result const&, T, RangeType, + EngineResult const&, T, RangeType, BaseResult, BaseUnsigned, RangeType, RangeType, RangeType ) { @@ -313,15 +313,15 @@ namespace sprout { { return sprout::throw_recursive_function_template_instantiation_exeeded(); } - template - inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result + template + inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result generate_uniform_int_true_1_1( - sprout::random::random_result const& rnd, T min_value, BaseResult bmin + EngineResult const& rnd, T min_value, BaseResult bmin ) { typedef T result_type; typedef typename std::make_unsigned::type base_unsigned; - return sprout::random::detail::generate_uniform_int_result{ + return sprout::random::detail::generate_uniform_int_result{ sprout::random::detail::add()( base_unsigned(sprout::random::detail::subtract()(rnd.result(), bmin)), min_value @@ -329,10 +329,10 @@ namespace sprout { rnd.engine() }; } - template - inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result + template + inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result generate_uniform_int_true_1_1( - sprout::random::random_result const&, T, BaseResult + EngineResult const&, T, BaseResult ) { return sprout::throw_recursive_function_template_instantiation_exeeded(); @@ -424,10 +424,10 @@ namespace sprout { template SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result generate_uniform_int(Engine const& eng, T min_value, T max_value, std::true_type); - template - inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result + template + inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result generate_uniform_int_true_3_1( - sprout::random::random_result const& rnd, T min_value, RangeType range, + EngineResult const& rnd, T min_value, RangeType range, BaseResult bmin, BaseUnsigned brange, BaseUnsigned bucket_size ); template @@ -449,10 +449,10 @@ namespace sprout { ) ; } - template - inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result + template + inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result generate_uniform_int_true_3_1( - sprout::random::random_result const& rnd, T min_value, RangeType range, + EngineResult const& rnd, T min_value, RangeType range, BaseResult bmin, BaseUnsigned brange, BaseUnsigned bucket_size ) { @@ -535,15 +535,15 @@ namespace sprout { BaseResult bmin, BaseUnsigned brange, RangeType limit, RangeType result = RangeType(0), RangeType mult = RangeType(1) ); - template - inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result + template + inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result generate_uniform_int_true_2_1_1( - sprout::random::random_result const& rnd, T min_value, RangeType range, + EngineResult const& rnd, T min_value, RangeType range, BaseResult bmin, BaseUnsigned brange, RangeType limit, RangeType result, RangeType mult ) { return mult * RangeType(brange) == range - mult + 1 - ? sprout::random::detail::generate_uniform_int_result{ + ? sprout::random::detail::generate_uniform_int_result{ static_cast( result + static_cast(sprout::random::detail::subtract()(rnd.result(), bmin) * mult) ), @@ -601,15 +601,15 @@ namespace sprout { : (range + 1) / (RangeType(brange) + 1) ); } - template - inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result + template + inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result generate_uniform_int_true_1_1( - sprout::random::random_result const& rnd, T min_value, BaseResult bmin + EngineResult const& rnd, T min_value, BaseResult bmin ) { typedef T result_type; typedef typename std::make_unsigned::type base_unsigned; - return sprout::random::detail::generate_uniform_int_result{ + return sprout::random::detail::generate_uniform_int_result{ sprout::random::detail::add()( base_unsigned(sprout::random::detail::subtract()(rnd.result(), bmin)), min_value @@ -792,7 +792,7 @@ namespace sprout { max_ = parm.b(); } template - SPROUT_CONSTEXPR sprout::random::random_result operator()(Engine const& eng) const { + SPROUT_CONSTEXPR sprout::random::random_result const operator()(Engine const& eng) const { return generate(sprout::random::detail::generate_uniform_int(eng, min_, max_)); } template diff --git a/sprout/random/uniform_real_distribution.hpp b/sprout/random/uniform_real_distribution.hpp index 32443c2c..64e5de82 100644 --- a/sprout/random/uniform_real_distribution.hpp +++ b/sprout/random/uniform_real_distribution.hpp @@ -27,16 +27,16 @@ namespace sprout { }; #ifdef SPROUT_WORKAROUND_NOT_TERMINATE_RECURSIVE_CONSTEXPR_FUNCTION_TEMPLATE - template - SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result + template + SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result generate_uniform_real_false_1( - sprout::random::random_result const& rnd, + EngineResult const& rnd, T min_value, T max_value ); - template - SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result + template + SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result generate_uniform_real_false_1( - sprout::random::random_result const& rnd, + EngineResult const& rnd, T min_value, T max_value ); template @@ -88,10 +88,10 @@ namespace sprout { { return sprout::throw_recursive_function_template_instantiation_exeeded(); } - template - SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result + template + SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result generate_uniform_real_false_1( - sprout::random::random_result const& rnd, + EngineResult const& rnd, T min_value, T max_value ) { @@ -101,25 +101,25 @@ namespace sprout { static_cast(rnd.result() - rnd.engine().min()), static_cast(rnd.engine().max() - rnd.engine().min()) ); } - template - SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result + template + SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result generate_uniform_real_false_1( - sprout::random::random_result const&, + EngineResult const&, T, T ) { return sprout::throw_recursive_function_template_instantiation_exeeded(); } - template - SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result + template + SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result generate_uniform_real_true_1( - sprout::random::random_result const& rnd, + EngineResult const& rnd, T min_value, T max_value ); - template - SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result + template + SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result generate_uniform_real_true_1( - sprout::random::random_result const& rnd, + EngineResult const& rnd, T min_value, T max_value ); template @@ -171,14 +171,14 @@ namespace sprout { { return sprout::throw_recursive_function_template_instantiation_exeeded(); } - template - SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result + template + SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result generate_uniform_real_true_1( - sprout::random::random_result const& rnd, + EngineResult const& rnd, T min_value, T max_value ) { - typedef typename Engine::result_type base_result; + typedef typename EngineResult::result_type base_result; return sprout::random::detail::generate_uniform_real_true_2( rnd.engine(), min_value, max_value, @@ -186,20 +186,20 @@ namespace sprout { static_cast(sprout::random::detail::subtract()(rnd.engine().max(), rnd.engine().min())) + 1 ); } - template - SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result + template + SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result generate_uniform_real_true_1( - sprout::random::random_result const&, + EngineResult const&, T, T ) { return sprout::throw_recursive_function_template_instantiation_exeeded(); } #else - template - SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result + template + SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result generate_uniform_real_false_1( - sprout::random::random_result const& rnd, + EngineResult const& rnd, T min_value, T max_value ); template @@ -231,10 +231,10 @@ namespace sprout { ) ; } - template - SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result + template + SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result generate_uniform_real_false_1( - sprout::random::random_result const& rnd, + EngineResult const& rnd, T min_value, T max_value ) { @@ -244,10 +244,10 @@ namespace sprout { static_cast(rnd.result() - rnd.engine().min()), static_cast(rnd.engine().max() - rnd.engine().min()) ); } - template - SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result + template + SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result generate_uniform_real_true_1( - sprout::random::random_result const& rnd, + EngineResult const& rnd, T min_value, T max_value ); template @@ -279,14 +279,14 @@ namespace sprout { ) ; } - template - SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result + template + SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result generate_uniform_real_true_1( - sprout::random::random_result const& rnd, + EngineResult const& rnd, T min_value, T max_value ) { - typedef typename Engine::result_type base_result; + typedef typename EngineResult::result_type base_result; return sprout::random::detail::generate_uniform_real_true_2( rnd.engine(), min_value, max_value, @@ -446,7 +446,7 @@ namespace sprout { max_ = parm.b(); } template - SPROUT_CONSTEXPR sprout::random::random_result operator()(Engine const& eng) const { + SPROUT_CONSTEXPR sprout::random::random_result const operator()(Engine const& eng) const { return generate(sprout::random::detail::generate_uniform_real(eng, min_, max_)); } template diff --git a/sprout/random/uniform_smallint.hpp b/sprout/random/uniform_smallint.hpp index 252d0b8a..0d920fff 100644 --- a/sprout/random/uniform_smallint.hpp +++ b/sprout/random/uniform_smallint.hpp @@ -89,10 +89,10 @@ namespace sprout { IntType min_; IntType max_; private: - template + template SPROUT_CONSTEXPR sprout::random::random_result generate_true_2( Engine const&, - sprout::random::random_result const& rnd, + EngineResult const& rnd, RangeType range, BaseUnsigned base_range, BaseUnsigned val @@ -111,10 +111,10 @@ namespace sprout { ) ; } - template + template SPROUT_CONSTEXPR sprout::random::random_result generate_true_1( Engine const& eng, - sprout::random::random_result const& rnd, + EngineResult const& rnd, RangeType range, BaseUnsigned base_range ) const @@ -227,7 +227,7 @@ namespace sprout { max_ = parm.b(); } template - SPROUT_CONSTEXPR sprout::random::random_result operator()(Engine const& eng) const { + SPROUT_CONSTEXPR sprout::random::random_result const operator()(Engine const& eng) const { typedef typename Engine::result_type base_result; return generate(eng, typename std::is_integral::type()); } diff --git a/sprout/random/xor_combine.hpp b/sprout/random/xor_combine.hpp index 7a9dd46d..b678474f 100644 --- a/sprout/random/xor_combine.hpp +++ b/sprout/random/xor_combine.hpp @@ -70,7 +70,7 @@ namespace sprout { SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT { return NS_SSCRISK_CEL_OR_SPROUT::max(rng1_.max(), rng2_.max()); } - SPROUT_CONSTEXPR sprout::random::random_result operator()() const { + SPROUT_CONSTEXPR sprout::random::random_result const operator()() const { return generate(rng1_(), rng2_()); } SPROUT_CONSTEXPR base1_type const& base1() const SPROUT_NOEXCEPT {