|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r58104 - trunk/boost/numeric/ublas
From: guwi17_at_[hidden]
Date: 2009-12-02 15:20:50
Author: guwi17
Date: 2009-12-02 15:20:50 EST (Wed, 02 Dec 2009)
New Revision: 58104
URL: http://svn.boost.org/trac/boost/changeset/58104
Log:
see #3649:
* applied patch
* existing unit test seem to work
Text files modified:
trunk/boost/numeric/ublas/traits.hpp | 86 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 86 insertions(+), 0 deletions(-)
Modified: trunk/boost/numeric/ublas/traits.hpp
==============================================================================
--- trunk/boost/numeric/ublas/traits.hpp (original)
+++ trunk/boost/numeric/ublas/traits.hpp 2009-12-02 15:20:50 EST (Wed, 02 Dec 2009)
@@ -23,6 +23,11 @@
#include <boost/type_traits.hpp>
#include <complex>
+#include <boost/typeof/typeof.hpp>
+#include <boost/utility/enable_if.hpp>
+#include <boost/type_traits/is_float.hpp>
+#include <boost/type_traits/is_integral.hpp>
+#include <boost/mpl/and.hpp>
// anonymous namespace to avoid ADL issues
namespace {
@@ -60,6 +65,87 @@
typedef typename id::type promote_type;
};
+ template<typename R, typename I>
+ typename boost::enable_if<
+ mpl::and_<
+ boost::is_float<R>,
+ boost::is_integral<I>
+ >,
+ std::complex<R> >::type inline operator+ (I in1, std::complex<R> const& in2 ) {
+ return R (in1) + in2;
+ }
+
+ template<typename R, typename I>
+ typename boost::enable_if<
+ mpl::and_<
+ boost::is_float<R>,
+ boost::is_integral<I>
+ >,
+ std::complex<R> >::type inline operator+ (std::complex<R> const& in1, I in2) {
+ return in1 + R (in2);
+ }
+
+ template<typename R, typename I>
+ typename boost::enable_if<
+ mpl::and_<
+ boost::is_float<R>,
+ boost::is_integral<I>
+ >,
+ std::complex<R> >::type inline operator- (I in1, std::complex<R> const& in2) {
+ return R (in1) - in2;
+ }
+
+ template<typename R, typename I>
+ typename boost::enable_if<
+ mpl::and_<
+ boost::is_float<R>,
+ boost::is_integral<I>
+ >,
+ std::complex<R> >::type inline operator- (std::complex<R> const& in1, I in2) {
+ return in1 - R (in2);
+ }
+
+ template<typename R, typename I>
+ typename boost::enable_if<
+ mpl::and_<
+ boost::is_float<R>,
+ boost::is_integral<I>
+ >,
+ std::complex<R> >::type inline operator* (I in1, std::complex<R> const& in2) {
+ return R (in1) * in2;
+ }
+
+ template<typename R, typename I>
+ typename boost::enable_if<
+ mpl::and_<
+ boost::is_float<R>,
+ boost::is_integral<I>
+ >,
+ std::complex<R> >::type inline operator* (std::complex<R> const& in1, I in2) {
+ return in1 * R(in2);
+ }
+
+ template<typename R, typename I>
+ typename boost::enable_if<
+ mpl::and_<
+ boost::is_float<R>,
+ boost::is_integral<I>
+ >,
+ std::complex<R> >::type inline operator/ (I in1, std::complex<R> const& in2) {
+ return R(in1) / in2;
+ }
+
+ template<typename R, typename I>
+ typename boost::enable_if<
+ mpl::and_<
+ boost::is_float<R>,
+ boost::is_integral<I>
+ >,
+ std::complex<R> >::type inline operator/ (std::complex<R> const& in1, I in2) {
+ return in1 / R (in2);
+ }
+
+
// Type traits - generic numeric properties and functions
template<class 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