File indexing completed on 2025-01-18 09:51:09
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef BOOST_RANDOM_DETAIL_SEED_HPP
0014 #define BOOST_RANDOM_DETAIL_SEED_HPP
0015
0016 #include <boost/config.hpp>
0017
0018
0019
0020 #if !defined(BOOST_NO_SFINAE) && !defined(__SUNPRO_CC) && !defined(BOOST_BORLANDC)
0021
0022 #include <boost/utility/enable_if.hpp>
0023 #include <boost/type_traits/is_arithmetic.hpp>
0024
0025 namespace boost {
0026 namespace random {
0027 namespace detail {
0028
0029 template<class T>
0030 struct disable_seed : boost::disable_if<boost::is_arithmetic<T> > {};
0031
0032 template<class Engine, class T>
0033 struct disable_constructor : disable_seed<T> {};
0034
0035 template<class Engine>
0036 struct disable_constructor<Engine, Engine> {};
0037
0038 #define BOOST_RANDOM_DETAIL_GENERATOR_CONSTRUCTOR(Self, Generator, gen) \
0039 template<class Generator> \
0040 explicit Self(Generator& gen, typename ::boost::random::detail::disable_constructor<Self, Generator>::type* = 0)
0041
0042 #define BOOST_RANDOM_DETAIL_GENERATOR_SEED(Self, Generator, gen) \
0043 template<class Generator> \
0044 void seed(Generator& gen, typename ::boost::random::detail::disable_seed<Generator>::type* = 0)
0045
0046 #define BOOST_RANDOM_DETAIL_SEED_SEQ_CONSTRUCTOR(Self, SeedSeq, seq) \
0047 template<class SeedSeq> \
0048 explicit Self(SeedSeq& seq, typename ::boost::random::detail::disable_constructor<Self, SeedSeq>::type* = 0)
0049
0050 #define BOOST_RANDOM_DETAIL_SEED_SEQ_SEED(Self, SeedSeq, seq) \
0051 template<class SeedSeq> \
0052 void seed(SeedSeq& seq, typename ::boost::random::detail::disable_seed<SeedSeq>::type* = 0)
0053
0054 #define BOOST_RANDOM_DETAIL_ARITHMETIC_CONSTRUCTOR(Self, T, x) \
0055 explicit Self(const T& x)
0056
0057 #define BOOST_RANDOM_DETAIL_ARITHMETIC_SEED(Self, T, x) \
0058 void seed(const T& x)
0059 }
0060 }
0061 }
0062
0063 #else
0064
0065 #include <boost/type_traits/is_arithmetic.hpp>
0066
0067 #define BOOST_RANDOM_DETAIL_GENERATOR_CONSTRUCTOR(Self, Generator, gen) \
0068 Self(Self& other) { *this = other; } \
0069 Self(const Self& other) { *this = other; } \
0070 template<class Generator> \
0071 explicit Self(Generator& gen) { \
0072 boost_random_constructor_impl(gen, ::boost::is_arithmetic<Generator>());\
0073 } \
0074 template<class Generator> \
0075 void boost_random_constructor_impl(Generator& gen, ::boost::false_type)
0076
0077 #define BOOST_RANDOM_DETAIL_GENERATOR_SEED(Self, Generator, gen) \
0078 template<class Generator> \
0079 void seed(Generator& gen) { \
0080 boost_random_seed_impl(gen, ::boost::is_arithmetic<Generator>());\
0081 }\
0082 template<class Generator>\
0083 void boost_random_seed_impl(Generator& gen, ::boost::false_type)
0084
0085 #define BOOST_RANDOM_DETAIL_SEED_SEQ_CONSTRUCTOR(Self, SeedSeq, seq) \
0086 Self(Self& other) { *this = other; } \
0087 Self(const Self& other) { *this = other; } \
0088 template<class SeedSeq> \
0089 explicit Self(SeedSeq& seq) { \
0090 boost_random_constructor_impl(seq, ::boost::is_arithmetic<SeedSeq>());\
0091 } \
0092 template<class SeedSeq> \
0093 void boost_random_constructor_impl(SeedSeq& seq, ::boost::false_type)
0094
0095 #define BOOST_RANDOM_DETAIL_SEED_SEQ_SEED(Self, SeedSeq, seq) \
0096 template<class SeedSeq> \
0097 void seed(SeedSeq& seq) { \
0098 boost_random_seed_impl(seq, ::boost::is_arithmetic<SeedSeq>()); \
0099 } \
0100 template<class SeedSeq> \
0101 void boost_random_seed_impl(SeedSeq& seq, ::boost::false_type)
0102
0103 #define BOOST_RANDOM_DETAIL_ARITHMETIC_CONSTRUCTOR(Self, T, x) \
0104 explicit Self(const T& x) { boost_random_constructor_impl(x, ::boost::true_type()); }\
0105 void boost_random_constructor_impl(const T& x, ::boost::true_type)
0106
0107 #define BOOST_RANDOM_DETAIL_ARITHMETIC_SEED(Self, T, x) \
0108 void seed(const T& x) { boost_random_seed_impl(x, ::boost::true_type()); }\
0109 void boost_random_seed_impl(const T& x, ::boost::true_type)
0110
0111 #endif
0112
0113 #endif