1 /* boost random/detail/operators.hpp header file
3 * Copyright Steven Watanabe 2010-2011
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)
8 * See http://www.boost.org for most recent version including documentation.
13 #ifndef BOOST_RANDOM_DETAIL_OPERATORS_HPP
14 #define BOOST_RANDOM_DETAIL_OPERATORS_HPP
16 #include <boost/random/detail/config.hpp>
17 #include <boost/detail/workaround.hpp>
19 #if BOOST_WORKAROUND(BOOST_MSVC, <= 1310) \
20 || BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100))
22 #define BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR(os, T, t) \
23 template<class CharT, class Traits> \
24 friend std::basic_ostream<CharT,Traits>& \
25 operator<<(std::basic_ostream<CharT,Traits>& os, const T& t) { \
29 template<class CharT, class Traits> \
30 static std::basic_ostream<CharT,Traits>& \
31 print(std::basic_ostream<CharT,Traits>& os, const T& t)
33 #define BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, T, t) \
34 template<class CharT, class Traits> \
35 friend std::basic_istream<CharT,Traits>& \
36 operator>>(std::basic_istream<CharT,Traits>& is, T& t) { \
40 template<class CharT, class Traits> \
41 static std::basic_istream<CharT,Traits>& \
42 read(std::basic_istream<CharT,Traits>& is, T& t)
46 #if defined(__BORLANDC__)
48 #define BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(T, lhs, rhs) \
49 bool operator==(const T& rhs) const \
50 { return T::is_equal(*this, rhs); } \
51 static bool is_equal(const T& lhs, const T& rhs)
53 #define BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(T) \
54 bool operator!=(const T& rhs) const \
55 { return !T::is_equal(*this, rhs); }
59 #ifndef BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR
60 #define BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR(os, T, t) \
61 template<class CharT, class Traits> \
62 friend std::basic_ostream<CharT,Traits>& \
63 operator<<(std::basic_ostream<CharT,Traits>& os, const T& t)
66 #ifndef BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR
67 #define BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, T, t) \
68 template<class CharT, class Traits> \
69 friend std::basic_istream<CharT,Traits>& \
70 operator>>(std::basic_istream<CharT,Traits>& is, T& t)
73 #ifndef BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR
74 #define BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(T, lhs, rhs) \
75 friend bool operator==(const T& lhs, const T& rhs)
78 #ifndef BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR
79 #define BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(T) \
80 friend bool operator!=(const T& lhs, const T& rhs) \
81 { return !(lhs == rhs); }