1 /* boost random/detail/uniform_int_float.hpp header file
\r
3 * Copyright Jens Maurer 2000-2001
\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: pass_through_engine.hpp 58649 2010-01-02 21:23:17Z steven_watanabe $
\r
14 #ifndef BOOST_RANDOM_DETAIL_PASS_THROUGH_ENGINE_HPP
\r
15 #define BOOST_RANDOM_DETAIL_PASS_THROUGH_ENGINE_HPP
\r
17 #include <boost/config.hpp>
\r
18 #include <boost/random/detail/ptr_helper.hpp>
\r
19 #include <boost/random/detail/disable_warnings.hpp>
\r
25 template<class UniformRandomNumberGenerator>
\r
26 class pass_through_engine
\r
29 typedef ptr_helper<UniformRandomNumberGenerator> helper_type;
\r
32 typedef typename helper_type::value_type base_type;
\r
33 typedef typename base_type::result_type result_type;
\r
35 explicit pass_through_engine(UniformRandomNumberGenerator rng)
\r
36 // make argument an rvalue to avoid matching Generator& constructor
\r
37 : _rng(static_cast<typename helper_type::rvalue_type>(rng))
\r
40 result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return (base().min)(); }
\r
41 result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return (base().max)(); }
\r
42 base_type& base() { return helper_type::ref(_rng); }
\r
43 const base_type& base() const { return helper_type::ref(_rng); }
\r
45 result_type operator()() { return base()(); }
\r
48 UniformRandomNumberGenerator _rng;
\r
51 #ifndef BOOST_NO_STD_LOCALE
\r
53 template<class UniformRandomNumberGenerator, class CharT, class Traits>
\r
54 std::basic_ostream<CharT,Traits>&
\r
56 std::basic_ostream<CharT,Traits>& os
\r
57 , const pass_through_engine<UniformRandomNumberGenerator>& ud
\r
60 return os << ud.base();
\r
63 template<class UniformRandomNumberGenerator, class CharT, class Traits>
\r
64 std::basic_istream<CharT,Traits>&
\r
66 std::basic_istream<CharT,Traits>& is
\r
67 , const pass_through_engine<UniformRandomNumberGenerator>& ud
\r
70 return is >> ud.base();
\r
73 #else // no new streams
\r
75 template<class UniformRandomNumberGenerator>
\r
76 inline std::ostream&
\r
77 operator<<(std::ostream& os,
\r
78 const pass_through_engine<UniformRandomNumberGenerator>& ud)
\r
80 return os << ud.base();
\r
83 template<class UniformRandomNumberGenerator>
\r
84 inline std::istream&
\r
85 operator>>(std::istream& is,
\r
86 const pass_through_engine<UniformRandomNumberGenerator>& ud)
\r
88 return is >> ud.base();
\r
93 } // namespace detail
\r
94 } // namespace random
\r
95 } // namespace boost
\r
97 #include <boost/random/detail/enable_warnings.hpp>
\r
99 #endif // BOOST_RANDOM_DETAIL_PASS_THROUGH_ENGINE_HPP
\r