mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-02-23 10:54:54 +00:00
fix: random generator/distribution result type (add const)
This commit is contained in:
parent
1132d08f23
commit
2c9f0647f4
33 changed files with 342 additions and 123 deletions
|
@ -41,5 +41,30 @@
|
|||
#include <sprout/algorithm/cxx14/partition.hpp>
|
||||
#include <sprout/algorithm/cxx14/stable_partition.hpp>
|
||||
#include <sprout/algorithm/cxx14/partition_copy.hpp>
|
||||
#include <sprout/algorithm/cxx14/sort.hpp>
|
||||
#include <sprout/algorithm/cxx14/stable_sort.hpp>
|
||||
#include <sprout/algorithm/cxx14/partial_sort.hpp>
|
||||
#include <sprout/algorithm/cxx14/partial_sort_copy.hpp>
|
||||
#include <sprout/algorithm/cxx14/nth_element.hpp>
|
||||
//#include <sprout/algorithm/cxx14/merge.hpp>
|
||||
//#include <sprout/algorithm/cxx14/inplace_merge.hpp>
|
||||
//#include <sprout/algorithm/cxx14/set_union.hpp>
|
||||
//#include <sprout/algorithm/cxx14/set_intersection.hpp>
|
||||
//#include <sprout/algorithm/cxx14/set_difference.hpp>
|
||||
//#include <sprout/algorithm/cxx14/set_symmetric_difference.hpp>
|
||||
//#include <sprout/algorithm/cxx14/push_heap.hpp>
|
||||
//#include <sprout/algorithm/cxx14/pop_heap.hpp>
|
||||
//#include <sprout/algorithm/cxx14/make_heap.hpp>
|
||||
//#include <sprout/algorithm/cxx14/sort_heap.hpp>
|
||||
//#include <sprout/algorithm/cxx14/next_permutation.hpp>
|
||||
//#include <sprout/algorithm/cxx14/prev_permutation.hpp>
|
||||
//#include <sprout/algorithm/cxx14/copy_while.hpp>
|
||||
//#include <sprout/algorithm/cxx14/copy_until.hpp>
|
||||
//#include <sprout/algorithm/cxx14/clamp_range.hpp>
|
||||
//#include <sprout/algorithm/cxx14/clamp_range_copy.hpp>
|
||||
//#include <sprout/algorithm/cxx14/bogo_sort.hpp>
|
||||
//#include <sprout/algorithm/cxx14/bogo_sort_result.hpp>
|
||||
//#include <sprout/algorithm/cxx14/bozo_sort.hpp>
|
||||
//#include <sprout/algorithm/cxx14/bozo_sort_result.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_ALGORITHM_CXX14_HPP
|
||||
|
|
27
sprout/algorithm/cxx14/nth_element.hpp
Normal file
27
sprout/algorithm/cxx14/nth_element.hpp
Normal file
|
@ -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 <sprout/config.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// 25.4.2 Nth element
|
||||
//
|
||||
// !!! TOTO: implementation
|
||||
template<typename RandomAccessIterator>
|
||||
inline SPROUT_CXX14_CONSTEXPR void
|
||||
nth_element(RandomAccessIterator first, RandomAccessIterator nth, RandomAccessIterator last);
|
||||
|
||||
template<typename RandomAccessIterator, typename Compare>
|
||||
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
|
27
sprout/algorithm/cxx14/partial_sort.hpp
Normal file
27
sprout/algorithm/cxx14/partial_sort.hpp
Normal file
|
@ -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 <sprout/config.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// 25.4.1.3 partial_sort
|
||||
//
|
||||
// !!! TOTO: implementation
|
||||
template<typename RandomAccessIterator>
|
||||
inline SPROUT_CXX14_CONSTEXPR void
|
||||
partial_sort(RandomAccessIterator first, RandomAccessIterator middle, RandomAccessIterator last);
|
||||
|
||||
template<typename RandomAccessIterator, typename Compare>
|
||||
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
|
27
sprout/algorithm/cxx14/partial_sort_copy.hpp
Normal file
27
sprout/algorithm/cxx14/partial_sort_copy.hpp
Normal file
|
@ -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 <sprout/config.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// 25.4.1.4 partial_sort_copy
|
||||
//
|
||||
// !!! TOTO: implementation
|
||||
template<typename InputIterator, typename RandomAccessIterator>
|
||||
inline SPROUT_CXX14_CONSTEXPR RandomAccessIterator
|
||||
partial_sort_copy(InputIterator first, InputIterator last, RandomAccessIterator result_first, RandomAccessIterator result_last);
|
||||
|
||||
template<typename InputIterator, typename RandomAccessIterator, typename Compare>
|
||||
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
|
|
@ -17,7 +17,16 @@ namespace sprout {
|
|||
//
|
||||
template<typename InputIterator, typename OutputIterator1, typename OutputIterator2, typename Predicate>
|
||||
inline SPROUT_CXX14_CONSTEXPR sprout::pair<OutputIterator1, OutputIterator2>
|
||||
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<OutputIterator1, OutputIterator2>(out_true, out_false);
|
||||
}
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_CXX14_ALGORITHM_PARTITION_COPY_HPP
|
||||
|
|
|
@ -8,7 +8,11 @@
|
|||
#ifndef SPROUT_CXX14_ALGORITHM_SHUFFLE_HPP
|
||||
#define SPROUT_CXX14_ALGORITHM_SHUFFLE_HPP
|
||||
|
||||
#include <iterator>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/iterator/distance.hpp>
|
||||
#include <sprout/algorithm/cxx14/iter_swap.hpp>
|
||||
#include <sprout/workaround/detail/uniform_int_distribution.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
|
@ -16,7 +20,20 @@ namespace sprout {
|
|||
//
|
||||
template<typename RandomAccessIterator, typename UniformRandomNumberGenerator>
|
||||
inline SPROUT_CXX14_CONSTEXPR void
|
||||
shuffle(RandomAccessIterator first, RandomAccessIterator last, UniformRandomNumberGenerator&& g); // !!!
|
||||
shuffle(RandomAccessIterator first, RandomAccessIterator last, UniformRandomNumberGenerator&& g) {
|
||||
typedef typename std::iterator_traits<RandomAccessIterator>::difference_type difference_type;
|
||||
typedef SPROUT_WORKAROUND_DETAIL_UNIFORM_INT_DISTRIBUTION<std::ptrdiff_t> 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
|
||||
|
|
27
sprout/algorithm/cxx14/sort.hpp
Normal file
27
sprout/algorithm/cxx14/sort.hpp
Normal file
|
@ -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 <sprout/config.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// 25.4.1.1 sort
|
||||
//
|
||||
// !!! TOTO: implementation
|
||||
template<typename RandomAccessIterator>
|
||||
inline SPROUT_CXX14_CONSTEXPR void
|
||||
sort(RandomAccessIterator first, RandomAccessIterator last);
|
||||
|
||||
template<typename RandomAccessIterator, typename Compare>
|
||||
inline SPROUT_CXX14_CONSTEXPR void
|
||||
sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_CXX14_ALGORITHM_SORT_HPP
|
|
@ -14,9 +14,10 @@ namespace sprout {
|
|||
//
|
||||
// 25.3.13 Partitions
|
||||
//
|
||||
// !!! TOTO: implementation
|
||||
template<typename BidirectionalIterator, typename Predicate>
|
||||
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
|
||||
|
|
27
sprout/algorithm/cxx14/stable_sort.hpp
Normal file
27
sprout/algorithm/cxx14/stable_sort.hpp
Normal file
|
@ -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 <sprout/config.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// 25.4.1.2 stable_sort
|
||||
//
|
||||
// !!! TOTO: implementation
|
||||
template<typename RandomAccessIterator>
|
||||
inline SPROUT_CXX14_CONSTEXPR void
|
||||
stable_sort(RandomAccessIterator first, RandomAccessIterator last);
|
||||
|
||||
template<typename RandomAccessIterator, typename Compare>
|
||||
inline SPROUT_CXX14_CONSTEXPR void
|
||||
stable_sort(RandomAccessIterator first, RandomAccessIterator last, Compare comp);
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_CXX14_ALGORITHM_STABLE_SORT_HPP
|
|
@ -11,5 +11,6 @@
|
|||
#include <sprout/config.hpp>
|
||||
#include <sprout/algorithm/fixed/nth_element.hpp>
|
||||
#include <sprout/algorithm/fit/nth_element.hpp>
|
||||
#include <sprout/algorithm/cxx14/nth_element.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_ALGORITHM_NTH_ELEMENT_HPP
|
||||
|
|
|
@ -11,5 +11,6 @@
|
|||
#include <sprout/config.hpp>
|
||||
#include <sprout/algorithm/fixed/partial_sort.hpp>
|
||||
#include <sprout/algorithm/fit/partial_sort.hpp>
|
||||
#include <sprout/algorithm/cxx14/partial_sort.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_ALGORITHM_PARTIAL_SORT_HPP
|
||||
|
|
14
sprout/algorithm/partial_sort_copy.hpp
Normal file
14
sprout/algorithm/partial_sort_copy.hpp
Normal file
|
@ -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 <sprout/config.hpp>
|
||||
#include <sprout/algorithm/cxx14/partial_sort_copy.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_ALGORITHM_PARTIAL_SORT_COPY_HPP
|
|
@ -11,5 +11,6 @@
|
|||
#include <sprout/config.hpp>
|
||||
#include <sprout/algorithm/fixed/sort.hpp>
|
||||
#include <sprout/algorithm/fit/sort.hpp>
|
||||
#include <sprout/algorithm/cxx14/sort.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_ALGORITHM_SORT_HPP
|
||||
|
|
|
@ -11,5 +11,6 @@
|
|||
#include <sprout/config.hpp>
|
||||
#include <sprout/algorithm/fixed/stable_sort.hpp>
|
||||
#include <sprout/algorithm/fit/stable_sort.hpp>
|
||||
#include <sprout/algorithm/cxx14/stable_sort.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_ALGORITHM_STABLE_SORT_HPP
|
||||
|
|
|
@ -1023,7 +1023,7 @@ namespace sprout {
|
|||
|
||||
template<typename Char, typename Traits>
|
||||
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) {
|
||||
|
|
|
@ -406,7 +406,7 @@ namespace sprout {
|
|||
position.item->next = nxt;
|
||||
return iterator(nxt);
|
||||
}
|
||||
template <class InputIterator>
|
||||
template<typename InputIterator>
|
||||
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);
|
||||
|
|
16
sprout/numeric/cxx14.hpp
Normal file
16
sprout/numeric/cxx14.hpp
Normal file
|
@ -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 <sprout/config.hpp>
|
||||
//#include <sprout/numeric/cxx14/partial_sum.hpp>
|
||||
//#include <sprout/numeric/cxx14/adjacent_difference.hpp>
|
||||
//#include <sprout/numeric/cxx14/iota.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_CXX14_HPP
|
|
@ -11,5 +11,6 @@
|
|||
#include <sprout/config.hpp>
|
||||
#include <sprout/numeric/fixed.hpp>
|
||||
#include <sprout/numeric/fit.hpp>
|
||||
#include <sprout/numeric/cxx14.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_NUMERIC_MODIFYIING_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<additive_combine_engine> operator()() const {
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<additive_combine_engine> const operator()() const {
|
||||
return generate(mlcg1_(), mlcg2_());
|
||||
}
|
||||
SPROUT_CONSTEXPR base1_type const& base1() const SPROUT_NOEXCEPT {
|
||||
|
|
|
@ -76,9 +76,9 @@ namespace sprout {
|
|||
private:
|
||||
RealType p_;
|
||||
private:
|
||||
template<typename Engine>
|
||||
template<typename Engine, typename EngineResult>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, bernoulli_distribution> generate(
|
||||
sprout::random::random_result<Engine> const& rnd
|
||||
EngineResult const& rnd
|
||||
) const
|
||||
{
|
||||
return sprout::random::random_result<Engine, bernoulli_distribution>(
|
||||
|
@ -113,10 +113,10 @@ namespace sprout {
|
|||
p_ = parm.p();
|
||||
}
|
||||
template<typename Engine>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, bernoulli_distribution> operator()(Engine const& eng) const {
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, bernoulli_distribution> const operator()(Engine const& eng) const {
|
||||
return p_ == RealType(0)
|
||||
? sprout::random::random_result<Engine, bernoulli_distribution>(false, eng, *this)
|
||||
: generate(eng())
|
||||
: generate<Engine>(eng())
|
||||
;
|
||||
}
|
||||
template<typename Elem, typename Traits>
|
||||
|
|
|
@ -649,8 +649,7 @@ namespace sprout {
|
|||
init();
|
||||
}
|
||||
template<typename Engine>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution>
|
||||
operator()(Engine const& eng) const {
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, binomial_distribution> const operator()(Engine const& eng) const {
|
||||
return use_inversion() ? RealType(0.5) < p_
|
||||
? invert2(t_, 1 - p_, eng)
|
||||
: invert(t_, p_, eng)
|
||||
|
|
|
@ -129,7 +129,7 @@ namespace sprout {
|
|||
log_1mp_ = init_log_1mp(p_);
|
||||
}
|
||||
template<typename Engine>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, geometric_distribution> operator()(Engine const& eng) const {
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, geometric_distribution> const operator()(Engine const& eng) const {
|
||||
return generate(eng);
|
||||
}
|
||||
template<typename Elem, typename Traits>
|
||||
|
|
|
@ -79,7 +79,7 @@ namespace sprout {
|
|||
SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT {
|
||||
return static_max();
|
||||
}
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<inversive_congruential_engine> operator()() const {
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<inversive_congruential_engine> const operator()() const {
|
||||
typedef sprout::random::detail::const_mod<IntType, p> do_mod;
|
||||
return generate(do_mod::mult_add(a, do_mod::invert(x_), b));
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ namespace sprout {
|
|||
SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT {
|
||||
return static_max();
|
||||
}
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<linear_congruential_engine> operator()() const {
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<linear_congruential_engine> const operator()() const {
|
||||
return generate(sprout::random::detail::const_mod<UIntType, m>::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<rand48> generate(
|
||||
sprout::random::random_result<lcf_type> const& lcf_result
|
||||
) const
|
||||
{
|
||||
template<typename LcfResult>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<rand48> generate(LcfResult const& lcf_result) const {
|
||||
return sprout::random::random_result<rand48>(
|
||||
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<rand48> operator()() const {
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<rand48> const operator()() const {
|
||||
return generate(lcf_());
|
||||
}
|
||||
friend SPROUT_CONSTEXPR bool operator==(rand48 const& lhs, rand48 const& rhs) {
|
||||
|
|
|
@ -78,7 +78,7 @@ namespace sprout {
|
|||
SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT {
|
||||
return static_max();
|
||||
}
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<linear_feedback_shift_engine> operator()() const {
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<linear_feedback_shift_engine> 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 {
|
||||
|
|
|
@ -386,7 +386,7 @@ namespace sprout {
|
|||
SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT {
|
||||
return static_max();
|
||||
}
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<mersenne_twister_engine> operator()() const {
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<mersenne_twister_engine> const operator()() const {
|
||||
return i_ == n
|
||||
? twist().generate()
|
||||
: generate()
|
||||
|
|
|
@ -206,7 +206,7 @@ namespace sprout {
|
|||
valid_ = false;
|
||||
}
|
||||
template<typename Engine>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, normal_distribution> operator()(Engine const& eng) const {
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, normal_distribution> const operator()(Engine const& eng) const {
|
||||
return generate(eng);
|
||||
}
|
||||
template<typename Elem, typename Traits>
|
||||
|
|
|
@ -144,7 +144,7 @@ namespace sprout {
|
|||
SPROUT_CONSTEXPR result_type max() const SPROUT_NOEXCEPT {
|
||||
return rng_.max();
|
||||
}
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<shuffle_order_engine> operator()() const {
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<shuffle_order_engine> const operator()() const {
|
||||
typedef typename std::make_unsigned<result_type>::type base_unsigned;
|
||||
return generate(
|
||||
base_unsigned(sprout::random::detail::subtract<result_type>()(max(), min())),
|
||||
|
|
|
@ -60,22 +60,22 @@ namespace sprout {
|
|||
};
|
||||
private:
|
||||
#ifdef SPROUT_WORKAROUND_NOT_TERMINATE_RECURSIVE_CONSTEXPR_FUNCTION_TEMPLATE
|
||||
template<int D, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
template<int D, typename Engine, typename EngineResult, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, uniform_01>
|
||||
generate_1(Engine const&, sprout::random::random_result<Engine> 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<Engine, uniform_01>(result, rnd.engine(), *this)
|
||||
: generate<D + 1>(rnd.engine(), rnd.engine()())
|
||||
;
|
||||
}
|
||||
template<int D, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
template<int D, typename Engine, typename EngineResult, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, uniform_01>
|
||||
generate_1(Engine const&, sprout::random::random_result<Engine> const&, result_type) const {
|
||||
generate_1(Engine const&, EngineResult const&, result_type) const {
|
||||
return sprout::throw_recursive_function_template_instantiation_exeeded();
|
||||
}
|
||||
template<int D = 16, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
template<int D = 16, typename Engine, typename EngineResult, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, uniform_01>
|
||||
generate(Engine const& eng, sprout::random::random_result<Engine> const& rnd) const {
|
||||
generate(Engine const& eng, EngineResult const& rnd) const {
|
||||
typedef typename Engine::result_type base_result;
|
||||
return generate_1<D + 1>(
|
||||
eng,
|
||||
|
@ -89,23 +89,23 @@ namespace sprout {
|
|||
)
|
||||
);
|
||||
}
|
||||
template<int D = 16, typename Engine, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
template<int D = 16, typename Engine, typename EngineResult, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, uniform_01>
|
||||
generate(Engine const&, sprout::random::random_result<Engine> const&) const {
|
||||
generate(Engine const&, EngineResult const&) const {
|
||||
return sprout::throw_recursive_function_template_instantiation_exeeded();
|
||||
}
|
||||
#else
|
||||
template<typename Engine>
|
||||
template<typename Engine, typename EngineResult>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, uniform_01>
|
||||
generate_1(Engine const&, sprout::random::random_result<Engine> 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<Engine, uniform_01>(result, rnd.engine(), *this)
|
||||
: generate(rnd.engine(), rnd.engine()())
|
||||
;
|
||||
}
|
||||
template<typename Engine>
|
||||
template<typename Engine, typename EngineResult>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, uniform_01>
|
||||
generate(Engine const& eng, sprout::random::random_result<Engine> 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<typename Engine>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, uniform_01> operator()(Engine const& eng) const {
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, uniform_01> const operator()(Engine const& eng) const {
|
||||
return generate(eng, eng());
|
||||
}
|
||||
template<typename Elem, typename Traits>
|
||||
|
|
|
@ -35,16 +35,16 @@ namespace sprout {
|
|||
template<int D = 16, typename Engine, typename T, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result<T, Engine>
|
||||
generate_uniform_int(Engine const& eng, T min_value, T max_value, std::true_type);
|
||||
template<int D, typename Engine, typename T, typename RangeType, typename BaseResult, typename BaseUnsigned, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result<T, Engine>
|
||||
template<int D, typename EngineResult, typename T, typename RangeType, typename BaseResult, typename BaseUnsigned, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result<T, typename EngineResult::engine_type>
|
||||
generate_uniform_int_true_3_1(
|
||||
sprout::random::random_result<Engine> const& rnd, T min_value, RangeType range,
|
||||
EngineResult const& rnd, T min_value, RangeType range,
|
||||
BaseResult bmin, BaseUnsigned brange, BaseUnsigned bucket_size
|
||||
);
|
||||
template<int D, typename Engine, typename T, typename RangeType, typename BaseResult, typename BaseUnsigned, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result<T, Engine>
|
||||
template<int D, typename EngineResult, typename T, typename RangeType, typename BaseResult, typename BaseUnsigned, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result<T, typename EngineResult::engine_type>
|
||||
generate_uniform_int_true_3_1(
|
||||
sprout::random::random_result<Engine> const& rnd, T min_value, RangeType range,
|
||||
EngineResult const& rnd, T min_value, RangeType range,
|
||||
BaseResult bmin, BaseUnsigned brange, BaseUnsigned bucket_size
|
||||
);
|
||||
template<int D, typename Engine, typename T, typename RangeType, typename BaseResult, typename BaseUnsigned, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
|
@ -75,10 +75,10 @@ namespace sprout {
|
|||
{
|
||||
return sprout::throw_recursive_function_template_instantiation_exeeded();
|
||||
}
|
||||
template<int D, typename Engine, typename T, typename RangeType, typename BaseResult, typename BaseUnsigned, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE_DECL(D)>
|
||||
inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result<T, Engine>
|
||||
template<int D, typename EngineResult, typename T, typename RangeType, typename BaseResult, typename BaseUnsigned, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE_DECL(D)>
|
||||
inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result<T, typename EngineResult::engine_type>
|
||||
generate_uniform_int_true_3_1(
|
||||
sprout::random::random_result<Engine> 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<BaseResult>()(rnd.result(), bmin) / bucket_size
|
||||
);
|
||||
}
|
||||
template<int D, typename Engine, typename T, typename RangeType, typename BaseResult, typename BaseUnsigned, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK_DECL(D)>
|
||||
inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result<T, Engine>
|
||||
template<int D, typename EngineResult, typename T, typename RangeType, typename BaseResult, typename BaseUnsigned, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK_DECL(D)>
|
||||
inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result<T, typename EngineResult::engine_type>
|
||||
generate_uniform_int_true_3_1(
|
||||
sprout::random::random_result<Engine> 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<int D, typename Engine, typename T, typename RangeType, typename BaseResult, typename BaseUnsigned, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result<T, Engine>
|
||||
template<int D, typename EngineResult, typename T, typename RangeType, typename BaseResult, typename BaseUnsigned, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result<T, typename EngineResult::engine_type>
|
||||
generate_uniform_int_true_2_1_1(
|
||||
sprout::random::random_result<Engine> 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<T, Engine>{
|
||||
? sprout::random::detail::generate_uniform_int_result<T, typename EngineResult::engine_type>{
|
||||
static_cast<T>(
|
||||
result + static_cast<RangeType>(sprout::random::detail::subtract<BaseResult>()(rnd.result(), bmin) * mult)
|
||||
),
|
||||
|
@ -241,10 +241,10 @@ namespace sprout {
|
|||
)
|
||||
;
|
||||
}
|
||||
template<int D, typename Engine, typename T, typename RangeType, typename BaseResult, typename BaseUnsigned, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result<T, Engine>
|
||||
template<int D, typename EngineResult, typename T, typename RangeType, typename BaseResult, typename BaseUnsigned, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result<T, typename EngineResult::engine_type>
|
||||
generate_uniform_int_true_2_1_1(
|
||||
sprout::random::random_result<Engine> 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<int D, typename Engine, typename T, typename BaseResult, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result<T, Engine>
|
||||
template<int D, typename EngineResult, typename T, typename BaseResult, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result<T, typename EngineResult::engine_type>
|
||||
generate_uniform_int_true_1_1(
|
||||
sprout::random::random_result<Engine> const& rnd, T min_value, BaseResult bmin
|
||||
EngineResult const& rnd, T min_value, BaseResult bmin
|
||||
)
|
||||
{
|
||||
typedef T result_type;
|
||||
typedef typename std::make_unsigned<BaseResult>::type base_unsigned;
|
||||
return sprout::random::detail::generate_uniform_int_result<T, Engine>{
|
||||
return sprout::random::detail::generate_uniform_int_result<T, typename EngineResult::engine_type>{
|
||||
sprout::random::detail::add<base_unsigned, result_type>()(
|
||||
base_unsigned(sprout::random::detail::subtract<BaseResult>()(rnd.result(), bmin)),
|
||||
min_value
|
||||
|
@ -329,10 +329,10 @@ namespace sprout {
|
|||
rnd.engine()
|
||||
};
|
||||
}
|
||||
template<int D, typename Engine, typename T, typename BaseResult, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result<T, Engine>
|
||||
template<int D, typename EngineResult, typename T, typename BaseResult, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result<T, typename EngineResult::engine_type>
|
||||
generate_uniform_int_true_1_1(
|
||||
sprout::random::random_result<Engine> const&, T, BaseResult
|
||||
EngineResult const&, T, BaseResult
|
||||
)
|
||||
{
|
||||
return sprout::throw_recursive_function_template_instantiation_exeeded();
|
||||
|
@ -424,10 +424,10 @@ namespace sprout {
|
|||
template<typename Engine, typename T>
|
||||
SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result<T, Engine>
|
||||
generate_uniform_int(Engine const& eng, T min_value, T max_value, std::true_type);
|
||||
template<typename Engine, typename T, typename RangeType, typename BaseResult, typename BaseUnsigned>
|
||||
inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result<T, Engine>
|
||||
template<typename EngineResult, typename T, typename RangeType, typename BaseResult, typename BaseUnsigned>
|
||||
inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result<T, typename EngineResult::engine_type>
|
||||
generate_uniform_int_true_3_1(
|
||||
sprout::random::random_result<Engine> const& rnd, T min_value, RangeType range,
|
||||
EngineResult const& rnd, T min_value, RangeType range,
|
||||
BaseResult bmin, BaseUnsigned brange, BaseUnsigned bucket_size
|
||||
);
|
||||
template<typename Engine, typename T, typename RangeType, typename BaseResult, typename BaseUnsigned>
|
||||
|
@ -449,10 +449,10 @@ namespace sprout {
|
|||
)
|
||||
;
|
||||
}
|
||||
template<typename Engine, typename T, typename RangeType, typename BaseResult, typename BaseUnsigned>
|
||||
inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result<T, Engine>
|
||||
template<typename EngineResult, typename T, typename RangeType, typename BaseResult, typename BaseUnsigned>
|
||||
inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result<T, typename EngineResult::engine_type>
|
||||
generate_uniform_int_true_3_1(
|
||||
sprout::random::random_result<Engine> 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<typename Engine, typename T, typename RangeType, typename BaseResult, typename BaseUnsigned>
|
||||
inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result<T, Engine>
|
||||
template<typename EngineResult, typename T, typename RangeType, typename BaseResult, typename BaseUnsigned>
|
||||
inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result<T, typename EngineResult::engine_type>
|
||||
generate_uniform_int_true_2_1_1(
|
||||
sprout::random::random_result<Engine> 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<T, Engine>{
|
||||
? sprout::random::detail::generate_uniform_int_result<T, typename EngineResult::engine_type>{
|
||||
static_cast<T>(
|
||||
result + static_cast<RangeType>(sprout::random::detail::subtract<BaseResult>()(rnd.result(), bmin) * mult)
|
||||
),
|
||||
|
@ -601,15 +601,15 @@ namespace sprout {
|
|||
: (range + 1) / (RangeType(brange) + 1)
|
||||
);
|
||||
}
|
||||
template<typename Engine, typename T, typename BaseResult>
|
||||
inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result<T, Engine>
|
||||
template<typename EngineResult, typename T, typename BaseResult>
|
||||
inline SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_int_result<T, typename EngineResult::engine_type>
|
||||
generate_uniform_int_true_1_1(
|
||||
sprout::random::random_result<Engine> const& rnd, T min_value, BaseResult bmin
|
||||
EngineResult const& rnd, T min_value, BaseResult bmin
|
||||
)
|
||||
{
|
||||
typedef T result_type;
|
||||
typedef typename std::make_unsigned<BaseResult>::type base_unsigned;
|
||||
return sprout::random::detail::generate_uniform_int_result<T, Engine>{
|
||||
return sprout::random::detail::generate_uniform_int_result<T, typename EngineResult::engine_type>{
|
||||
sprout::random::detail::add<base_unsigned, result_type>()(
|
||||
base_unsigned(sprout::random::detail::subtract<BaseResult>()(rnd.result(), bmin)),
|
||||
min_value
|
||||
|
@ -792,7 +792,7 @@ namespace sprout {
|
|||
max_ = parm.b();
|
||||
}
|
||||
template<typename Engine>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, uniform_int_distribution> operator()(Engine const& eng) const {
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, uniform_int_distribution> const operator()(Engine const& eng) const {
|
||||
return generate<Engine>(sprout::random::detail::generate_uniform_int(eng, min_, max_));
|
||||
}
|
||||
template<typename Elem, typename Traits>
|
||||
|
|
|
@ -27,16 +27,16 @@ namespace sprout {
|
|||
};
|
||||
|
||||
#ifdef SPROUT_WORKAROUND_NOT_TERMINATE_RECURSIVE_CONSTEXPR_FUNCTION_TEMPLATE
|
||||
template<int D = 16, typename Engine, typename T, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result<T, Engine>
|
||||
template<int D = 16, typename EngineResult, typename T, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result<T, typename EngineResult::engine_type>
|
||||
generate_uniform_real_false_1(
|
||||
sprout::random::random_result<Engine> const& rnd,
|
||||
EngineResult const& rnd,
|
||||
T min_value, T max_value
|
||||
);
|
||||
template<int D = 16, typename Engine, typename T, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result<T, Engine>
|
||||
template<int D = 16, typename EngineResult, typename T, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result<T, typename EngineResult::engine_type>
|
||||
generate_uniform_real_false_1(
|
||||
sprout::random::random_result<Engine> const& rnd,
|
||||
EngineResult const& rnd,
|
||||
T min_value, T max_value
|
||||
);
|
||||
template<int D, typename Engine, typename T, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
|
@ -88,10 +88,10 @@ namespace sprout {
|
|||
{
|
||||
return sprout::throw_recursive_function_template_instantiation_exeeded();
|
||||
}
|
||||
template<int D, typename Engine, typename T, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE_DECL(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result<T, Engine>
|
||||
template<int D, typename EngineResult, typename T, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE_DECL(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result<T, typename EngineResult::engine_type>
|
||||
generate_uniform_real_false_1(
|
||||
sprout::random::random_result<Engine> const& rnd,
|
||||
EngineResult const& rnd,
|
||||
T min_value, T max_value
|
||||
)
|
||||
{
|
||||
|
@ -101,25 +101,25 @@ namespace sprout {
|
|||
static_cast<T>(rnd.result() - rnd.engine().min()), static_cast<T>(rnd.engine().max() - rnd.engine().min())
|
||||
);
|
||||
}
|
||||
template<int D, typename Engine, typename T, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK_DECL(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result<T, Engine>
|
||||
template<int D, typename EngineResult, typename T, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK_DECL(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result<T, typename EngineResult::engine_type>
|
||||
generate_uniform_real_false_1(
|
||||
sprout::random::random_result<Engine> const&,
|
||||
EngineResult const&,
|
||||
T, T
|
||||
)
|
||||
{
|
||||
return sprout::throw_recursive_function_template_instantiation_exeeded();
|
||||
}
|
||||
template<int D = 16, typename Engine, typename T, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result<T, Engine>
|
||||
template<int D = 16, typename EngineResult, typename T, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result<T, typename EngineResult::engine_type>
|
||||
generate_uniform_real_true_1(
|
||||
sprout::random::random_result<Engine> const& rnd,
|
||||
EngineResult const& rnd,
|
||||
T min_value, T max_value
|
||||
);
|
||||
template<int D = 16, typename Engine, typename T, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result<T, Engine>
|
||||
template<int D = 16, typename EngineResult, typename T, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result<T, typename EngineResult::engine_type>
|
||||
generate_uniform_real_true_1(
|
||||
sprout::random::random_result<Engine> const& rnd,
|
||||
EngineResult const& rnd,
|
||||
T min_value, T max_value
|
||||
);
|
||||
template<int D, typename Engine, typename T, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE(D)>
|
||||
|
@ -171,14 +171,14 @@ namespace sprout {
|
|||
{
|
||||
return sprout::throw_recursive_function_template_instantiation_exeeded();
|
||||
}
|
||||
template<int D, typename Engine, typename T, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE_DECL(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result<T, Engine>
|
||||
template<int D, typename EngineResult, typename T, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_CONTINUE_DECL(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result<T, typename EngineResult::engine_type>
|
||||
generate_uniform_real_true_1(
|
||||
sprout::random::random_result<Engine> 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<D + 1>(
|
||||
rnd.engine(),
|
||||
min_value, max_value,
|
||||
|
@ -186,20 +186,20 @@ namespace sprout {
|
|||
static_cast<T>(sprout::random::detail::subtract<base_result>()(rnd.engine().max(), rnd.engine().min())) + 1
|
||||
);
|
||||
}
|
||||
template<int D, typename Engine, typename T, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK_DECL(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result<T, Engine>
|
||||
template<int D, typename EngineResult, typename T, SPROUT_RECURSIVE_FUNCTION_TEMPLATE_BREAK_DECL(D)>
|
||||
SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result<T, typename EngineResult::engine_type>
|
||||
generate_uniform_real_true_1(
|
||||
sprout::random::random_result<Engine> const&,
|
||||
EngineResult const&,
|
||||
T, T
|
||||
)
|
||||
{
|
||||
return sprout::throw_recursive_function_template_instantiation_exeeded();
|
||||
}
|
||||
#else
|
||||
template<typename Engine, typename T>
|
||||
SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result<T, Engine>
|
||||
template<typename EngineResult, typename T>
|
||||
SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result<T, typename EngineResult::engine_type>
|
||||
generate_uniform_real_false_1(
|
||||
sprout::random::random_result<Engine> const& rnd,
|
||||
EngineResult const& rnd,
|
||||
T min_value, T max_value
|
||||
);
|
||||
template<typename Engine, typename T>
|
||||
|
@ -231,10 +231,10 @@ namespace sprout {
|
|||
)
|
||||
;
|
||||
}
|
||||
template<typename Engine, typename T>
|
||||
SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result<T, Engine>
|
||||
template<typename EngineResult, typename T>
|
||||
SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result<T, typename EngineResult::engine_type>
|
||||
generate_uniform_real_false_1(
|
||||
sprout::random::random_result<Engine> const& rnd,
|
||||
EngineResult const& rnd,
|
||||
T min_value, T max_value
|
||||
)
|
||||
{
|
||||
|
@ -244,10 +244,10 @@ namespace sprout {
|
|||
static_cast<T>(rnd.result() - rnd.engine().min()), static_cast<T>(rnd.engine().max() - rnd.engine().min())
|
||||
);
|
||||
}
|
||||
template<typename Engine, typename T>
|
||||
SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result<T, Engine>
|
||||
template<typename EngineResult, typename T>
|
||||
SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result<T, typename EngineResult::engine_type>
|
||||
generate_uniform_real_true_1(
|
||||
sprout::random::random_result<Engine> const& rnd,
|
||||
EngineResult const& rnd,
|
||||
T min_value, T max_value
|
||||
);
|
||||
template<typename Engine, typename T>
|
||||
|
@ -279,14 +279,14 @@ namespace sprout {
|
|||
)
|
||||
;
|
||||
}
|
||||
template<typename Engine, typename T>
|
||||
SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result<T, Engine>
|
||||
template<typename EngineResult, typename T>
|
||||
SPROUT_CONSTEXPR sprout::random::detail::generate_uniform_real_result<T, typename EngineResult::engine_type>
|
||||
generate_uniform_real_true_1(
|
||||
sprout::random::random_result<Engine> 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<typename Engine>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, uniform_real_distribution> operator()(Engine const& eng) const {
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, uniform_real_distribution> const operator()(Engine const& eng) const {
|
||||
return generate<Engine>(sprout::random::detail::generate_uniform_real(eng, min_, max_));
|
||||
}
|
||||
template<typename Elem, typename Traits>
|
||||
|
|
|
@ -89,10 +89,10 @@ namespace sprout {
|
|||
IntType min_;
|
||||
IntType max_;
|
||||
private:
|
||||
template<typename Engine, typename RangeType, typename BaseUnsigned>
|
||||
template<typename Engine, typename EngineResult, typename RangeType, typename BaseUnsigned>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, uniform_smallint> generate_true_2(
|
||||
Engine const&,
|
||||
sprout::random::random_result<Engine> const& rnd,
|
||||
EngineResult const& rnd,
|
||||
RangeType range,
|
||||
BaseUnsigned base_range,
|
||||
BaseUnsigned val
|
||||
|
@ -111,10 +111,10 @@ namespace sprout {
|
|||
)
|
||||
;
|
||||
}
|
||||
template<typename Engine, typename RangeType, typename BaseUnsigned>
|
||||
template<typename Engine, typename EngineResult, typename RangeType, typename BaseUnsigned>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, uniform_smallint> generate_true_1(
|
||||
Engine const& eng,
|
||||
sprout::random::random_result<Engine> const& rnd,
|
||||
EngineResult const& rnd,
|
||||
RangeType range,
|
||||
BaseUnsigned base_range
|
||||
) const
|
||||
|
@ -227,7 +227,7 @@ namespace sprout {
|
|||
max_ = parm.b();
|
||||
}
|
||||
template<typename Engine>
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, uniform_smallint> operator()(Engine const& eng) const {
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<Engine, uniform_smallint> const operator()(Engine const& eng) const {
|
||||
typedef typename Engine::result_type base_result;
|
||||
return generate(eng, typename std::is_integral<base_result>::type());
|
||||
}
|
||||
|
|
|
@ -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<xor_combine_engine> operator()() const {
|
||||
SPROUT_CONSTEXPR sprout::random::random_result<xor_combine_engine> const operator()() const {
|
||||
return generate(rng1_(), rng2_());
|
||||
}
|
||||
SPROUT_CONSTEXPR base1_type const& base1() const SPROUT_NOEXCEPT {
|
||||
|
|
Loading…
Add table
Reference in a new issue