diff --git a/include/boost/math/octonion.hpp b/include/boost/math/octonion.hpp index fba9aff27..1fc1c43d4 100644 --- a/include/boost/math/octonion.hpp +++ b/include/boost/math/octonion.hpp @@ -20,89 +20,89 @@ namespace boost { #define BOOST_OCTONION_ACCESSOR_GENERATOR(type) \ - type real() const \ + BOOST_CONSTEXPR type real() const \ { \ return(a); \ } \ \ - octonion unreal() const \ + BOOST_CONSTEXPR octonion unreal() const \ { \ return( octonion(static_cast(0),b,c,d,e,f,g,h)); \ } \ \ - type R_component_1() const \ + BOOST_CONSTEXPR type R_component_1() const \ { \ return(a); \ } \ \ - type R_component_2() const \ + BOOST_CONSTEXPR type R_component_2() const \ { \ return(b); \ } \ \ - type R_component_3() const \ + BOOST_CONSTEXPR type R_component_3() const \ { \ return(c); \ } \ \ - type R_component_4() const \ + BOOST_CONSTEXPR type R_component_4() const \ { \ return(d); \ } \ \ - type R_component_5() const \ + BOOST_CONSTEXPR type R_component_5() const \ { \ return(e); \ } \ \ - type R_component_6() const \ + BOOST_CONSTEXPR type R_component_6() const \ { \ return(f); \ } \ \ - type R_component_7() const \ + BOOST_CONSTEXPR type R_component_7() const \ { \ return(g); \ } \ \ - type R_component_8() const \ + BOOST_CONSTEXPR type R_component_8() const \ { \ return(h); \ } \ \ - ::std::complex C_component_1() const \ + BOOST_CONSTEXPR ::std::complex C_component_1() const \ { \ return(::std::complex(a,b)); \ } \ \ - ::std::complex C_component_2() const \ + BOOST_CONSTEXPR ::std::complex C_component_2() const \ { \ return(::std::complex(c,d)); \ } \ \ - ::std::complex C_component_3() const \ + BOOST_CONSTEXPR ::std::complex C_component_3() const \ { \ return(::std::complex(e,f)); \ } \ \ - ::std::complex C_component_4() const \ + BOOST_CONSTEXPR ::std::complex C_component_4() const \ { \ return(::std::complex(g,h)); \ } \ \ - ::boost::math::quaternion H_component_1() const \ + BOOST_CONSTEXPR ::boost::math::quaternion H_component_1() const \ { \ return(::boost::math::quaternion(a,b,c,d)); \ } \ \ - ::boost::math::quaternion H_component_2() const \ + BOOST_CONSTEXPR ::boost::math::quaternion H_component_2() const \ { \ return(::boost::math::quaternion(e,f,g,h)); \ } #define BOOST_OCTONION_MEMBER_ASSIGNMENT_GENERATOR(type) \ - template \ + template BOOST_CXX14_CONSTEXPR \ octonion & operator = (octonion const & a_affecter) \ { \ a = static_cast(a_affecter.R_component_1()); \ @@ -117,6 +117,7 @@ namespace boost return(*this); \ } \ \ + BOOST_CXX14_CONSTEXPR \ octonion & operator = (octonion const & a_affecter) \ { \ a = a_affecter.a; \ @@ -131,6 +132,7 @@ namespace boost return(*this); \ } \ \ + BOOST_CXX14_CONSTEXPR \ octonion & operator = (type const & a_affecter) \ { \ a = a_affecter; \ @@ -140,6 +142,7 @@ namespace boost return(*this); \ } \ \ + BOOST_CXX14_CONSTEXPR \ octonion & operator = (::std::complex const & a_affecter) \ { \ a = a_affecter.real(); \ @@ -150,6 +153,7 @@ namespace boost return(*this); \ } \ \ + BOOST_CXX14_CONSTEXPR \ octonion & operator = (::boost::math::quaternion const & a_affecter) \ { \ a = a_affecter.R_component_1(); \ @@ -184,7 +188,7 @@ namespace boost // constructor for O seen as R^8 // (also default constructor) - explicit octonion( T const & requested_a = T(), + explicit BOOST_CONSTEXPR octonion( T const & requested_a = T(), T const & requested_b = T(), T const & requested_c = T(), T const & requested_d = T(), @@ -207,7 +211,7 @@ namespace boost // constructor for H seen as C^4 - explicit octonion( ::std::complex const & z0, + explicit BOOST_CONSTEXPR octonion( ::std::complex const & z0, ::std::complex const & z1 = ::std::complex(), ::std::complex const & z2 = ::std::complex(), ::std::complex const & z3 = ::std::complex()) @@ -226,7 +230,7 @@ namespace boost // constructor for O seen as H^2 - explicit octonion( ::boost::math::quaternion const & q0, + explicit BOOST_CONSTEXPR octonion( ::boost::math::quaternion const & q0, ::boost::math::quaternion const & q1 = ::boost::math::quaternion()) : a(q0.R_component_1()), b(q0.R_component_2()), @@ -248,7 +252,7 @@ namespace boost // templated copy constructor template - explicit octonion(octonion const & a_recopier) + explicit BOOST_CONSTEXPR octonion(octonion const & a_recopier) : a(static_cast(a_recopier.R_component_1())), b(static_cast(a_recopier.R_component_2())), c(static_cast(a_recopier.R_component_3())), @@ -288,6 +292,7 @@ namespace boost // and "q /= rhs;" means "q = q * inverse_of(rhs);"; // octonion multiplication is also *NOT* associative + BOOST_CXX14_CONSTEXPR octonion & operator += (T const & rhs) { T at = a + rhs; // exception guard @@ -298,6 +303,7 @@ namespace boost } + BOOST_CXX14_CONSTEXPR octonion & operator += (::std::complex const & rhs) { T at = a + rhs.real(); // exception guard @@ -310,6 +316,7 @@ namespace boost } + BOOST_CXX14_CONSTEXPR octonion & operator += (::boost::math::quaternion const & rhs) { T at = a + rhs.R_component_1(); // exception guard @@ -326,7 +333,7 @@ namespace boost } - template + template BOOST_CXX14_CONSTEXPR octonion & operator += (octonion const & rhs) { T at = a + static_cast(rhs.R_component_1()); // exception guard @@ -352,6 +359,7 @@ namespace boost + BOOST_CXX14_CONSTEXPR octonion & operator -= (T const & rhs) { T at = a - rhs; // exception guard @@ -362,6 +370,7 @@ namespace boost } + BOOST_CXX14_CONSTEXPR octonion & operator -= (::std::complex const & rhs) { T at = a - rhs.real(); // exception guard @@ -374,6 +383,7 @@ namespace boost } + BOOST_CXX14_CONSTEXPR octonion & operator -= (::boost::math::quaternion const & rhs) { T at = a - rhs.R_component_1(); // exception guard @@ -390,7 +400,7 @@ namespace boost } - template + template BOOST_CXX14_CONSTEXPR octonion & operator -= (octonion const & rhs) { T at = a - static_cast(rhs.R_component_1()); // exception guard @@ -415,6 +425,7 @@ namespace boost } + BOOST_CXX14_CONSTEXPR octonion & operator *= (T const & rhs) { T at = a * rhs; // exception guard @@ -439,6 +450,7 @@ namespace boost } + BOOST_CXX14_CONSTEXPR octonion & operator *= (::std::complex const & rhs) { T ar = rhs.real(); @@ -466,6 +478,7 @@ namespace boost } + BOOST_CXX14_CONSTEXPR octonion & operator *= (::boost::math::quaternion const & rhs) { T ar = rhs.R_component_1(); @@ -495,7 +508,7 @@ namespace boost } - template + template BOOST_CXX14_CONSTEXPR octonion & operator *= (octonion const & rhs) { T ar = static_cast(rhs.R_component_1()); @@ -529,6 +542,7 @@ namespace boost } + BOOST_CXX14_CONSTEXPR octonion & operator /= (T const & rhs) { T at = a / rhs; // exception guard @@ -553,6 +567,7 @@ namespace boost } + BOOST_CXX14_CONSTEXPR octonion & operator /= (::std::complex const & rhs) { T ar = rhs.real(); @@ -582,6 +597,7 @@ namespace boost } + BOOST_CXX14_CONSTEXPR octonion & operator /= (::boost::math::quaternion const & rhs) { T ar = rhs.R_component_1(); @@ -613,7 +629,7 @@ namespace boost } - template + template BOOST_CXX14_CONSTEXPR octonion & operator /= (octonion const & rhs) { T ar = static_cast(rhs.R_component_1()); @@ -682,7 +698,7 @@ namespace boost #define BOOST_OCTONION_CONSTRUCTOR_GENERATOR(type) \ - explicit octonion( type const & requested_a = static_cast(0), \ + explicit BOOST_CONSTEXPR octonion( type const & requested_a = static_cast(0), \ type const & requested_b = static_cast(0), \ type const & requested_c = static_cast(0), \ type const & requested_d = static_cast(0), \ @@ -701,7 +717,7 @@ namespace boost { \ } \ \ - explicit octonion( ::std::complex const & z0, \ + explicit BOOST_CONSTEXPR octonion( ::std::complex const & z0, \ ::std::complex const & z1 = ::std::complex(), \ ::std::complex const & z2 = ::std::complex(), \ ::std::complex const & z3 = ::std::complex()) \ @@ -716,7 +732,7 @@ namespace boost { \ } \ \ - explicit octonion( ::boost::math::quaternion const & q0, \ + explicit BOOST_CONSTEXPR octonion( ::boost::math::quaternion const & q0, \ ::boost::math::quaternion const & q1 = ::boost::math::quaternion()) \ : a(q0.R_component_1()), \ b(q0.R_component_2()), \ @@ -731,6 +747,7 @@ namespace boost #define BOOST_OCTONION_MEMBER_ADD_GENERATOR_1(type) \ + BOOST_CXX14_CONSTEXPR \ octonion & operator += (type const & rhs) \ { \ a += rhs; \ @@ -739,6 +756,7 @@ namespace boost } #define BOOST_OCTONION_MEMBER_ADD_GENERATOR_2(type) \ + BOOST_CXX14_CONSTEXPR \ octonion & operator += (::std::complex const & rhs) \ { \ a += rhs.real(); \ @@ -748,6 +766,7 @@ namespace boost } #define BOOST_OCTONION_MEMBER_ADD_GENERATOR_3(type) \ + BOOST_CXX14_CONSTEXPR \ octonion & operator += (::boost::math::quaternion const & rhs) \ { \ a += rhs.R_component_1(); \ @@ -759,7 +778,7 @@ namespace boost } #define BOOST_OCTONION_MEMBER_ADD_GENERATOR_4(type) \ - template \ + template BOOST_CXX14_CONSTEXPR \ octonion & operator += (octonion const & rhs) \ { \ a += static_cast(rhs.R_component_1()); \ @@ -775,6 +794,7 @@ namespace boost } #define BOOST_OCTONION_MEMBER_SUB_GENERATOR_1(type) \ + BOOST_CXX14_CONSTEXPR \ octonion & operator -= (type const & rhs) \ { \ a -= rhs; \ @@ -783,6 +803,7 @@ namespace boost } #define BOOST_OCTONION_MEMBER_SUB_GENERATOR_2(type) \ + BOOST_CXX14_CONSTEXPR \ octonion & operator -= (::std::complex const & rhs) \ { \ a -= rhs.real(); \ @@ -792,6 +813,7 @@ namespace boost } #define BOOST_OCTONION_MEMBER_SUB_GENERATOR_3(type) \ + BOOST_CXX14_CONSTEXPR \ octonion & operator -= (::boost::math::quaternion const & rhs) \ { \ a -= rhs.R_component_1(); \ @@ -803,7 +825,7 @@ namespace boost } #define BOOST_OCTONION_MEMBER_SUB_GENERATOR_4(type) \ - template \ + template BOOST_CXX14_CONSTEXPR \ octonion & operator -= (octonion const & rhs) \ { \ a -= static_cast(rhs.R_component_1()); \ @@ -819,6 +841,7 @@ namespace boost } #define BOOST_OCTONION_MEMBER_MUL_GENERATOR_1(type) \ + BOOST_CXX14_CONSTEXPR \ octonion & operator *= (type const & rhs) \ { \ a *= rhs; \ @@ -834,6 +857,7 @@ namespace boost } #define BOOST_OCTONION_MEMBER_MUL_GENERATOR_2(type) \ + BOOST_CXX14_CONSTEXPR \ octonion & operator *= (::std::complex const & rhs) \ { \ type ar = rhs.real(); \ @@ -860,7 +884,8 @@ namespace boost return(*this); \ } -#define BOOST_OCTONION_MEMBER_MUL_GENERATOR_3(type) \ +#define BOOST_OCTONION_MEMBER_MUL_GENERATOR_3(type) \ + BOOST_CXX14_CONSTEXPR \ octonion & operator *= (::boost::math::quaternion const & rhs) \ { \ type ar = rhs.R_component_1(); \ @@ -890,7 +915,7 @@ namespace boost } #define BOOST_OCTONION_MEMBER_MUL_GENERATOR_4(type) \ - template \ + template BOOST_CXX14_CONSTEXPR \ octonion & operator *= (octonion const & rhs) \ { \ type ar = static_cast(rhs.R_component_1()); \ @@ -931,6 +956,7 @@ namespace boost // (painfully) explicit. #define BOOST_OCTONION_MEMBER_DIV_GENERATOR_1(type) \ + BOOST_CXX14_CONSTEXPR \ octonion & operator /= (type const & rhs) \ { \ a /= rhs; \ @@ -1258,7 +1284,7 @@ namespace boost // UNtemplated copy constructor // (this is taken care of by the compiler itself) - // explicit copy constructors (precision-loosing converters) + // explicit copy constructors (precision-losing converters) explicit octonion(octonion const & a_recopier) { @@ -1327,7 +1353,7 @@ namespace boost *this = detail::octonion_type_converter(a_recopier); } - // explicit copy constructors (precision-loosing converters) + // explicit copy constructors (precision-losing converters) explicit octonion(octonion const & a_recopier) { @@ -1480,37 +1506,37 @@ namespace boost } #define BOOST_OCTONION_OPERATOR_GENERATOR_1_L(op) \ - template \ + template BOOST_CXX14_CONSTEXPR \ inline octonion operator op (T const & lhs, octonion const & rhs) \ BOOST_OCTONION_OPERATOR_GENERATOR_BODY(op) #define BOOST_OCTONION_OPERATOR_GENERATOR_1_R(op) \ - template \ + template BOOST_CXX14_CONSTEXPR \ inline octonion operator op (octonion const & lhs, T const & rhs) \ BOOST_OCTONION_OPERATOR_GENERATOR_BODY(op) #define BOOST_OCTONION_OPERATOR_GENERATOR_2_L(op) \ - template \ + template BOOST_CXX14_CONSTEXPR \ inline octonion operator op (::std::complex const & lhs, octonion const & rhs) \ BOOST_OCTONION_OPERATOR_GENERATOR_BODY(op) #define BOOST_OCTONION_OPERATOR_GENERATOR_2_R(op) \ - template \ + template BOOST_CXX14_CONSTEXPR \ inline octonion operator op (octonion const & lhs, ::std::complex const & rhs) \ BOOST_OCTONION_OPERATOR_GENERATOR_BODY(op) #define BOOST_OCTONION_OPERATOR_GENERATOR_3_L(op) \ - template \ + template BOOST_CXX14_CONSTEXPR \ inline octonion operator op (::boost::math::quaternion const & lhs, octonion const & rhs) \ BOOST_OCTONION_OPERATOR_GENERATOR_BODY(op) #define BOOST_OCTONION_OPERATOR_GENERATOR_3_R(op) \ - template \ + template BOOST_CXX14_CONSTEXPR \ inline octonion operator op (octonion const & lhs, ::boost::math::quaternion const & rhs) \ BOOST_OCTONION_OPERATOR_GENERATOR_BODY(op) #define BOOST_OCTONION_OPERATOR_GENERATOR_4(op) \ - template \ + template BOOST_CXX14_CONSTEXPR \ inline octonion operator op (octonion const & lhs, octonion const & rhs) \ BOOST_OCTONION_OPERATOR_GENERATOR_BODY(op) @@ -1543,21 +1569,21 @@ namespace boost #undef BOOST_OCTONION_OPERATOR_GENERATOR_BODY - template + template BOOST_CONSTEXPR inline octonion operator + (octonion const & o) { return(o); } - template + template BOOST_CONSTEXPR inline octonion operator - (octonion const & o) { return(octonion(-o.R_component_1(),-o.R_component_2(),-o.R_component_3(),-o.R_component_4(),-o.R_component_5(),-o.R_component_6(),-o.R_component_7(),-o.R_component_8())); } - template + template BOOST_CONSTEXPR inline bool operator == (T const & lhs, octonion const & rhs) { return( @@ -1573,7 +1599,7 @@ namespace boost } - template + template BOOST_CONSTEXPR inline bool operator == (octonion const & lhs, T const & rhs) { return( @@ -1589,7 +1615,7 @@ namespace boost } - template + template BOOST_CONSTEXPR inline bool operator == (::std::complex const & lhs, octonion const & rhs) { return( @@ -1605,7 +1631,7 @@ namespace boost } - template + template BOOST_CONSTEXPR inline bool operator == (octonion const & lhs, ::std::complex const & rhs) { return( @@ -1621,7 +1647,7 @@ namespace boost } - template + template BOOST_CONSTEXPR inline bool operator == (::boost::math::quaternion const & lhs, octonion const & rhs) { return( @@ -1637,7 +1663,7 @@ namespace boost } - template + template BOOST_CONSTEXPR inline bool operator == (octonion const & lhs, ::boost::math::quaternion const & rhs) { return( @@ -1653,7 +1679,7 @@ namespace boost } - template + template BOOST_CONSTEXPR inline bool operator == (octonion const & lhs, octonion const & rhs) { return( @@ -1674,31 +1700,31 @@ namespace boost return(!(lhs == rhs)); \ } - template + template BOOST_CONSTEXPR inline bool operator != (T const & lhs, octonion const & rhs) BOOST_OCTONION_NOT_EQUAL_GENERATOR - template + template BOOST_CONSTEXPR inline bool operator != (octonion const & lhs, T const & rhs) BOOST_OCTONION_NOT_EQUAL_GENERATOR - template + template BOOST_CONSTEXPR inline bool operator != (::std::complex const & lhs, octonion const & rhs) BOOST_OCTONION_NOT_EQUAL_GENERATOR - template + template BOOST_CONSTEXPR inline bool operator != (octonion const & lhs, ::std::complex const & rhs) BOOST_OCTONION_NOT_EQUAL_GENERATOR - template + template BOOST_CONSTEXPR inline bool operator != (::boost::math::quaternion const & lhs, octonion const & rhs) BOOST_OCTONION_NOT_EQUAL_GENERATOR - template + template BOOST_CONSTEXPR inline bool operator != (octonion const & lhs, ::boost::math::quaternion const & rhs) BOOST_OCTONION_NOT_EQUAL_GENERATOR - template + template BOOST_CONSTEXPR inline bool operator != (octonion const & lhs, octonion const & rhs) BOOST_OCTONION_NOT_EQUAL_GENERATOR @@ -3880,14 +3906,14 @@ namespace boost // values - template + template BOOST_CONSTEXPR inline T real(octonion const & o) { return(o.real()); } - template + template BOOST_CONSTEXPR inline octonion unreal(octonion const & o) { return(o.unreal()); @@ -3972,14 +3998,14 @@ namespace boost // Note: This is the Cayley norm, not the Euclidian norm... - template + template BOOST_CXX14_CONSTEXPR inline T norm(octonion const & o) { return(real(o*conj(o))); } - template + template BOOST_CONSTEXPR inline octonion conj(octonion const & o) { return(octonion( +o.R_component_1(), @@ -4190,7 +4216,7 @@ namespace boost } - template + template BOOST_CXX14_CONSTEXPR octonion pow(octonion const & o, int n) { diff --git a/include/boost/math/quaternion.hpp b/include/boost/math/quaternion.hpp index d816a767c..560fd32aa 100644 --- a/include/boost/math/quaternion.hpp +++ b/include/boost/math/quaternion.hpp @@ -35,49 +35,49 @@ namespace boost { #define BOOST_QUATERNION_ACCESSOR_GENERATOR(type) \ - type real() const \ + BOOST_CONSTEXPR type real() const \ { \ return(a); \ } \ \ - quaternion unreal() const \ + BOOST_CONSTEXPR quaternion unreal() const \ { \ return(quaternion(static_cast(0),b,c,d)); \ } \ \ - type R_component_1() const \ + BOOST_CONSTEXPR type R_component_1() const \ { \ return(a); \ } \ \ - type R_component_2() const \ + BOOST_CONSTEXPR type R_component_2() const \ { \ return(b); \ } \ \ - type R_component_3() const \ + BOOST_CONSTEXPR type R_component_3() const \ { \ return(c); \ } \ \ - type R_component_4() const \ + BOOST_CONSTEXPR type R_component_4() const \ { \ return(d); \ } \ \ - ::std::complex C_component_1() const \ + BOOST_CONSTEXPR ::std::complex C_component_1() const \ { \ return(::std::complex(a,b)); \ } \ \ - ::std::complex C_component_2() const \ + BOOST_CONSTEXPR ::std::complex C_component_2() const \ { \ return(::std::complex(c,d)); \ } #define BOOST_QUATERNION_MEMBER_ASSIGNMENT_GENERATOR(type) \ - template \ + template BOOST_CXX14_CONSTEXPR \ quaternion & operator = (quaternion const & a_affecter) \ { \ a = static_cast(a_affecter.R_component_1()); \ @@ -88,6 +88,7 @@ namespace boost return(*this); \ } \ \ + BOOST_CXX14_CONSTEXPR \ quaternion & operator = (quaternion const & a_affecter) \ { \ a = a_affecter.a; \ @@ -98,6 +99,7 @@ namespace boost return(*this); \ } \ \ + BOOST_CXX14_CONSTEXPR \ quaternion & operator = (type const & a_affecter) \ { \ a = a_affecter; \ @@ -107,6 +109,7 @@ namespace boost return(*this); \ } \ \ + BOOST_CXX14_CONSTEXPR \ quaternion & operator = (::std::complex const & a_affecter) \ { \ a = a_affecter.real(); \ @@ -136,10 +139,10 @@ namespace boost // constructor for H seen as R^4 // (also default constructor) - explicit quaternion( T const & requested_a = T(), - T const & requested_b = T(), - T const & requested_c = T(), - T const & requested_d = T()) + explicit BOOST_CONSTEXPR quaternion( T const & requested_a = T(), + T const & requested_b = T(), + T const & requested_c = T(), + T const & requested_d = T()) : a(requested_a), b(requested_b), c(requested_c), @@ -151,8 +154,8 @@ namespace boost // constructor for H seen as C^2 - explicit quaternion( ::std::complex const & z0, - ::std::complex const & z1 = ::std::complex()) + explicit BOOST_CONSTEXPR quaternion( ::std::complex const & z0, + ::std::complex const & z1 = ::std::complex()) : a(z0.real()), b(z0.imag()), c(z1.real()), @@ -169,7 +172,7 @@ namespace boost // templated copy constructor template - explicit quaternion(quaternion const & a_recopier) + explicit BOOST_CONSTEXPR quaternion(quaternion const & a_recopier) : a(static_cast(a_recopier.R_component_1())), b(static_cast(a_recopier.R_component_2())), c(static_cast(a_recopier.R_component_3())), @@ -204,6 +207,7 @@ namespace boost // symbolically, "q *= rhs;" means "q = q * rhs;" // and "q /= rhs;" means "q = q * inverse_of(rhs);" + BOOST_CXX14_CONSTEXPR quaternion & operator += (T const & rhs) { T at = a + rhs; // exception guard @@ -214,6 +218,7 @@ namespace boost } + BOOST_CXX14_CONSTEXPR quaternion & operator += (::std::complex const & rhs) { T at = a + rhs.real(); // exception guard @@ -226,7 +231,7 @@ namespace boost } - template + template BOOST_CXX14_CONSTEXPR quaternion & operator += (quaternion const & rhs) { T at = a + static_cast(rhs.R_component_1()); // exception guard @@ -244,6 +249,7 @@ namespace boost + BOOST_CXX14_CONSTEXPR quaternion & operator -= (T const & rhs) { T at = a - rhs; // exception guard @@ -254,6 +260,7 @@ namespace boost } + BOOST_CXX14_CONSTEXPR quaternion & operator -= (::std::complex const & rhs) { T at = a - rhs.real(); // exception guard @@ -266,7 +273,7 @@ namespace boost } - template + template BOOST_CXX14_CONSTEXPR quaternion & operator -= (quaternion const & rhs) { T at = a - static_cast(rhs.R_component_1()); // exception guard @@ -283,6 +290,8 @@ namespace boost } + + BOOST_CXX14_CONSTEXPR quaternion & operator *= (T const & rhs) { T at = a * rhs; // exception guard @@ -299,6 +308,7 @@ namespace boost } + BOOST_CXX14_CONSTEXPR quaternion & operator *= (::std::complex const & rhs) { T ar = rhs.real(); @@ -318,7 +328,7 @@ namespace boost } - template + template BOOST_CXX14_CONSTEXPR quaternion & operator *= (quaternion const & rhs) { T ar = static_cast(rhs.R_component_1()); @@ -341,6 +351,7 @@ namespace boost + BOOST_CXX14_CONSTEXPR quaternion & operator /= (T const & rhs) { T at = a / rhs; // exception guard @@ -357,6 +368,7 @@ namespace boost } + BOOST_CXX14_CONSTEXPR quaternion & operator /= (::std::complex const & rhs) { T ar = rhs.real(); @@ -378,7 +390,7 @@ namespace boost } - template + template BOOST_CXX14_CONSTEXPR quaternion & operator /= (quaternion const & rhs) { T ar = static_cast(rhs.R_component_1()); @@ -434,29 +446,30 @@ namespace boost // implementation of quaternion specialization -#define BOOST_QUATERNION_CONSTRUCTOR_GENERATOR(type) \ - explicit quaternion( type const & requested_a = static_cast(0), \ - type const & requested_b = static_cast(0), \ - type const & requested_c = static_cast(0), \ - type const & requested_d = static_cast(0)) \ - : a(requested_a), \ - b(requested_b), \ - c(requested_c), \ - d(requested_d) \ - { \ - } \ - \ - explicit quaternion( ::std::complex const & z0, \ - ::std::complex const & z1 = ::std::complex()) \ - : a(z0.real()), \ - b(z0.imag()), \ - c(z1.real()), \ - d(z1.imag()) \ - { \ +#define BOOST_QUATERNION_CONSTRUCTOR_GENERATOR(type) \ + explicit BOOST_CONSTEXPR quaternion( type const & requested_a = static_cast(0), \ + type const & requested_b = static_cast(0), \ + type const & requested_c = static_cast(0), \ + type const & requested_d = static_cast(0)) \ + : a(requested_a), \ + b(requested_b), \ + c(requested_c), \ + d(requested_d) \ + { \ + } \ + \ + explicit BOOST_CONSTEXPR quaternion( ::std::complex const & z0, \ + ::std::complex const & z1 = ::std::complex()) \ + : a(z0.real()), \ + b(z0.imag()), \ + c(z1.real()), \ + d(z1.imag()) \ + { \ } #define BOOST_QUATERNION_MEMBER_ADD_GENERATOR_1(type) \ + BOOST_CXX14_CONSTEXPR \ quaternion & operator += (type const & rhs) \ { \ a += rhs; \ @@ -465,6 +478,7 @@ namespace boost } #define BOOST_QUATERNION_MEMBER_ADD_GENERATOR_2(type) \ + BOOST_CXX14_CONSTEXPR \ quaternion & operator += (::std::complex const & rhs) \ { \ a += rhs.real(); \ @@ -474,7 +488,7 @@ namespace boost } #define BOOST_QUATERNION_MEMBER_ADD_GENERATOR_3(type) \ - template \ + template BOOST_CXX14_CONSTEXPR \ quaternion & operator += (quaternion const & rhs) \ { \ a += static_cast(rhs.R_component_1()); \ @@ -486,6 +500,7 @@ namespace boost } #define BOOST_QUATERNION_MEMBER_SUB_GENERATOR_1(type) \ + BOOST_CXX14_CONSTEXPR \ quaternion & operator -= (type const & rhs) \ { \ a -= rhs; \ @@ -494,6 +509,7 @@ namespace boost } #define BOOST_QUATERNION_MEMBER_SUB_GENERATOR_2(type) \ + BOOST_CXX14_CONSTEXPR \ quaternion & operator -= (::std::complex const & rhs) \ { \ a -= rhs.real(); \ @@ -503,7 +519,7 @@ namespace boost } #define BOOST_QUATERNION_MEMBER_SUB_GENERATOR_3(type) \ - template \ + template BOOST_CXX14_CONSTEXPR \ quaternion & operator -= (quaternion const & rhs) \ { \ a -= static_cast(rhs.R_component_1()); \ @@ -515,6 +531,7 @@ namespace boost } #define BOOST_QUATERNION_MEMBER_MUL_GENERATOR_1(type) \ + BOOST_CXX14_CONSTEXPR \ quaternion & operator *= (type const & rhs) \ { \ a *= rhs; \ @@ -526,6 +543,7 @@ namespace boost } #define BOOST_QUATERNION_MEMBER_MUL_GENERATOR_2(type) \ + BOOST_CXX14_CONSTEXPR \ quaternion & operator *= (::std::complex const & rhs) \ { \ type ar = rhs.real(); \ @@ -545,7 +563,7 @@ namespace boost } #define BOOST_QUATERNION_MEMBER_MUL_GENERATOR_3(type) \ - template \ + template BOOST_CXX14_CONSTEXPR \ quaternion & operator *= (quaternion const & rhs) \ { \ type ar = static_cast(rhs.R_component_1()); \ @@ -574,6 +592,7 @@ namespace boost // (painfully) explicit. #define BOOST_QUATERNION_MEMBER_DIV_GENERATOR_1(type) \ + BOOST_CXX14_CONSTEXPR \ quaternion & operator /= (type const & rhs) \ { \ a /= rhs; \ @@ -767,7 +786,7 @@ namespace boost // UNtemplated copy constructor // (this is taken care of by the compiler itself) - // explicit copy constructors (precision-loosing converters) + // explicit copy constructors (precision-losing converters) explicit quaternion(quaternion const & a_recopier) { @@ -835,7 +854,7 @@ namespace boost *this = detail::quaternion_type_converter(a_recopier); } - // explicit copy constructors (precision-loosing converters) + // explicit copy constructors (precision-losing converters) explicit quaternion(quaternion const & a_recopier) { @@ -978,27 +997,27 @@ namespace boost } #define BOOST_QUATERNION_OPERATOR_GENERATOR_1_L(op) \ - template \ + template BOOST_CXX14_CONSTEXPR \ inline quaternion operator op (T const & lhs, quaternion const & rhs) \ BOOST_QUATERNION_OPERATOR_GENERATOR_BODY(op) #define BOOST_QUATERNION_OPERATOR_GENERATOR_1_R(op) \ - template \ + template BOOST_CXX14_CONSTEXPR \ inline quaternion operator op (quaternion const & lhs, T const & rhs) \ BOOST_QUATERNION_OPERATOR_GENERATOR_BODY(op) #define BOOST_QUATERNION_OPERATOR_GENERATOR_2_L(op) \ - template \ + template BOOST_CXX14_CONSTEXPR \ inline quaternion operator op (::std::complex const & lhs, quaternion const & rhs) \ BOOST_QUATERNION_OPERATOR_GENERATOR_BODY(op) #define BOOST_QUATERNION_OPERATOR_GENERATOR_2_R(op) \ - template \ + template BOOST_CXX14_CONSTEXPR \ inline quaternion operator op (quaternion const & lhs, ::std::complex const & rhs) \ BOOST_QUATERNION_OPERATOR_GENERATOR_BODY(op) #define BOOST_QUATERNION_OPERATOR_GENERATOR_3(op) \ - template \ + template BOOST_CXX14_CONSTEXPR \ inline quaternion operator op (quaternion const & lhs, quaternion const & rhs) \ BOOST_QUATERNION_OPERATOR_GENERATOR_BODY(op) @@ -1027,21 +1046,21 @@ namespace boost #undef BOOST_QUATERNION_OPERATOR_GENERATOR_BODY - template + template BOOST_CONSTEXPR inline quaternion operator + (quaternion const & q) { return(q); } - template + template BOOST_CONSTEXPR inline quaternion operator - (quaternion const & q) { return(quaternion(-q.R_component_1(),-q.R_component_2(),-q.R_component_3(),-q.R_component_4())); } - template + template BOOST_CONSTEXPR inline bool operator == (T const & lhs, quaternion const & rhs) { return ( @@ -1053,7 +1072,7 @@ namespace boost } - template + template BOOST_CONSTEXPR inline bool operator == (quaternion const & lhs, T const & rhs) { return ( @@ -1065,7 +1084,7 @@ namespace boost } - template + template BOOST_CONSTEXPR inline bool operator == (::std::complex const & lhs, quaternion const & rhs) { return ( @@ -1077,7 +1096,7 @@ namespace boost } - template + template BOOST_CONSTEXPR inline bool operator == (quaternion const & lhs, ::std::complex const & rhs) { return ( @@ -1089,7 +1108,7 @@ namespace boost } - template + template BOOST_CONSTEXPR inline bool operator == (quaternion const & lhs, quaternion const & rhs) { return ( @@ -1106,30 +1125,30 @@ namespace boost return(!(lhs == rhs)); \ } - template + template BOOST_CONSTEXPR inline bool operator != (T const & lhs, quaternion const & rhs) BOOST_QUATERNION_NOT_EQUAL_GENERATOR - template + template BOOST_CONSTEXPR inline bool operator != (quaternion const & lhs, T const & rhs) BOOST_QUATERNION_NOT_EQUAL_GENERATOR - template + template BOOST_CONSTEXPR inline bool operator != (::std::complex const & lhs, quaternion const & rhs) BOOST_QUATERNION_NOT_EQUAL_GENERATOR - template + template BOOST_CONSTEXPR inline bool operator != (quaternion const & lhs, ::std::complex const & rhs) BOOST_QUATERNION_NOT_EQUAL_GENERATOR - template + template BOOST_CONSTEXPR inline bool operator != (quaternion const & lhs, quaternion const & rhs) BOOST_QUATERNION_NOT_EQUAL_GENERATOR #undef BOOST_QUATERNION_NOT_EQUAL_GENERATOR - // Note: we allow the following formats, whith a, b, c, and d reals + // Note: we allow the following formats, with a, b, c, and d reals // a // (a), (a,b), (a,b,c), (a,b,c,d) // (a,(c)), (a,(c,d)), ((a)), ((a),c), ((a),(c)), ((a),(c,d)), ((a,b)), ((a,b),c), ((a,b),(c)), ((a,b),(c,d)) @@ -1420,14 +1439,14 @@ namespace boost // values - template + template BOOST_CONSTEXPR inline T real(quaternion const & q) { return(q.real()); } - template + template BOOST_CONSTEXPR inline quaternion unreal(quaternion const & q) { return(q.unreal()); @@ -1508,14 +1527,14 @@ namespace boost // Note: This is the Cayley norm, not the Euclidian norm... - template + template BOOST_CXX14_CONSTEXPR inline T norm(quaternionconst & q) { return(real(q*conj(q))); } - template + template BOOST_CONSTEXPR inline quaternion conj(quaternion const & q) { return(quaternion( +q.R_component_1(), @@ -1717,7 +1736,7 @@ namespace boost } - template + template BOOST_CXX14_CONSTEXPR quaternion pow(quaternion const & q, int n) {