diff --git a/include/boost/multiprecision/detail/number_base.hpp b/include/boost/multiprecision/detail/number_base.hpp index 21975d80..15e4e2bc 100644 --- a/include/boost/multiprecision/detail/number_base.hpp +++ b/include/boost/multiprecision/detail/number_base.hpp @@ -330,12 +330,19 @@ struct expression const Arg1& left_ref()const BOOST_NOEXCEPT { return arg; } static const unsigned depth = left_type::depth + 1; - +#ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS + explicit operator bool()const + { + result_type r(*this); + return static_cast(r); + } +#else operator unmentionable_type()const { result_type r(*this); return r ? &unmentionable::proc : 0; } +#endif private: typename expression_storage::type arg; @@ -355,10 +362,17 @@ struct expression static const unsigned depth = 0; +#ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS + explicit operator bool()const + { + return static_cast(arg); + } +#else operator unmentionable_type()const { return arg ? &unmentionable::proc : 0; } +#endif private: typename expression_storage::type arg; @@ -383,12 +397,19 @@ struct expression const Arg1& left_ref()const BOOST_NOEXCEPT { return arg1; } const Arg2& right_ref()const BOOST_NOEXCEPT { return arg2; } +#ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS + explicit operator bool()const + { + result_type r(*this); + return static_cast(r); + } +#else operator unmentionable_type()const { result_type r(*this); return r ? &unmentionable::proc : 0; } - +#endif static const unsigned left_depth = left_type::depth + 1; static const unsigned right_depth = right_type::depth + 1; static const unsigned depth = left_depth > right_depth ? left_depth : right_depth; @@ -423,12 +444,19 @@ struct expression const Arg2& middle_ref()const BOOST_NOEXCEPT { return arg2; } const Arg3& right_ref()const BOOST_NOEXCEPT { return arg3; } +#ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS + explicit operator bool()const + { + result_type r(*this); + return static_cast(r); + } +#else operator unmentionable_type()const { result_type r(*this); return r ? &unmentionable::proc : 0; } - +#endif static const unsigned left_depth = left_type::depth + 1; static const unsigned middle_depth = middle_type::depth + 1; static const unsigned right_depth = right_type::depth + 1; @@ -472,12 +500,19 @@ struct expression const Arg3& right_middle_ref()const BOOST_NOEXCEPT { return arg3; } const Arg4& right_ref()const BOOST_NOEXCEPT { return arg4; } +#ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS + explicit operator bool()const + { + result_type r(*this); + return static_cast(r); + } +#else operator unmentionable_type()const { result_type r(*this); return r ? &unmentionable::proc : 0; } - +#endif static const unsigned left_depth = left_type::depth + 1; static const unsigned left_middle_depth = left_middle_type::depth + 1; static const unsigned right_middle_depth = right_middle_type::depth + 1; diff --git a/include/boost/multiprecision/number.hpp b/include/boost/multiprecision/number.hpp index 21a5b484..b61ed079 100644 --- a/include/boost/multiprecision/number.hpp +++ b/include/boost/multiprecision/number.hpp @@ -541,13 +541,19 @@ public: // // Use in boolean context: // +#ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS + BOOST_MP_FORCEINLINE explicit operator bool()const + { + return !is_zero(); + } +#else typedef bool (self_type::*unmentionable_type)()const; BOOST_MP_FORCEINLINE operator unmentionable_type()const { return is_zero() ? 0 : &self_type::is_zero; } - +#endif // // swap: // @@ -623,11 +629,12 @@ public: { return this->template convert_to(); } + /* explicit operator bool()const { using default_ops::eval_is_zero; return !eval_is_zero(backend()); - } + }*/ explicit operator void()const {} #endif #endif @@ -1764,26 +1771,12 @@ inline multiprecision::number denominator(const rational return a.denominator(); } -namespace numeric { namespace ublas { -// -// uBlas interoperability: -// -template -class sparse_vector_element; - -template -inline bool operator == (const sparse_vector_element& a, const ::boost::multiprecision::number& b) -{ -typedef typename sparse_vector_element::const_reference ref_type; - return static_cast(a) == b; -} - -}} // namespaces - #ifdef BOOST_MSVC #pragma warning(pop) #endif } // namespaces +#include + #endif diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 35e8c6a6..efe916ef 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -500,6 +500,13 @@ run ublas_interop/test5.cpp ublas_interop/test52.cpp ublas_interop/test53.cpp ; run ublas_interop/test6.cpp ublas_interop/test62.cpp ublas_interop/test63.cpp ; #run ublas_interop/test7.cpp ublas_interop/test71.cpp ublas_interop/test72.cpp ublas_interop/test73.cpp ; +run ublas_interop/test1.cpp ublas_interop/test11.cpp ublas_interop/test12.cpp ublas_interop/test13.cpp : : : TEST_ET=1 : ublas1_et ; +run ublas_interop/test2.cpp ublas_interop/test21.cpp ublas_interop/test22.cpp ublas_interop/test23.cpp : : : TEST_ET=1 : ublas2_et ; +#run ublas_interop/test3.cpp ublas_interop/test31.cpp ublas_interop/test32.cpp ublas_interop/test33.cpp : : : TEST_ET=1 : ublas3_et ; +run ublas_interop/test4.cpp ublas_interop/test42.cpp ublas_interop/test43.cpp : : : TEST_ET=1 : ublas3_et ; +run ublas_interop/test5.cpp ublas_interop/test52.cpp ublas_interop/test53.cpp : : : TEST_ET=1 : ublas4_et ; +run ublas_interop/test6.cpp ublas_interop/test62.cpp ublas_interop/test63.cpp : : : TEST_ET=1 : ublas5_et ; +#run ublas_interop/test7.cpp ublas_interop/test71.cpp ublas_interop/test72.cpp ublas_interop/test73.cpp : : : TEST_ET=1 : ublas6_et ; if $(enable-specfun) { diff --git a/test/ublas_interop/test1.hpp b/test/ublas_interop/test1.hpp index b732c66e..887b5055 100644 --- a/test/ublas_interop/test1.hpp +++ b/test/ublas_interop/test1.hpp @@ -19,7 +19,11 @@ #include +#ifdef TEST_ET +typedef boost::multiprecision::number, boost::multiprecision::et_on> mp_test_type; +#else typedef boost::multiprecision::number, boost::multiprecision::et_off> mp_test_type; +#endif //typedef double mp_test_type; #define USE_RANGE diff --git a/test/ublas_interop/test2.hpp b/test/ublas_interop/test2.hpp index 232b7e2c..7d5154ae 100644 --- a/test/ublas_interop/test2.hpp +++ b/test/ublas_interop/test2.hpp @@ -18,7 +18,11 @@ #include +#ifdef TEST_ET +typedef boost::multiprecision::number, boost::multiprecision::et_on> mp_test_type; +#else typedef boost::multiprecision::number, boost::multiprecision::et_off> mp_test_type; +#endif //typedef double mp_test_type; #define USE_RANGE diff --git a/test/ublas_interop/test3.hpp b/test/ublas_interop/test3.hpp index 97becba0..05d61e9f 100644 --- a/test/ublas_interop/test3.hpp +++ b/test/ublas_interop/test3.hpp @@ -19,7 +19,11 @@ #include +#ifdef TEST_ET +typedef boost::multiprecision::number, boost::multiprecision::et_on> mp_test_type; +#else typedef boost::multiprecision::number, boost::multiprecision::et_off> mp_test_type; +#endif //typedef double mp_test_type; #define USE_RANGE diff --git a/test/ublas_interop/test4.hpp b/test/ublas_interop/test4.hpp index c5ed3eba..6490dd46 100644 --- a/test/ublas_interop/test4.hpp +++ b/test/ublas_interop/test4.hpp @@ -19,7 +19,11 @@ #include +#ifdef TEST_ET +typedef boost::multiprecision::number, boost::multiprecision::et_on> mp_test_type; +#else typedef boost::multiprecision::number, boost::multiprecision::et_off> mp_test_type; +#endif //typedef double mp_test_type; #define USE_RANGE diff --git a/test/ublas_interop/test5.hpp b/test/ublas_interop/test5.hpp index dc345198..a5654db9 100644 --- a/test/ublas_interop/test5.hpp +++ b/test/ublas_interop/test5.hpp @@ -19,7 +19,11 @@ #include +#ifdef TEST_ET +typedef boost::multiprecision::number, boost::multiprecision::et_on> mp_test_type; +#else typedef boost::multiprecision::number, boost::multiprecision::et_off> mp_test_type; +#endif //typedef double mp_test_type; #define USE_RANGE diff --git a/test/ublas_interop/test6.hpp b/test/ublas_interop/test6.hpp index 766d6b92..5d568fc8 100644 --- a/test/ublas_interop/test6.hpp +++ b/test/ublas_interop/test6.hpp @@ -13,6 +13,36 @@ #ifndef TEST6_H #define TEST6_H +#ifdef _MSC_VER +# pragma warning(disable:4800 4996) +#endif + +#include + +#ifdef TEST_ET +typedef boost::multiprecision::number, boost::multiprecision::et_on> mp_test_type; +#else +typedef boost::multiprecision::number, boost::multiprecision::et_off> mp_test_type; +#endif +//typedef double mp_test_type; + +#define USE_RANGE +#define USE_SLICE +#define USE_FLOAT +#define USE_UNBOUNDED_ARRAY +#define USE_BOUNDED_ARRAY +#define USE_STD_VECTOR +#define USE_BOUNDED_VECTOR USE_MATRIX +#define USE_UNBOUNDED_ARRAY +#define USE_MAP_ARRAY +#define USE_STD_MAP +#define USE_MAPPED_VECTOR +#define USE_COMPRESSED_VECTOR +#define USE_COORDINATE_VECTOR +#define USE_MAPPED_MATRIX +#define USE_COMPRESSED_MATRIX +#define USE_COORDINATE_MATRIX + #include #include diff --git a/test/ublas_interop/test7.hpp b/test/ublas_interop/test7.hpp index ad990859..65325a26 100644 --- a/test/ublas_interop/test7.hpp +++ b/test/ublas_interop/test7.hpp @@ -19,13 +19,18 @@ #include +#ifdef TEST_ET +typedef boost::multiprecision::number, boost::multiprecision::et_on> mp_test_type; +#else typedef boost::multiprecision::number, boost::multiprecision::et_off> mp_test_type; +#endif //typedef double mp_test_type; #define USE_RANGE #define USE_SLICE #define USE_FLOAT -#define USE_UNBOUNDED_ARRAY +#define USE_UNBOUNDED_ARRAY +#define USE_BOUNDED_ARRAY #define USE_STD_VECTOR #define USE_BOUNDED_VECTOR USE_MATRIX #define USE_UNBOUNDED_ARRAY diff --git a/test/ublas_interop/test71.cpp b/test/ublas_interop/test71.cpp index 4639b139..5fc6c2b0 100644 --- a/test/ublas_interop/test71.cpp +++ b/test/ublas_interop/test71.cpp @@ -9,6 +9,10 @@ // GeNeSys mbH & Co. KG in producing this work. // +// +// This file fails to compile - appears to be a known uBlas issue :-( +// + #include "test7.hpp" // Test vector expression templates