Skip to content

Commit ddcd361

Browse files
authored
Merge pull request #127 from boostorg/remove_array
Remove Heavy Dependencies
2 parents 4a4cdfe + efb6d03 commit ddcd361

9 files changed

+139
-117
lines changed

CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@ target_include_directories(boost_random PUBLIC include)
1717

1818
target_link_libraries(boost_random
1919
PUBLIC
20-
Boost::array
2120
Boost::assert
2221
Boost::config
2322
Boost::core
2423
Boost::dynamic_bitset
2524
Boost::integer
2625
Boost::io
27-
Boost::range
2826
Boost::static_assert
2927
Boost::system
3028
Boost::throw_exception
@@ -51,4 +49,3 @@ if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt")
5149
add_subdirectory(test)
5250

5351
endif()
54-

build.jam

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
require-b2 5.2 ;
77

88
constant boost_dependencies :
9-
/boost/array//boost_array
109
/boost/assert//boost_assert
1110
/boost/config//boost_config
1211
/boost/core//boost_core
1312
/boost/dynamic_bitset//boost_dynamic_bitset
1413
/boost/integer//boost_integer
1514
/boost/io//boost_io
16-
/boost/range//boost_range
1715
/boost/static_assert//boost_static_assert
1816
/boost/system//boost_system
1917
/boost/throw_exception//boost_throw_exception
@@ -33,4 +31,3 @@ explicit
3331
call-if : boost-library random
3432
: install boost_random
3533
;
36-
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright Matt Borland 2025.
3+
* Distributed under the Boost Software License, Version 1.0. (See
4+
* accompanying file LICENSE_1_0.txt or copy at
5+
* http://www.boost.org/LICENSE_1_0.txt)
6+
*
7+
* See http://www.boost.org for most recent version including documentation.
8+
*
9+
* $Id$
10+
*/
11+
12+
#include <iterator>
13+
#include <cstddef>
14+
15+
namespace boost {
16+
namespace random {
17+
namespace detail {
18+
19+
#if defined (__cpp_lib_nonmember_container_access) && __cpp_lib_nonmember_container_access >= 201411L
20+
21+
using std::size;
22+
23+
#else
24+
25+
template <typename C>
26+
constexpr auto size(const C& c) -> decltype(c.size())
27+
{
28+
return c.size();
29+
}
30+
31+
template <typename T, std::size_t N>
32+
constexpr std::size_t size(const T (&array)[N]) noexcept
33+
{
34+
return N;
35+
}
36+
37+
#endif
38+
39+
} // namespace detail
40+
} // namespace random
41+
} // namespace boost

include/boost/random/discrete_distribution.hpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@
2929
#include <initializer_list>
3030
#endif
3131

32-
#include <boost/range/begin.hpp>
33-
#include <boost/range/end.hpp>
34-
3532
#include <boost/random/detail/disable_warnings.hpp>
3633

3734
namespace boost {
@@ -268,7 +265,7 @@ class discrete_distribution {
268265
*/
269266
template<class Range>
270267
explicit param_type(const Range& range)
271-
: _probabilities(boost::begin(range), boost::end(range))
268+
: _probabilities(std::begin(range), std::end(range))
272269
{
273270
normalize();
274271
}
@@ -308,7 +305,7 @@ class discrete_distribution {
308305
detail::print_vector(os, parm._probabilities);
309306
return os;
310307
}
311-
308+
312309
/** Reads the parameters from a @c std::istream. */
313310
BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, param_type, parm)
314311
{
@@ -389,7 +386,7 @@ class discrete_distribution {
389386
template<class Range>
390387
explicit discrete_distribution(const Range& range)
391388
{
392-
init(boost::begin(range), boost::end(range));
389+
init(std::begin(range), std::end(range));
393390
}
394391
/**
395392
* Constructs a discrete_distribution that approximates a function.
@@ -440,7 +437,7 @@ class discrete_distribution {
440437
return(_impl._alias_table[static_cast<std::size_t>(result)].second);
441438
}
442439
}
443-
440+
444441
/**
445442
* Returns a value distributed according to the parameters
446443
* specified by param.
@@ -472,7 +469,7 @@ class discrete_distribution {
472469
return discrete_distribution(parm)(urng);
473470
}
474471
}
475-
472+
476473
/** Returns the smallest value that the distribution can produce. */
477474
result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return 0; }
478475
/** Returns the largest value that the distribution can produce. */
@@ -520,7 +517,7 @@ class discrete_distribution {
520517
{
521518
init(parm._probabilities.begin(), parm._probabilities.end());
522519
}
523-
520+
524521
/**
525522
* Effects: Subsequent uses of the distribution do not depend
526523
* on values produced by any engine prior to invoking reset.
@@ -576,7 +573,7 @@ class discrete_distribution {
576573
std::vector<std::pair<WeightType, IntType> > above_average;
577574
below_average.reserve(input_size);
578575
above_average.reserve(input_size);
579-
576+
580577
WeightType weight_average = _impl.init_average(first, last);
581578
WeightType normalized_average = _impl.get_weight(0);
582579
std::size_t i = 0;

include/boost/random/hyperexponential_distribution.hpp

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@
2323
#include <boost/core/cmath.hpp>
2424
#include <boost/random/detail/operators.hpp>
2525
#include <boost/random/detail/vector_io.hpp>
26+
#include <boost/random/detail/size.hpp>
2627
#include <boost/random/discrete_distribution.hpp>
2728
#include <boost/random/exponential_distribution.hpp>
28-
#include <boost/range/begin.hpp>
29-
#include <boost/range/end.hpp>
30-
#include <boost/range/size.hpp>
3129
#include <boost/type_traits/has_pre_increment.hpp>
3230
#include <cmath>
3331
#include <cstddef>
@@ -294,8 +292,8 @@ class hyperexponential_distribution
294292
param_type(ProbRangeT const& prob_range,
295293
RateRangeT const& rate_range,
296294
typename boost::disable_if_c<boost::has_pre_increment<ProbRangeT>::value || boost::has_pre_increment<RateRangeT>::value>::type* = 0)
297-
: probs_(boost::begin(prob_range), boost::end(prob_range)),
298-
rates_(boost::begin(rate_range), boost::end(rate_range))
295+
: probs_(std::begin(prob_range), std::end(prob_range)),
296+
rates_(std::begin(rate_range), std::end(rate_range))
299297
{
300298
hyperexp_detail::normalize(probs_);
301299

@@ -330,8 +328,8 @@ class hyperexponential_distribution
330328
// We SFINAE this out of existance if the argument type is
331329
// incrementable as in that case the type is probably an iterator.
332330
public: template <typename RateIterT>
333-
param_type(RateIterT rate_first,
334-
RateIterT rate_last,
331+
param_type(RateIterT rate_first,
332+
RateIterT rate_last,
335333
typename boost::enable_if_c<boost::has_pre_increment<RateIterT>::value>::type* = 0)
336334
: probs_(std::distance(rate_first, rate_last), 1), // will be normalized below
337335
rates_(rate_first, rate_last)
@@ -355,8 +353,8 @@ class hyperexponential_distribution
355353
*/
356354
public: template <typename RateRangeT>
357355
param_type(RateRangeT const& rate_range)
358-
: probs_(boost::size(rate_range), 1), // Will be normalized below
359-
rates_(boost::begin(rate_range), boost::end(rate_range))
356+
: probs_(boost::random::detail::size(rate_range), 1), // Will be normalized below
357+
rates_(std::begin(rate_range), std::end(rate_range))
360358
{
361359
hyperexp_detail::normalize(probs_);
362360

@@ -529,7 +527,7 @@ class hyperexponential_distribution
529527
return lhs.probs_ == rhs.probs_
530528
&& lhs.rates_ == rhs.rates_;
531529
}
532-
530+
533531
/** Returns true if the two sets of parameters are the different. */
534532
public: BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(param_type)
535533

@@ -608,7 +606,7 @@ class hyperexponential_distribution
608606
RateRangeT const& rate_range,
609607
typename boost::disable_if_c<boost::has_pre_increment<ProbRangeT>::value || boost::has_pre_increment<RateRangeT>::value>::type* = 0)
610608
: dd_(prob_range),
611-
rates_(boost::begin(rate_range), boost::end(rate_range))
609+
rates_(std::begin(rate_range), std::end(rate_range))
612610
{
613611
BOOST_ASSERT( hyperexp_detail::check_params(dd_.probabilities(), rates_) );
614612
}
@@ -667,8 +665,8 @@ class hyperexponential_distribution
667665
*/
668666
public: template <typename RateRangeT>
669667
hyperexponential_distribution(RateRangeT const& rate_range)
670-
: dd_(std::vector<RealT>(boost::size(rate_range), 1)),
671-
rates_(boost::begin(rate_range), boost::end(rate_range))
668+
: dd_(std::vector<RealT>(boost::random::detail::size(rate_range), 1)),
669+
rates_(std::begin(rate_range), std::end(rate_range))
672670
{
673671
BOOST_ASSERT( hyperexp_detail::check_params(dd_.probabilities(), rates_) );
674672
}
@@ -854,7 +852,7 @@ class hyperexponential_distribution
854852
return lhs.dd_ == rhs.dd_
855853
&& lhs.rates_ == rhs.rates_;
856854
}
857-
855+
858856
/**
859857
* Returns true if the two instances of @c hyperexponential_distribution will
860858
* return different sequences of values given equal generators.

0 commit comments

Comments
 (0)