public:
typedef complex<T> this_type;
- complex(const T& r = 0,const T& i = 0) : r_(r),i_(i) { }
- complex(const this_type& source) : r_(source.r_),i_(source.i_) { }
+ constexpr complex(const T& r = 0,const T& i = 0) : r_(r),i_(i) { }
+ constexpr complex(const this_type& source) : r_(source.r_),i_(source.i_) { }
- this_type& operator=(const this_type& source)
+ constexpr this_type& operator=(const this_type& source)
{
if (this == &source) return *this;
return *this;
}
- T& real() { return r_; }
- T& imag() { return i_; }
+ constexpr T& real() { return r_; }
+ constexpr T& imag() { return i_; }
- const T& real() const { return r_; }
- const T& imag() const { return i_; }
+ constexpr const T& real() const { return r_; }
+ constexpr const T& imag() const { return i_; }
- this_type& operator+=(const T& val)
+ constexpr this_type& operator+=(const T& val)
{
r_ += val;
return *this;
}
- this_type& operator-=(const T& val)
+ constexpr this_type& operator-=(const T& val)
{
r_ -= val;
return *this;
}
- this_type& operator*=(const T& val)
+ constexpr this_type& operator*=(const T& val)
{
r_ *= val;
i_ *= val;
return *this;
}
- this_type& operator/=(const T& val)
+ constexpr this_type& operator/=(const T& val)
{
r_ /= val;
i_ /= val;
return *this;
}
- this_type& operator+=(const this_type& source)
+ constexpr this_type& operator+=(const this_type& source)
{
r_ += source.r_;
i_ += source.i_;
return *this;
}
- this_type& operator-=(const this_type& source)
+ constexpr this_type& operator-=(const this_type& source)
{
r_ -= source.r_;
i_ -= source.i_;
return *this;
}
- this_type& operator*=(const this_type& source)
+ constexpr this_type& operator*=(const this_type& source)
{
*this = *this * source;
return *this;
}
- this_type& operator/=(const this_type& source)
+ constexpr this_type& operator/=(const this_type& source)
{
*this = *this / source;
return *this;
namespace units {
template<class X>
+constexpr
complex<typename unary_plus_typeof_helper<X>::type>
operator+(const complex<X>& x)
{
}
template<class X>
+constexpr
complex<typename unary_minus_typeof_helper<X>::type>
operator-(const complex<X>& x)
{
}
template<class X,class Y>
+constexpr
complex<typename add_typeof_helper<X,Y>::type>
operator+(const complex<X>& x,const complex<Y>& y)
{
}
template<class X,class Y>
+constexpr
complex<typename boost::units::subtract_typeof_helper<X,Y>::type>
operator-(const complex<X>& x,const complex<Y>& y)
{
}
template<class X,class Y>
+constexpr
complex<typename boost::units::multiply_typeof_helper<X,Y>::type>
operator*(const complex<X>& x,const complex<Y>& y)
{
}
template<class X,class Y>
+constexpr
complex<typename boost::units::divide_typeof_helper<X,Y>::type>
operator/(const complex<X>& x,const complex<Y>& y)
{
int main(void)
{
- using namespace boost::math;
using namespace boost::units;
using namespace boost::units::test;
//[complex_snippet_1
typedef quantity<length,complex<double> > length_dimension;
- length_dimension L(complex<double>(2.0,1.0)*meters);
+ const length_dimension L(complex<double>(2.0,1.0)*meters);
//]
std::cout << "+L = " << +L << std::endl
//[complex_snippet_2
typedef complex<quantity<length> > length_dimension;
- length_dimension L(2.0*meters,1.0*meters);
+ const length_dimension L(2.0*meters,1.0*meters);
//]
std::cout << "+L = " << +L << std::endl