1 /* boost random/detail/seed.hpp header file
\r
3 * Copyright Steven Watanabe 2009
\r
4 * Distributed under the Boost Software License, Version 1.0. (See
\r
5 * accompanying file LICENSE_1_0.txt or copy at
\r
6 * http://www.boost.org/LICENSE_1_0.txt)
\r
8 * See http://www.boost.org for most recent version including documentation.
\r
10 * $Id: seed.hpp 53871 2009-06-13 17:54:06Z steven_watanabe $
\r
13 #ifndef BOOST_RANDOM_DETAIL_SEED_HPP
\r
14 #define BOOST_RANDOM_DETAIL_SEED_HPP
\r
16 #include <boost/config.hpp>
\r
18 #if !defined(BOOST_NO_SFINAE)
\r
20 #include <boost/utility/enable_if.hpp>
\r
21 #include <boost/type_traits/is_arithmetic.hpp>
\r
28 struct disable_seed : boost::disable_if<boost::is_arithmetic<T> > {};
\r
30 template<class Engine, class T>
\r
31 struct disable_constructor : disable_seed<T> {};
\r
33 template<class Engine>
\r
34 struct disable_constructor<Engine, Engine> {
\r
37 #define BOOST_RANDOM_DETAIL_GENERATOR_CONSTRUCTOR(Self, Generator, gen) \
\r
38 template<class Generator> \
\r
39 explicit Self(Generator& gen, typename ::boost::random::detail::disable_constructor<Self, Generator>::type* = 0)
\r
41 #define BOOST_RANDOM_DETAIL_GENERATOR_SEED(Self, Generator, gen) \
\r
42 template<class Generator> \
\r
43 void seed(Generator& gen, typename ::boost::random::detail::disable_seed<Generator>::type* = 0)
\r
45 #define BOOST_RANDOM_DETAIL_ARITHMETIC_CONSTRUCTOR(Self, T, x) \
\r
46 explicit Self(const T& x)
\r
48 #define BOOST_RANDOM_DETAIL_ARITHMETIC_SEED(Self, T, x) \
\r
49 void seed(const T& x)
\r
57 #include <boost/type_traits/is_arithmetic.hpp>
\r
58 #include <boost/mpl/bool.hpp>
\r
60 #define BOOST_RANDOM_DETAIL_GENERATOR_CONSTRUCTOR(Self, Generator, gen) \
\r
61 Self(Self& other) { *this = other; } \
\r
62 Self(const Self& other) { *this = other; } \
\r
63 template<class Generator> \
\r
64 explicit Self(Generator& gen) { \
\r
65 boost_random_constructor_impl(gen, ::boost::is_arithmetic<Generator>());\
\r
67 template<class Generator> \
\r
68 void boost_random_constructor_impl(Generator& gen, ::boost::mpl::false_)
\r
70 #define BOOST_RANDOM_DETAIL_GENERATOR_SEED(Self, Generator, gen) \
\r
71 template<class Generator> \
\r
72 void seed(Generator& gen) { \
\r
73 boost_random_seed_impl(gen, ::boost::is_arithmetic<Generator>());\
\r
75 template<class Generator>\
\r
76 void boost_random_seed_impl(Generator& gen, ::boost::mpl::false_)
\r
78 #define BOOST_RANDOM_DETAIL_ARITHMETIC_CONSTRUCTOR(Self, T, x) \
\r
79 explicit Self(const T& x) { boost_random_constructor_impl(x, ::boost::mpl::true_()); }\
\r
80 void boost_random_constructor_impl(const T& x, ::boost::mpl::true_)
\r
82 #define BOOST_RANDOM_DETAIL_ARITHMETIC_SEED(Self, T, x) \
\r
83 void seed(const T& x) { boost_random_seed_impl(x, ::boost::mpl::true_()); }\
\r
84 void boost_random_seed_impl(const T& x, ::boost::mpl::true_)
\r