|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r63286 - in trunk: boost/random boost/random/detail libs/random/doc
From: steven_at_[hidden]
Date: 2010-06-24 11:58:43
Author: steven_watanabe
Date: 2010-06-24 11:58:41 EDT (Thu, 24 Jun 2010)
New Revision: 63286
URL: http://svn.boost.org/trac/boost/changeset/63286
Log:
Attempt to fix msvc-7.1 errors in subtract_with_carry.
Added:
trunk/boost/random/detail/operators.hpp (contents, props changed)
Text files modified:
trunk/boost/random/subtract_with_carry.hpp | 50 +++++++++++----------------------------
trunk/libs/random/doc/Jamfile.v2 | 4 +++
2 files changed, 18 insertions(+), 36 deletions(-)
Added: trunk/boost/random/detail/operators.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/random/detail/operators.hpp 2010-06-24 11:58:41 EDT (Thu, 24 Jun 2010)
@@ -0,0 +1,69 @@
+/* boost random/detail/operators.hpp header file
+ *
+ * Copyright Steven Watanabe 2010
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * See http://www.boost.org for most recent version including documentation.
+ *
+ * $Id$
+ */
+
+#ifndef BOOST_RANDOM_DETAIL_OPERATORS_HPP
+#define BOOST_RANDOM_DETAIL_OPERATORS_HPP
+
+#include <boost/random/detail/config.hpp>
+
+#if BOOST_WORKAROUND(BOOST_MSVC, <= 1310)
+
+#define BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR(os, T, t) \
+ template<class CharT, class Traits> \
+ friend std::basic_ostream<CharT,Traits>& \
+ operator<<(std::basic_ostream<CharT,Traits>& os, const T& t) { \
+ t.print(os, t); \
+ return os; \
+ } \
+ template<class CharT, class Traits> \
+ static std::basic_ostream<CharT,Traits>& \
+ print(std::basic_ostream<CharT,Traits>& os, const T& t)
+
+#define BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, T, t) \
+ template<class CharT, class Traits> \
+ friend std::basic_istream<CharT,Traits>& \
+ operator>>(std::basic_istream<CharT,Traits>& is, T& t) { \
+ t.read(is, t); \
+ return is; \
+ } \
+ template<class CharT, class Traits> \
+ static std::basic_istream<CharT,Traits>& \
+ read(std::basic_istream<CharT,Traits>& is, T& t)
+
+#endif
+
+#ifndef BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR
+#define BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR(os, T, t) \
+ template<class CharT, class Traits> \
+ friend std::basic_ostream<CharT,Traits>& \
+ operator<<(std::basic_ostream<CharT,Traits>& os, const T& t)
+#endif
+
+#ifndef BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR
+#define BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, T, t) \
+ template<class CharT, class Traits> \
+ friend std::basic_istream<CharT,Traits>& \
+ operator>>(std::basic_istream<CharT,Traits>& is, T& t)
+#endif
+
+#ifndef BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR
+#define BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(T, lhs, rhs) \
+ friend bool operator==(const T& lhs, const T& rhs)
+#endif
+
+#ifndef BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR
+#define BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(T) \
+ friend bool operator!=(const T& lhs, const T& rhs) \
+ { return !(lhs == rhs); }
+#endif
+
+#endif
Modified: trunk/boost/random/subtract_with_carry.hpp
==============================================================================
--- trunk/boost/random/subtract_with_carry.hpp (original)
+++ trunk/boost/random/subtract_with_carry.hpp 2010-06-24 11:58:41 EDT (Thu, 24 Jun 2010)
@@ -27,6 +27,7 @@
#include <boost/detail/workaround.hpp>
#include <boost/random/detail/config.hpp>
#include <boost/random/detail/seed.hpp>
+#include <boost/random/detail/operators.hpp>
#include <boost/random/linear_congruential.hpp>
@@ -193,12 +194,8 @@
}
}
-#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
/** Writes a @c subtract_with_carry_engine to a @c std::ostream. */
- template<class CharT, class Traits>
- friend std::basic_ostream<CharT,Traits>&
- operator<<(std::basic_ostream<CharT,Traits>& os,
- const subtract_with_carry_engine& f)
+ BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR(os, subtract_with_carry_engine, f)
{
for(unsigned int j = 0; j < f.long_lag; ++j)
os << f.compute(j) << " ";
@@ -207,10 +204,7 @@
}
/** Reads a @c subtract_with_carry_engine from a @c std::istream. */
- template<class CharT, class Traits>
- friend std::basic_istream<CharT,Traits>&
- operator>>(std::basic_istream<CharT,Traits>& is,
- subtract_with_carry_engine& f)
+ BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, subtract_with_carry_engine, f)
{
for(unsigned int j = 0; j < f.long_lag; ++j)
is >> f.x[j] >> std::ws;
@@ -218,14 +212,12 @@
f.k = 0;
return is;
}
-#endif
/**
* Returns true if the two generators will produce identical
* sequences of values.
*/
- friend bool operator==(const subtract_with_carry_engine& x,
- const subtract_with_carry_engine& y)
+ BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(subtract_with_carry_engine, x, y)
{
for(unsigned int j = 0; j < r; ++j)
if(x.compute(j) != y.compute(j))
@@ -237,9 +229,7 @@
* Returns true if the two generators will produce different
* sequences of values.
*/
- friend bool operator!=(const subtract_with_carry_engine& x,
- const subtract_with_carry_engine& y)
- { return !(x == y); }
+ BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(subtract_with_carry_engine)
private:
/// \cond
@@ -440,11 +430,8 @@
}
}
-#ifndef BOOST_RANDOM_NO_STREAM_OPERATORS
- template<class CharT, class Traits>
- friend std::basic_ostream<CharT,Traits>&
- operator<<(std::basic_ostream<CharT,Traits>& os,
- const subtract_with_carry_01_engine& f)
+ /** Writes a subtract_with_carry_01_engine to a @c std::ostream. */
+ BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR(os, subtract_with_carry_01_engine, f)
{
std::ios_base::fmtflags oldflags =
os.flags(os.dec | os.fixed | os.left);
@@ -454,16 +441,11 @@
os.flags(oldflags);
return os;
}
-
- template<class CharT, class Traits>
- friend std::basic_istream<CharT,Traits>&
- operator>>(std::basic_istream<CharT,Traits>& is,
- subtract_with_carry_01_engine& f)
- {
- // MSVC (up to 7.1) and Borland (up to 5.64) don't handle the template
- // type parameter "RealType" available from the class template scope,
- // so use the member typedef
- typename subtract_with_carry_01_engine::result_type value;
+
+ /** Reads a subtract_with_carry_01_engine from a @c std::istream. */
+ BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is, subtract_with_carry_01_engine, f)
+ {
+ RealType value;
for(unsigned int j = 0; j < long_lag; ++j) {
is >> value >> std::ws;
f.x[j] = value / f._modulus;
@@ -473,11 +455,9 @@
f.k = 0;
return is;
}
-#endif
/** Returns true if the two generators will produce identical sequences. */
- friend bool operator==(const subtract_with_carry_01_engine& x,
- const subtract_with_carry_01_engine& y)
+ BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(subtract_with_carry_01_engine, x, y)
{
for(unsigned int j = 0; j < r; ++j)
if(x.compute(j) != y.compute(j))
@@ -486,9 +466,7 @@
}
/** Returns true if the two generators will produce different sequences. */
- friend bool operator!=(const subtract_with_carry_01_engine& x,
- const subtract_with_carry_01_engine& y)
- { return !(x == y); }
+ BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(subtract_with_carry_01_engine)
private:
/// \cond
Modified: trunk/libs/random/doc/Jamfile.v2
==============================================================================
--- trunk/libs/random/doc/Jamfile.v2 (original)
+++ trunk/libs/random/doc/Jamfile.v2 2010-06-24 11:58:41 EDT (Thu, 24 Jun 2010)
@@ -104,6 +104,10 @@
\"BOOST_PREVENT_MACRO_SUBSTITUTION=\" \\
\"BOOST_STATIC_ASSERT(x)=\" \\
\"BOOST_STATIC_CONSTANT(type,value)=static const type value\" \\
+ \"BOOST_RANDOM_DETAIL_OSTREAM_OPERATOR(os,T,t)=template<class CharT, class Traits> friend std::basic_ostream<CharT,Traits>& operator<<(std::basic_ostream<CharT,Traits>& os, const T& t)\" \\
+ \"BOOST_RANDOM_DETAIL_ISTREAM_OPERATOR(is,T,t)=template<class CharT, class Traits> friend std::basic_istream<CharT,Traits>& operator>>(std::basic_istream<CharT,Traits>& is, const T& t)\" \\
+ \"BOOST_RANDOM_DETAIL_EQUALITY_OPERATOR(T,lhs,rhs)=friend bool operator==(const T& rhs, const T& rhs)\" \\
+ \"BOOST_RANDOM_DETAIL_INEQUALITY_OPERATOR(T)=friend bool operator!=(const T& rhs, const T& rhs) { return !(lhs == rhs); }\" \\
\"BOOST_RANDOM_DETAIL_ARITHMETIC_CONSTRUCTOR(Self,T,t)=explicit Self(T t)\" \\
\"BOOST_RANDOM_DETAIL_GENERATOR_CONSTRUCTOR(Self,T,t)=template<class T> explicit Self(T& t)\" \\
\"BOOST_RANDOM_DETAIL_SEED_SEQ_CONSTRUCTOR(Self,T,t)=template<class T> explicit Self(T& t)\" \\
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk