]> AND Private Git Repository - canny.git/blob - stc/exp/ml_stc_linux_make_v1.0/include/boost/random/detail/pass_through_engine.hpp
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
8627025ef165cb6e29a66d49086b5fe0b2211f63
[canny.git] / stc / exp / ml_stc_linux_make_v1.0 / include / boost / random / detail / pass_through_engine.hpp
1 /* boost random/detail/uniform_int_float.hpp header file\r
2  *\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
7  *\r
8  * See http://www.boost.org for most recent version including documentation.\r
9  *\r
10  * $Id: pass_through_engine.hpp 58649 2010-01-02 21:23:17Z steven_watanabe $\r
11  *\r
12  */\r
13 \r
14 #ifndef BOOST_RANDOM_DETAIL_PASS_THROUGH_ENGINE_HPP\r
15 #define BOOST_RANDOM_DETAIL_PASS_THROUGH_ENGINE_HPP\r
16 \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
20 \r
21 namespace boost {\r
22 namespace random {\r
23 namespace detail {\r
24 \r
25 template<class UniformRandomNumberGenerator>\r
26 class pass_through_engine\r
27 {\r
28 private:\r
29   typedef ptr_helper<UniformRandomNumberGenerator> helper_type;\r
30 \r
31 public:\r
32   typedef typename helper_type::value_type base_type;\r
33   typedef typename base_type::result_type result_type;\r
34 \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
38   { }\r
39 \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
44 \r
45   result_type operator()() { return base()(); }\r
46 \r
47 private:\r
48   UniformRandomNumberGenerator _rng;\r
49 };\r
50 \r
51 #ifndef BOOST_NO_STD_LOCALE\r
52 \r
53 template<class UniformRandomNumberGenerator, class CharT, class Traits>\r
54 std::basic_ostream<CharT,Traits>&\r
55 operator<<(\r
56     std::basic_ostream<CharT,Traits>& os\r
57     , const pass_through_engine<UniformRandomNumberGenerator>& ud\r
58     )\r
59 {\r
60     return os << ud.base();\r
61 }\r
62 \r
63 template<class UniformRandomNumberGenerator, class CharT, class Traits>\r
64 std::basic_istream<CharT,Traits>&\r
65 operator>>(\r
66     std::basic_istream<CharT,Traits>& is\r
67     , const pass_through_engine<UniformRandomNumberGenerator>& ud\r
68     )\r
69 {\r
70     return is >> ud.base();\r
71 }\r
72 \r
73 #else // no new streams\r
74 \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
79 {\r
80     return os << ud.base();\r
81 }\r
82 \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
87 {\r
88     return is >> ud.base();\r
89 }\r
90 \r
91 #endif\r
92 \r
93 } // namespace detail\r
94 } // namespace random\r
95 } // namespace boost\r
96 \r
97 #include <boost/random/detail/enable_warnings.hpp>\r
98 \r
99 #endif // BOOST_RANDOM_DETAIL_PASS_THROUGH_ENGINE_HPP\r
100 \r