Chris@16: /* boost random/detail/seed.hpp header file Chris@16: * Chris@16: * Copyright Steven Watanabe 2009 Chris@16: * Distributed under the Boost Software License, Version 1.0. (See Chris@16: * accompanying file LICENSE_1_0.txt or copy at Chris@16: * http://www.boost.org/LICENSE_1_0.txt) Chris@16: * Chris@16: * See http://www.boost.org for most recent version including documentation. Chris@16: * Chris@101: * $Id$ Chris@16: */ Chris@16: Chris@16: #ifndef BOOST_RANDOM_DETAIL_SEED_HPP Chris@16: #define BOOST_RANDOM_DETAIL_SEED_HPP Chris@16: Chris@16: #include Chris@16: Chris@16: // Sun seems to have trouble with the use of SFINAE for the Chris@16: // templated constructor. So does Borland. Chris@16: #if !defined(BOOST_NO_SFINAE) && !defined(__SUNPRO_CC) && !defined(__BORLANDC__) Chris@16: Chris@16: #include Chris@16: #include Chris@101: #include Chris@16: Chris@16: namespace boost { Chris@16: namespace random { Chris@16: namespace detail { Chris@16: Chris@16: template Chris@16: struct disable_seed : boost::disable_if > {}; Chris@16: Chris@16: template Chris@16: struct disable_constructor : disable_seed {}; Chris@16: Chris@16: template Chris@16: struct disable_constructor {}; Chris@16: Chris@16: #define BOOST_RANDOM_DETAIL_GENERATOR_CONSTRUCTOR(Self, Generator, gen) \ Chris@16: template \ Chris@16: explicit Self(Generator& gen, typename ::boost::random::detail::disable_constructor::type* = 0) Chris@16: Chris@16: #define BOOST_RANDOM_DETAIL_GENERATOR_SEED(Self, Generator, gen) \ Chris@16: template \ Chris@16: void seed(Generator& gen, typename ::boost::random::detail::disable_seed::type* = 0) Chris@16: Chris@16: #define BOOST_RANDOM_DETAIL_SEED_SEQ_CONSTRUCTOR(Self, SeedSeq, seq) \ Chris@16: template \ Chris@16: explicit Self(SeedSeq& seq, typename ::boost::random::detail::disable_constructor::type* = 0) Chris@16: Chris@16: #define BOOST_RANDOM_DETAIL_SEED_SEQ_SEED(Self, SeedSeq, seq) \ Chris@16: template \ Chris@16: void seed(SeedSeq& seq, typename ::boost::random::detail::disable_seed::type* = 0) Chris@16: Chris@16: #define BOOST_RANDOM_DETAIL_ARITHMETIC_CONSTRUCTOR(Self, T, x) \ Chris@16: explicit Self(const T& x) Chris@16: Chris@16: #define BOOST_RANDOM_DETAIL_ARITHMETIC_SEED(Self, T, x) \ Chris@16: void seed(const T& x) Chris@16: } Chris@16: } Chris@16: } Chris@16: Chris@16: #else Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: #define BOOST_RANDOM_DETAIL_GENERATOR_CONSTRUCTOR(Self, Generator, gen) \ Chris@16: Self(Self& other) { *this = other; } \ Chris@16: Self(const Self& other) { *this = other; } \ Chris@16: template \ Chris@16: explicit Self(Generator& gen) { \ Chris@16: boost_random_constructor_impl(gen, ::boost::is_arithmetic());\ Chris@16: } \ Chris@16: template \ Chris@16: void boost_random_constructor_impl(Generator& gen, ::boost::mpl::false_) Chris@16: Chris@16: #define BOOST_RANDOM_DETAIL_GENERATOR_SEED(Self, Generator, gen) \ Chris@16: template \ Chris@16: void seed(Generator& gen) { \ Chris@16: boost_random_seed_impl(gen, ::boost::is_arithmetic());\ Chris@16: }\ Chris@16: template\ Chris@16: void boost_random_seed_impl(Generator& gen, ::boost::mpl::false_) Chris@16: Chris@16: #define BOOST_RANDOM_DETAIL_SEED_SEQ_CONSTRUCTOR(Self, SeedSeq, seq) \ Chris@16: Self(Self& other) { *this = other; } \ Chris@16: Self(const Self& other) { *this = other; } \ Chris@16: template \ Chris@16: explicit Self(SeedSeq& seq) { \ Chris@16: boost_random_constructor_impl(seq, ::boost::is_arithmetic());\ Chris@16: } \ Chris@16: template \ Chris@16: void boost_random_constructor_impl(SeedSeq& seq, ::boost::mpl::false_) Chris@16: Chris@16: #define BOOST_RANDOM_DETAIL_SEED_SEQ_SEED(Self, SeedSeq, seq) \ Chris@16: template \ Chris@16: void seed(SeedSeq& seq) { \ Chris@16: boost_random_seed_impl(seq, ::boost::is_arithmetic()); \ Chris@16: } \ Chris@16: template \ Chris@16: void boost_random_seed_impl(SeedSeq& seq, ::boost::mpl::false_) Chris@16: Chris@16: #define BOOST_RANDOM_DETAIL_ARITHMETIC_CONSTRUCTOR(Self, T, x) \ Chris@16: explicit Self(const T& x) { boost_random_constructor_impl(x, ::boost::mpl::true_()); }\ Chris@16: void boost_random_constructor_impl(const T& x, ::boost::mpl::true_) Chris@16: Chris@16: #define BOOST_RANDOM_DETAIL_ARITHMETIC_SEED(Self, T, x) \ Chris@16: void seed(const T& x) { boost_random_seed_impl(x, ::boost::mpl::true_()); }\ Chris@16: void boost_random_seed_impl(const T& x, ::boost::mpl::true_) Chris@16: Chris@16: #endif Chris@16: Chris@16: #endif