blob: 4df4881d5d5e4bd8d66e7b7afffa6a3dbf927fd2 [file] [log] [blame]
Jeff Thompson86b6d642013-10-17 15:01:56 -07001/* 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: operators.hpp 71018 2011-04-05 21:27:52Z steven_watanabe $
11 */
12
13#ifndef NDNBOOST_RANDOM_DETAIL_OPERATORS_HPP
14#define NDNBOOST_RANDOM_DETAIL_OPERATORS_HPP
15
16#include <ndnboost/random/detail/config.hpp>
17#include <ndnboost/detail/workaround.hpp>
18
19#if NDNBOOST_WORKAROUND(NDNBOOST_MSVC, <= 1310) \
20 || NDNBOOST_WORKAROUND(__SUNPRO_CC, NDNBOOST_TESTED_AT(0x5100))
21
22#define NDNBOOST_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 NDNBOOST_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 NDNBOOST_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 NDNBOOST_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 NDNBOOST_RANDOM_DETAIL_OSTREAM_OPERATOR
60#define NDNBOOST_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 NDNBOOST_RANDOM_DETAIL_ISTREAM_OPERATOR
67#define NDNBOOST_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 NDNBOOST_RANDOM_DETAIL_EQUALITY_OPERATOR
74#define NDNBOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(T, lhs, rhs) \
75 friend bool operator==(const T& lhs, const T& rhs)
76#endif
77
78#ifndef NDNBOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR
79#define NDNBOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(T) \
80 friend bool operator!=(const T& lhs, const T& rhs) \
81 { return !(lhs == rhs); }
82#endif
83
84#endif