]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /* boost random/detail/operators.hpp header file |
2 | * | |
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) | |
7 | * | |
8 | * See http://www.boost.org for most recent version including documentation. | |
9 | * | |
10 | * $Id$ | |
11 | */ | |
12 | ||
13 | #ifndef BOOST_RANDOM_DETAIL_OPERATORS_HPP | |
14 | #define BOOST_RANDOM_DETAIL_OPERATORS_HPP | |
15 | ||
16 | #include <boost/random/detail/config.hpp> | |
17 | #include <boost/detail/workaround.hpp> | |
18 | ||
19 | #if BOOST_WORKAROUND(BOOST_MSVC, <= 1310) \ | |
20 | || BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x5100)) | |
21 | ||
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) { \ | |
26 | t.print(os, t); \ | |
27 | return os; \ | |
28 | } \ | |
29 | template<class CharT, class Traits> \ | |
30 | static std::basic_ostream<CharT,Traits>& \ | |
31 | print(std::basic_ostream<CharT,Traits>& os, const T& t) | |
32 | ||
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) { \ | |
37 | t.read(is, t); \ | |
38 | return is; \ | |
39 | } \ | |
40 | template<class CharT, class Traits> \ | |
41 | static std::basic_istream<CharT,Traits>& \ | |
42 | read(std::basic_istream<CharT,Traits>& is, T& t) | |
43 | ||
44 | #endif | |
45 | ||
46 | #if defined(__BORLANDC__) | |
47 | ||
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) | |
52 | ||
53 | #define BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(T) \ | |
54 | bool operator!=(const T& rhs) const \ | |
55 | { return !T::is_equal(*this, rhs); } | |
56 | ||
57 | #endif | |
58 | ||
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) | |
64 | #endif | |
65 | ||
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) | |
71 | #endif | |
72 | ||
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) | |
76 | #endif | |
77 | ||
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); } | |
82 | #endif | |
83 | ||
84 | #endif |