]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/random/detail/seed.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / random / detail / seed.hpp
1 /* boost random/detail/seed.hpp header file
2 *
3 * Copyright Steven Watanabe 2009
4 * Distributed under the Boost Software License, Version 1.0. (See
5 * accompanying file LICENSE_1_0.txt or copy at
6 * http://www.boost.org/LICENSE_1_0.txt)
7 *
8 * See http://www.boost.org for most recent version including documentation.
9 *
10 * $Id$
11 */
12
13 #ifndef BOOST_RANDOM_DETAIL_SEED_HPP
14 #define BOOST_RANDOM_DETAIL_SEED_HPP
15
16 #include <boost/config.hpp>
17
18 // Sun seems to have trouble with the use of SFINAE for the
19 // templated constructor. So does Borland.
20 #if !defined(BOOST_NO_SFINAE) && !defined(__SUNPRO_CC) && !defined(BOOST_BORLANDC)
21
22 #include <boost/utility/enable_if.hpp>
23 #include <boost/type_traits/is_arithmetic.hpp>
24
25 namespace boost {
26 namespace random {
27 namespace detail {
28
29 template<class T>
30 struct disable_seed : boost::disable_if<boost::is_arithmetic<T> > {};
31
32 template<class Engine, class T>
33 struct disable_constructor : disable_seed<T> {};
34
35 template<class Engine>
36 struct disable_constructor<Engine, Engine> {};
37
38 #define BOOST_RANDOM_DETAIL_GENERATOR_CONSTRUCTOR(Self, Generator, gen) \
39 template<class Generator> \
40 explicit Self(Generator& gen, typename ::boost::random::detail::disable_constructor<Self, Generator>::type* = 0)
41
42 #define BOOST_RANDOM_DETAIL_GENERATOR_SEED(Self, Generator, gen) \
43 template<class Generator> \
44 void seed(Generator& gen, typename ::boost::random::detail::disable_seed<Generator>::type* = 0)
45
46 #define BOOST_RANDOM_DETAIL_SEED_SEQ_CONSTRUCTOR(Self, SeedSeq, seq) \
47 template<class SeedSeq> \
48 explicit Self(SeedSeq& seq, typename ::boost::random::detail::disable_constructor<Self, SeedSeq>::type* = 0)
49
50 #define BOOST_RANDOM_DETAIL_SEED_SEQ_SEED(Self, SeedSeq, seq) \
51 template<class SeedSeq> \
52 void seed(SeedSeq& seq, typename ::boost::random::detail::disable_seed<SeedSeq>::type* = 0)
53
54 #define BOOST_RANDOM_DETAIL_ARITHMETIC_CONSTRUCTOR(Self, T, x) \
55 explicit Self(const T& x)
56
57 #define BOOST_RANDOM_DETAIL_ARITHMETIC_SEED(Self, T, x) \
58 void seed(const T& x)
59 }
60 }
61 }
62
63 #else
64
65 #include <boost/type_traits/is_arithmetic.hpp>
66
67 #define BOOST_RANDOM_DETAIL_GENERATOR_CONSTRUCTOR(Self, Generator, gen) \
68 Self(Self& other) { *this = other; } \
69 Self(const Self& other) { *this = other; } \
70 template<class Generator> \
71 explicit Self(Generator& gen) { \
72 boost_random_constructor_impl(gen, ::boost::is_arithmetic<Generator>());\
73 } \
74 template<class Generator> \
75 void boost_random_constructor_impl(Generator& gen, ::boost::false_type)
76
77 #define BOOST_RANDOM_DETAIL_GENERATOR_SEED(Self, Generator, gen) \
78 template<class Generator> \
79 void seed(Generator& gen) { \
80 boost_random_seed_impl(gen, ::boost::is_arithmetic<Generator>());\
81 }\
82 template<class Generator>\
83 void boost_random_seed_impl(Generator& gen, ::boost::false_type)
84
85 #define BOOST_RANDOM_DETAIL_SEED_SEQ_CONSTRUCTOR(Self, SeedSeq, seq) \
86 Self(Self& other) { *this = other; } \
87 Self(const Self& other) { *this = other; } \
88 template<class SeedSeq> \
89 explicit Self(SeedSeq& seq) { \
90 boost_random_constructor_impl(seq, ::boost::is_arithmetic<SeedSeq>());\
91 } \
92 template<class SeedSeq> \
93 void boost_random_constructor_impl(SeedSeq& seq, ::boost::false_type)
94
95 #define BOOST_RANDOM_DETAIL_SEED_SEQ_SEED(Self, SeedSeq, seq) \
96 template<class SeedSeq> \
97 void seed(SeedSeq& seq) { \
98 boost_random_seed_impl(seq, ::boost::is_arithmetic<SeedSeq>()); \
99 } \
100 template<class SeedSeq> \
101 void boost_random_seed_impl(SeedSeq& seq, ::boost::false_type)
102
103 #define BOOST_RANDOM_DETAIL_ARITHMETIC_CONSTRUCTOR(Self, T, x) \
104 explicit Self(const T& x) { boost_random_constructor_impl(x, ::boost::true_type()); }\
105 void boost_random_constructor_impl(const T& x, ::boost::true_type)
106
107 #define BOOST_RANDOM_DETAIL_ARITHMETIC_SEED(Self, T, x) \
108 void seed(const T& x) { boost_random_seed_impl(x, ::boost::true_type()); }\
109 void boost_random_seed_impl(const T& x, ::boost::true_type)
110
111 #endif
112
113 #endif