2
0
mirror of https://github.com/boostorg/random.git synced 2026-01-19 04:22:17 +00:00

Remove boost.range dependency

This commit is contained in:
Matt Borland
2025-02-03 10:56:12 -05:00
parent 534b10981e
commit e9dbb6d160
7 changed files with 34 additions and 54 deletions

View File

@@ -17,14 +17,12 @@ target_include_directories(boost_random PUBLIC include)
target_link_libraries(boost_random
PUBLIC
Boost::array
Boost::assert
Boost::config
Boost::core
Boost::dynamic_bitset
Boost::integer
Boost::io
Boost::range
Boost::static_assert
Boost::system
Boost::throw_exception
@@ -51,4 +49,3 @@ if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
add_subdirectory(test)
endif()

View File

@@ -6,14 +6,12 @@
require-b2 5.2 ;
constant boost_dependencies :
/boost/array//boost_array
/boost/assert//boost_assert
/boost/config//boost_config
/boost/core//boost_core
/boost/dynamic_bitset//boost_dynamic_bitset
/boost/integer//boost_integer
/boost/io//boost_io
/boost/range//boost_range
/boost/static_assert//boost_static_assert
/boost/system//boost_system
/boost/throw_exception//boost_throw_exception
@@ -33,4 +31,3 @@ explicit
call-if : boost-library random
: install boost_random
;

View File

@@ -29,9 +29,6 @@
#include <initializer_list>
#endif
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/random/detail/disable_warnings.hpp>
namespace boost {
@@ -268,7 +265,7 @@ public:
*/
template<class Range>
explicit param_type(const Range& range)
: _probabilities(boost::begin(range), boost::end(range))
: _probabilities(std::begin(range), std::end(range))
{
normalize();
}
@@ -308,7 +305,7 @@ public:
detail::print_vector(os, parm._probabilities);
return os;
}
/** Reads the parameters from a @c std::istream. */
BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, param_type, parm)
{
@@ -389,7 +386,7 @@ public:
template<class Range>
explicit discrete_distribution(const Range& range)
{
init(boost::begin(range), boost::end(range));
init(std::begin(range), std::end(range));
}
/**
* Constructs a discrete_distribution that approximates a function.
@@ -440,7 +437,7 @@ public:
return(_impl._alias_table[static_cast<std::size_t>(result)].second);
}
}
/**
* Returns a value distributed according to the parameters
* specified by param.
@@ -472,7 +469,7 @@ public:
return discrete_distribution(parm)(urng);
}
}
/** Returns the smallest value that the distribution can produce. */
result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return 0; }
/** Returns the largest value that the distribution can produce. */
@@ -520,7 +517,7 @@ public:
{
init(parm._probabilities.begin(), parm._probabilities.end());
}
/**
* Effects: Subsequent uses of the distribution do not depend
* on values produced by any engine prior to invoking reset.
@@ -576,7 +573,7 @@ private:
std::vector<std::pair<WeightType, IntType> > above_average;
below_average.reserve(input_size);
above_average.reserve(input_size);
WeightType weight_average = _impl.init_average(first, last);
WeightType normalized_average = _impl.get_weight(0);
std::size_t i = 0;

View File

@@ -25,9 +25,6 @@
#include <boost/random/detail/vector_io.hpp>
#include <boost/random/discrete_distribution.hpp>
#include <boost/random/exponential_distribution.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <boost/range/size.hpp>
#include <boost/type_traits/has_pre_increment.hpp>
#include <cmath>
#include <cstddef>
@@ -294,8 +291,8 @@ class hyperexponential_distribution
param_type(ProbRangeT const& prob_range,
RateRangeT const& rate_range,
typename boost::disable_if_c<boost::has_pre_increment<ProbRangeT>::value || boost::has_pre_increment<RateRangeT>::value>::type* = 0)
: probs_(boost::begin(prob_range), boost::end(prob_range)),
rates_(boost::begin(rate_range), boost::end(rate_range))
: probs_(std::begin(prob_range), std::end(prob_range)),
rates_(std::begin(rate_range), std::end(rate_range))
{
hyperexp_detail::normalize(probs_);
@@ -330,8 +327,8 @@ class hyperexponential_distribution
// We SFINAE this out of existance if the argument type is
// incrementable as in that case the type is probably an iterator.
public: template <typename RateIterT>
param_type(RateIterT rate_first,
RateIterT rate_last,
param_type(RateIterT rate_first,
RateIterT rate_last,
typename boost::enable_if_c<boost::has_pre_increment<RateIterT>::value>::type* = 0)
: probs_(std::distance(rate_first, rate_last), 1), // will be normalized below
rates_(rate_first, rate_last)
@@ -355,8 +352,8 @@ class hyperexponential_distribution
*/
public: template <typename RateRangeT>
param_type(RateRangeT const& rate_range)
: probs_(boost::size(rate_range), 1), // Will be normalized below
rates_(boost::begin(rate_range), boost::end(rate_range))
: probs_(std::size(rate_range), 1), // Will be normalized below
rates_(std::begin(rate_range), std::end(rate_range))
{
hyperexp_detail::normalize(probs_);
@@ -529,7 +526,7 @@ class hyperexponential_distribution
return lhs.probs_ == rhs.probs_
&& lhs.rates_ == rhs.rates_;
}
/** Returns true if the two sets of parameters are the different. */
public: BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(param_type)
@@ -608,7 +605,7 @@ class hyperexponential_distribution
RateRangeT const& rate_range,
typename boost::disable_if_c<boost::has_pre_increment<ProbRangeT>::value || boost::has_pre_increment<RateRangeT>::value>::type* = 0)
: dd_(prob_range),
rates_(boost::begin(rate_range), boost::end(rate_range))
rates_(std::begin(rate_range), std::end(rate_range))
{
BOOST_ASSERT( hyperexp_detail::check_params(dd_.probabilities(), rates_) );
}
@@ -667,8 +664,8 @@ class hyperexponential_distribution
*/
public: template <typename RateRangeT>
hyperexponential_distribution(RateRangeT const& rate_range)
: dd_(std::vector<RealT>(boost::size(rate_range), 1)),
rates_(boost::begin(rate_range), boost::end(rate_range))
: dd_(std::vector<RealT>(std::size(rate_range), 1)),
rates_(std::begin(rate_range), std::end(rate_range))
{
BOOST_ASSERT( hyperexp_detail::check_params(dd_.probabilities(), rates_) );
}
@@ -854,7 +851,7 @@ class hyperexponential_distribution
return lhs.dd_ == rhs.dd_
&& lhs.rates_ == rhs.rates_;
}
/**
* Returns true if the two instances of @c hyperexponential_distribution will
* return different sequences of values given equal generators.

View File

@@ -26,9 +26,6 @@
#include <initializer_list>
#endif
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
namespace boost {
namespace random {
@@ -127,8 +124,8 @@ public:
template<class IntervalRange, class WeightRange>
param_type(const IntervalRange& intervals_arg,
const WeightRange& weights_arg)
: _intervals(boost::begin(intervals_arg), boost::end(intervals_arg)),
_weights(boost::begin(weights_arg), boost::end(weights_arg))
: _intervals(std::begin(intervals_arg), std::end(intervals_arg)),
_weights(std::begin(weights_arg), std::end(weights_arg))
{
if(_intervals.size() < 2) {
_intervals.clear();
@@ -185,7 +182,7 @@ public:
detail::print_vector(os, parm._weights);
return os;
}
/** Reads the parameters from a @c std::istream. */
BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, param_type, parm)
{
@@ -318,7 +315,7 @@ public:
piecewise_constant_distribution(const IntervalsRange& intervals_arg,
const WeightsRange& weights_arg)
: _bins(weights_arg),
_intervals(boost::begin(intervals_arg), boost::end(intervals_arg))
_intervals(std::begin(intervals_arg), std::end(intervals_arg))
{
if(_intervals.size() < 2) {
_intervals.clear();
@@ -367,7 +364,7 @@ public:
std::size_t i = _bins(urng);
return uniform_real<RealType>(_intervals[i], _intervals[i+1])(urng);
}
/**
* Returns a value distributed according to the parameters
* specified by param.
@@ -377,7 +374,7 @@ public:
{
return piecewise_constant_distribution(parm)(urng);
}
/** Returns the smallest value that the distribution can produce. */
result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const
{ return _intervals.front(); }
@@ -414,7 +411,7 @@ public:
_bins.param(bins_param);
_intervals.swap(new_intervals);
}
/**
* Effects: Subsequent uses of the distribution do not depend
* on values produced by any engine prior to invoking reset.

View File

@@ -28,9 +28,6 @@
#include <initializer_list>
#endif
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
namespace boost {
namespace random {
@@ -134,8 +131,8 @@ public:
template<class IntervalRange, class WeightRange>
param_type(const IntervalRange& intervals_arg,
const WeightRange& weights_arg)
: _intervals(boost::begin(intervals_arg), boost::end(intervals_arg)),
_weights(boost::begin(weights_arg), boost::end(weights_arg))
: _intervals(std::begin(intervals_arg), std::end(intervals_arg)),
_weights(std::begin(weights_arg), std::end(weights_arg))
{
if(_intervals.size() < 2) {
_weights.clear();
@@ -200,7 +197,7 @@ public:
detail::print_vector(os, parm._weights);
return os;
}
/** Reads the parameters from a @c std::istream. */
BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, param_type, parm)
{
@@ -321,8 +318,8 @@ public:
template<class IntervalsRange, class WeightsRange>
piecewise_linear_distribution(const IntervalsRange& intervals_arg,
const WeightsRange& weights_arg)
: _intervals(boost::begin(intervals_arg), boost::end(intervals_arg)),
_weights(boost::begin(weights_arg), boost::end(weights_arg))
: _intervals(std::begin(intervals_arg), std::end(intervals_arg)),
_weights(std::begin(weights_arg), std::end(weights_arg))
{
if(_intervals.size() < 2) {
default_init();
@@ -383,7 +380,7 @@ public:
return (std::min)(dist(urng), dist(urng));
}
}
/**
* Returns a value distributed according to the parameters
* specified by param.
@@ -393,7 +390,7 @@ public:
{
return piecewise_linear_distribution(parm)(urng);
}
/** Returns the smallest value that the distribution can produce. */
result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const
{ return _intervals.front(); }
@@ -439,7 +436,7 @@ public:
_intervals.swap(new_intervals);
_weights.swap(new_weights);
}
/**
* Effects: Subsequent uses of the distribution do not depend
* on values produced by any engine prior to invoking reset.

View File

@@ -16,8 +16,6 @@
#include <boost/config.hpp>
#include <boost/cstdint.hpp>
#include <boost/range/begin.hpp>
#include <boost/range/end.hpp>
#include <cstddef>
#include <vector>
#include <algorithm>
@@ -53,7 +51,7 @@ public:
/** Initializes the sequence from Boost.Range range. */
template<class Range>
explicit seed_seq(const Range& range)
: v(boost::begin(range), boost::end(range)) {}
: v(std::begin(range), std::end(range)) {}
/**
* Fills a range with 32-bit values based on the stored sequence.