Skip to content

Commit 7a278d9

Browse files
Remove dependency on Boost.random.
Boost.iostreams now requires C++11, so normally a <random> implementation shall exists in the compiling toolchain, so use this instead of the Boost implementation. This allows to no longer depend explicitly on libboost_random.so, which is now the case with the recent modular works (see other case of these extra dependencies being added with modular changes in boostorg/regex#253 or boostorg/system#132)
1 parent 8561bdb commit 7a278d9

File tree

2 files changed

+7
-22
lines changed

2 files changed

+7
-22
lines changed

build.jam

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ constant boost_dependencies :
1818
/boost/mpl//boost_mpl
1919
/boost/numeric_conversion//boost_numeric_conversion
2020
/boost/preprocessor//boost_preprocessor
21-
/boost/random//boost_random
2221
/boost/range//boost_range
2322
/boost/regex//boost_regex
2423
/boost/smart_ptr//boost_smart_ptr

include/boost/iostreams/filter/test.hpp

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,7 @@
2424
#include <iterator>
2525
#include <string>
2626
#include <vector>
27-
#if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) && \
28-
!BOOST_WORKAROUND(__MWERKS__, <= 0x3003) \
29-
/**/
30-
# include <boost/random/linear_congruential.hpp>
31-
# include <boost/random/uniform_smallint.hpp>
32-
#endif
27+
#include <random>
3328
#include <boost/iostreams/categories.hpp>
3429
#include <boost/iostreams/compose.hpp>
3530
#include <boost/iostreams/copy.hpp>
@@ -64,21 +59,12 @@ BOOST_IOSTREAMS_BOOL_TRAIT_DEF(is_string, std::basic_string, 3)
6459

6560
const std::streamsize default_increment = 5;
6661

67-
#if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) && \
68-
!BOOST_WORKAROUND(__MWERKS__, <= 0x3003) \
69-
/**/
70-
std::streamsize rand(std::streamsize inc)
71-
{
72-
static rand48 random_gen;
73-
static uniform_smallint<int> random_dist(0, static_cast<int>(inc));
74-
return random_dist(random_gen);
75-
}
76-
#else
77-
std::streamsize rand(std::streamsize inc)
78-
{
79-
return (std::rand() * inc + 1) / RAND_MAX;
80-
}
81-
#endif
62+
std::streamsize rand(std::streamsize inc)
63+
{
64+
static std::mt19937 random_gen;
65+
static std::uniform_int_distribution<int> random_dist(0, static_cast<int>(inc));
66+
return random_dist(random_gen);
67+
}
8268

8369
class non_blocking_source {
8470
public:

0 commit comments

Comments
 (0)