mirror of
https://github.com/boostorg/utility.git
synced 2025-05-09 15:04:00 +00:00
Add constexpr to operators (w/ basic docs, tests)
This commit is contained in:
parent
ce64b13846
commit
e8d2b2ba76
@ -132,34 +132,34 @@ template <typename T> class empty_base {};
|
||||
template <class T, class U, class B = operators_detail::empty_base<T> >
|
||||
struct less_than_comparable2 : B
|
||||
{
|
||||
friend bool operator<=(const T& x, const U& y) { return !static_cast<bool>(x > y); }
|
||||
friend bool operator>=(const T& x, const U& y) { return !static_cast<bool>(x < y); }
|
||||
friend bool operator>(const U& x, const T& y) { return y < x; }
|
||||
friend bool operator<(const U& x, const T& y) { return y > x; }
|
||||
friend bool operator<=(const U& x, const T& y) { return !static_cast<bool>(y < x); }
|
||||
friend bool operator>=(const U& x, const T& y) { return !static_cast<bool>(y > x); }
|
||||
friend BOOST_CONSTEXPR bool operator<=(const T& x, const U& y) { return !static_cast<bool>(x > y); }
|
||||
friend BOOST_CONSTEXPR bool operator>=(const T& x, const U& y) { return !static_cast<bool>(x < y); }
|
||||
friend BOOST_CONSTEXPR bool operator>(const U& x, const T& y) { return y < x; }
|
||||
friend BOOST_CONSTEXPR bool operator<(const U& x, const T& y) { return y > x; }
|
||||
friend BOOST_CONSTEXPR bool operator<=(const U& x, const T& y) { return !static_cast<bool>(y < x); }
|
||||
friend BOOST_CONSTEXPR bool operator>=(const U& x, const T& y) { return !static_cast<bool>(y > x); }
|
||||
};
|
||||
|
||||
template <class T, class B = operators_detail::empty_base<T> >
|
||||
struct less_than_comparable1 : B
|
||||
{
|
||||
friend bool operator>(const T& x, const T& y) { return y < x; }
|
||||
friend bool operator<=(const T& x, const T& y) { return !static_cast<bool>(y < x); }
|
||||
friend bool operator>=(const T& x, const T& y) { return !static_cast<bool>(x < y); }
|
||||
friend BOOST_CONSTEXPR bool operator>(const T& x, const T& y) { return y < x; }
|
||||
friend BOOST_CONSTEXPR bool operator<=(const T& x, const T& y) { return !static_cast<bool>(y < x); }
|
||||
friend BOOST_CONSTEXPR bool operator>=(const T& x, const T& y) { return !static_cast<bool>(x < y); }
|
||||
};
|
||||
|
||||
template <class T, class U, class B = operators_detail::empty_base<T> >
|
||||
struct equality_comparable2 : B
|
||||
{
|
||||
friend bool operator==(const U& y, const T& x) { return x == y; }
|
||||
friend bool operator!=(const U& y, const T& x) { return !static_cast<bool>(x == y); }
|
||||
friend bool operator!=(const T& y, const U& x) { return !static_cast<bool>(y == x); }
|
||||
friend BOOST_CONSTEXPR bool operator==(const U& y, const T& x) { return x == y; }
|
||||
friend BOOST_CONSTEXPR bool operator!=(const U& y, const T& x) { return !static_cast<bool>(x == y); }
|
||||
friend BOOST_CONSTEXPR bool operator!=(const T& y, const U& x) { return !static_cast<bool>(y == x); }
|
||||
};
|
||||
|
||||
template <class T, class B = operators_detail::empty_base<T> >
|
||||
struct equality_comparable1 : B
|
||||
{
|
||||
friend bool operator!=(const T& x, const T& y) { return !static_cast<bool>(x == y); }
|
||||
friend BOOST_CONSTEXPR bool operator!=(const T& x, const T& y) { return !static_cast<bool>(x == y); }
|
||||
};
|
||||
|
||||
// A macro which produces "name_2left" from "name".
|
||||
@ -178,16 +178,16 @@ struct equality_comparable1 : B
|
||||
template <class T, class U, class B = operators_detail::empty_base<T> > \
|
||||
struct NAME##2 : B \
|
||||
{ \
|
||||
friend T operator OP( const T& lhs, const U& rhs ) \
|
||||
friend BOOST_CXX14_CONSTEXPR T operator OP( const T& lhs, const U& rhs ) \
|
||||
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
|
||||
friend T operator OP( const U& lhs, const T& rhs ) \
|
||||
friend BOOST_CXX14_CONSTEXPR T operator OP( const U& lhs, const T& rhs ) \
|
||||
{ T nrv( rhs ); nrv OP##= lhs; return nrv; } \
|
||||
}; \
|
||||
\
|
||||
template <class T, class B = operators_detail::empty_base<T> > \
|
||||
struct NAME##1 : B \
|
||||
{ \
|
||||
friend T operator OP( const T& lhs, const T& rhs ) \
|
||||
friend BOOST_CXX14_CONSTEXPR T operator OP( const T& lhs, const T& rhs ) \
|
||||
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
|
||||
};
|
||||
|
||||
@ -195,21 +195,21 @@ struct NAME##1 : B \
|
||||
template <class T, class U, class B = operators_detail::empty_base<T> > \
|
||||
struct NAME##2 : B \
|
||||
{ \
|
||||
friend T operator OP( const T& lhs, const U& rhs ) \
|
||||
friend BOOST_CXX14_CONSTEXPR T operator OP( const T& lhs, const U& rhs ) \
|
||||
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
|
||||
}; \
|
||||
\
|
||||
template <class T, class U, class B = operators_detail::empty_base<T> > \
|
||||
struct BOOST_OPERATOR2_LEFT(NAME) : B \
|
||||
{ \
|
||||
friend T operator OP( const U& lhs, const T& rhs ) \
|
||||
friend BOOST_CXX14_CONSTEXPR T operator OP( const U& lhs, const T& rhs ) \
|
||||
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
|
||||
}; \
|
||||
\
|
||||
template <class T, class B = operators_detail::empty_base<T> > \
|
||||
struct NAME##1 : B \
|
||||
{ \
|
||||
friend T operator OP( const T& lhs, const T& rhs ) \
|
||||
friend BOOST_CXX14_CONSTEXPR T operator OP( const T& lhs, const T& rhs ) \
|
||||
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
|
||||
};
|
||||
|
||||
@ -224,34 +224,34 @@ struct NAME##1 : B \
|
||||
template <class T, class U, class B = operators_detail::empty_base<T> > \
|
||||
struct NAME##2 : B \
|
||||
{ \
|
||||
friend T operator OP( T lhs, const U& rhs ) { return lhs OP##= rhs; } \
|
||||
friend T operator OP( const U& lhs, T rhs ) { return rhs OP##= lhs; } \
|
||||
friend BOOST_CONSTEXPR T operator OP( T lhs, const U& rhs ) { return lhs OP##= rhs; } \
|
||||
friend BOOST_CONSTEXPR T operator OP( const U& lhs, T rhs ) { return rhs OP##= lhs; } \
|
||||
}; \
|
||||
\
|
||||
template <class T, class B = operators_detail::empty_base<T> > \
|
||||
struct NAME##1 : B \
|
||||
{ \
|
||||
friend T operator OP( T lhs, const T& rhs ) { return lhs OP##= rhs; } \
|
||||
friend BOOST_CONSTEXPR T operator OP( T lhs, const T& rhs ) { return lhs OP##= rhs; } \
|
||||
};
|
||||
|
||||
#define BOOST_BINARY_OPERATOR_NON_COMMUTATIVE( NAME, OP ) \
|
||||
template <class T, class U, class B = operators_detail::empty_base<T> > \
|
||||
struct NAME##2 : B \
|
||||
{ \
|
||||
friend T operator OP( T lhs, const U& rhs ) { return lhs OP##= rhs; } \
|
||||
friend BOOST_CONSTEXPR T operator OP( T lhs, const U& rhs ) { return lhs OP##= rhs; } \
|
||||
}; \
|
||||
\
|
||||
template <class T, class U, class B = operators_detail::empty_base<T> > \
|
||||
struct BOOST_OPERATOR2_LEFT(NAME) : B \
|
||||
{ \
|
||||
friend T operator OP( const U& lhs, const T& rhs ) \
|
||||
friend BOOST_CONSTEXPR T operator OP( const U& lhs, const T& rhs ) \
|
||||
{ return T( lhs ) OP##= rhs; } \
|
||||
}; \
|
||||
\
|
||||
template <class T, class B = operators_detail::empty_base<T> > \
|
||||
struct NAME##1 : B \
|
||||
{ \
|
||||
friend T operator OP( T lhs, const T& rhs ) { return lhs OP##= rhs; } \
|
||||
friend BOOST_CONSTEXPR T operator OP( T lhs, const T& rhs ) { return lhs OP##= rhs; } \
|
||||
};
|
||||
|
||||
#endif // defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS)
|
||||
@ -274,7 +274,7 @@ BOOST_BINARY_OPERATOR_COMMUTATIVE( orable, | )
|
||||
template <class T, class B = operators_detail::empty_base<T> >
|
||||
struct incrementable : B
|
||||
{
|
||||
friend T operator++(T& x, int)
|
||||
friend BOOST_CXX14_CONSTEXPR T operator++(T& x, int)
|
||||
{
|
||||
incrementable_type nrv(x);
|
||||
++x;
|
||||
@ -287,7 +287,7 @@ private: // The use of this typedef works around a Borland bug
|
||||
template <class T, class B = operators_detail::empty_base<T> >
|
||||
struct decrementable : B
|
||||
{
|
||||
friend T operator--(T& x, int)
|
||||
friend BOOST_CXX14_CONSTEXPR T operator--(T& x, int)
|
||||
{
|
||||
decrementable_type nrv(x);
|
||||
--x;
|
||||
@ -326,14 +326,14 @@ struct indexable : B
|
||||
template <class T, class U, class B = operators_detail::empty_base<T> > \
|
||||
struct NAME##2 : B \
|
||||
{ \
|
||||
friend T operator OP( const T& lhs, const U& rhs ) \
|
||||
friend BOOST_CXX14_CONSTEXPR T operator OP( const T& lhs, const U& rhs ) \
|
||||
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
|
||||
}; \
|
||||
\
|
||||
template <class T, class B = operators_detail::empty_base<T> > \
|
||||
struct NAME##1 : B \
|
||||
{ \
|
||||
friend T operator OP( const T& lhs, const T& rhs ) \
|
||||
friend BOOST_CXX14_CONSTEXPR T operator OP( const T& lhs, const T& rhs ) \
|
||||
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
|
||||
};
|
||||
|
||||
@ -343,13 +343,13 @@ struct NAME##1 : B \
|
||||
template <class T, class U, class B = operators_detail::empty_base<T> > \
|
||||
struct NAME##2 : B \
|
||||
{ \
|
||||
friend T operator OP( T lhs, const U& rhs ) { return lhs OP##= rhs; } \
|
||||
friend BOOST_CONSTEXPR T operator OP( T lhs, const U& rhs ) { return lhs OP##= rhs; } \
|
||||
}; \
|
||||
\
|
||||
template <class T, class B = operators_detail::empty_base<T> > \
|
||||
struct NAME##1 : B \
|
||||
{ \
|
||||
friend T operator OP( T lhs, const T& rhs ) { return lhs OP##= rhs; } \
|
||||
friend BOOST_CONSTEXPR T operator OP( T lhs, const T& rhs ) { return lhs OP##= rhs; } \
|
||||
};
|
||||
|
||||
#endif // defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS)
|
||||
@ -362,7 +362,7 @@ BOOST_BINARY_OPERATOR( right_shiftable, >> )
|
||||
template <class T, class U, class B = operators_detail::empty_base<T> >
|
||||
struct equivalent2 : B
|
||||
{
|
||||
friend bool operator==(const T& x, const U& y)
|
||||
friend BOOST_CONSTEXPR bool operator==(const T& x, const U& y)
|
||||
{
|
||||
return !static_cast<bool>(x < y) && !static_cast<bool>(x > y);
|
||||
}
|
||||
@ -371,7 +371,7 @@ struct equivalent2 : B
|
||||
template <class T, class B = operators_detail::empty_base<T> >
|
||||
struct equivalent1 : B
|
||||
{
|
||||
friend bool operator==(const T&x, const T&y)
|
||||
friend BOOST_CONSTEXPR bool operator==(const T&x, const T&y)
|
||||
{
|
||||
return !static_cast<bool>(x < y) && !static_cast<bool>(y < x);
|
||||
}
|
||||
@ -380,28 +380,28 @@ struct equivalent1 : B
|
||||
template <class T, class U, class B = operators_detail::empty_base<T> >
|
||||
struct partially_ordered2 : B
|
||||
{
|
||||
friend bool operator<=(const T& x, const U& y)
|
||||
friend BOOST_CONSTEXPR bool operator<=(const T& x, const U& y)
|
||||
{ return static_cast<bool>(x < y) || static_cast<bool>(x == y); }
|
||||
friend bool operator>=(const T& x, const U& y)
|
||||
friend BOOST_CONSTEXPR bool operator>=(const T& x, const U& y)
|
||||
{ return static_cast<bool>(x > y) || static_cast<bool>(x == y); }
|
||||
friend bool operator>(const U& x, const T& y)
|
||||
friend BOOST_CONSTEXPR bool operator>(const U& x, const T& y)
|
||||
{ return y < x; }
|
||||
friend bool operator<(const U& x, const T& y)
|
||||
friend BOOST_CONSTEXPR bool operator<(const U& x, const T& y)
|
||||
{ return y > x; }
|
||||
friend bool operator<=(const U& x, const T& y)
|
||||
friend BOOST_CONSTEXPR bool operator<=(const U& x, const T& y)
|
||||
{ return static_cast<bool>(y > x) || static_cast<bool>(y == x); }
|
||||
friend bool operator>=(const U& x, const T& y)
|
||||
friend BOOST_CONSTEXPR bool operator>=(const U& x, const T& y)
|
||||
{ return static_cast<bool>(y < x) || static_cast<bool>(y == x); }
|
||||
};
|
||||
|
||||
template <class T, class B = operators_detail::empty_base<T> >
|
||||
struct partially_ordered1 : B
|
||||
{
|
||||
friend bool operator>(const T& x, const T& y)
|
||||
friend BOOST_CONSTEXPR bool operator>(const T& x, const T& y)
|
||||
{ return y < x; }
|
||||
friend bool operator<=(const T& x, const T& y)
|
||||
friend BOOST_CONSTEXPR bool operator<=(const T& x, const T& y)
|
||||
{ return static_cast<bool>(x < y) || static_cast<bool>(x == y); }
|
||||
friend bool operator>=(const T& x, const T& y)
|
||||
friend BOOST_CONSTEXPR bool operator>=(const T& x, const T& y)
|
||||
{ return static_cast<bool>(y < x) || static_cast<bool>(x == y); }
|
||||
};
|
||||
|
||||
|
@ -454,7 +454,7 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
</caption>
|
||||
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<td colspan="4">
|
||||
<table align="center" border="1">
|
||||
<caption>
|
||||
<em>Key</em>
|
||||
@ -482,6 +482,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<th>Supplied Operations</th>
|
||||
|
||||
<th>Requirements</th>
|
||||
|
||||
<th>Propagates <code>constexpr</code>?</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -496,6 +498,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>t < t1</code>.<br>
|
||||
Return convertible to <code>bool</code>. See the <a href=
|
||||
"#ordering">Ordering Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++11</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -513,6 +517,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>t < u</code>. <code>t > u</code>.<br>
|
||||
Returns convertible to <code>bool</code>. See the <a href=
|
||||
"#ordering">Ordering Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++11</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -524,6 +530,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
|
||||
<td><code>t == t1</code>.<br>
|
||||
Return convertible to <code>bool</code>.</td>
|
||||
|
||||
<td>Since <code>C++11</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -537,6 +545,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
|
||||
<td><code>t == u</code>.<br>
|
||||
Return convertible to <code>bool</code>.</td>
|
||||
|
||||
<td>Since <code>C++11</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -548,6 +558,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp += t1</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++14</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -560,6 +572,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp += u</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++14</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -572,6 +586,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp -= t1</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++14</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -584,6 +600,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp -= u</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++14</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -594,6 +612,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
|
||||
<td><code>T temp(u); temp -= t</code>.<br>
|
||||
Return convertible to <code>T</code>.</td>
|
||||
|
||||
<td>Since <code>C++14</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -606,6 +626,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp *= t1</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++14</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -619,6 +641,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp *= u</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++14</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -630,6 +654,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp /= t1</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++14</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -641,6 +667,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp /= u</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++14</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -651,6 +679,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
|
||||
<td><code>T temp(u); temp /= t</code>.<br>
|
||||
Return convertible to <code>T</code>.</td>
|
||||
|
||||
<td>Since <code>C++14</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -662,6 +692,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp %= t1</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++14</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -673,6 +705,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp %= u</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++14</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -683,6 +717,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
|
||||
<td><code>T temp(u); temp %= t</code>.<br>
|
||||
Return convertible to <code>T</code>.</td>
|
||||
|
||||
<td>Since <code>C++14</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -694,6 +730,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp |= t1</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++14</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -706,6 +744,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp |= u</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++14</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -717,6 +757,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp &= t1</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++14</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -729,6 +771,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp &= u</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++14</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -740,6 +784,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp ^= t1</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++14</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -752,6 +798,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp ^= u</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++14</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -762,6 +810,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
|
||||
<td><code>T temp(t); ++t</code><br>
|
||||
Return convertible to <code>T</code>.</td>
|
||||
|
||||
<td>Since <code>C++14</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -772,6 +822,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
|
||||
<td><code>T temp(t); --t;</code><br>
|
||||
Return convertible to <code>T</code>.</td>
|
||||
|
||||
<td>Since <code>C++14</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -784,6 +836,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp <<= t1</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++14</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -796,6 +850,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp <<= u</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++14</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -808,6 +864,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp >>= t1</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++14</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -820,6 +878,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>T temp(t); temp >>= u</code>.<br>
|
||||
Return convertible to <code>T</code>. See the <a href=
|
||||
"#symmetry">Symmetry Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++14</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -831,6 +891,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>t < t1</code>.<br>
|
||||
Return convertible to <code>bool</code>. See the <a href=
|
||||
"#ordering">Ordering Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++11</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -842,6 +904,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>t < u</code>. <code>t > u</code>.<br>
|
||||
Returns convertible to <code>bool</code>. See the <a href=
|
||||
"#ordering">Ordering Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++11</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -856,6 +920,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
<td><code>t < t1</code>. <code>t == t1</code>.<br>
|
||||
Returns convertible to <code>bool</code>. See the <a href=
|
||||
"#ordering">Ordering Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++11</code></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
@ -874,6 +940,8 @@ const point<float> pi_over_4_normalized = pi_over_4 / length(pi_over_4);
|
||||
u</code>.<br>
|
||||
Returns convertible to <code>bool</code>. See the <a href=
|
||||
"#ordering">Ordering Note</a>.</td>
|
||||
|
||||
<td>Since <code>C++11</code></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
@ -50,9 +50,9 @@ namespace
|
||||
void operator!() const;
|
||||
|
||||
public:
|
||||
convertible_to_bool( const bool value ) : _value( value ) {}
|
||||
BOOST_CONSTEXPR convertible_to_bool( const bool value ) : _value( value ) {}
|
||||
|
||||
operator unspecified_bool_type() const
|
||||
BOOST_CONSTEXPR operator unspecified_bool_type() const
|
||||
{ return _value ? &convertible_to_bool::_value : 0; }
|
||||
};
|
||||
|
||||
@ -64,36 +64,36 @@ namespace
|
||||
, boost::shiftable<Wrapped1<T> >
|
||||
{
|
||||
public:
|
||||
explicit Wrapped1( T v = T() ) : _value(v) {}
|
||||
T value() const { return _value; }
|
||||
BOOST_CONSTEXPR explicit Wrapped1( T v = T() ) : _value(v) {}
|
||||
BOOST_CONSTEXPR T value() const { return _value; }
|
||||
|
||||
convertible_to_bool operator<(const Wrapped1& x) const
|
||||
BOOST_CONSTEXPR convertible_to_bool operator<(const Wrapped1& x) const
|
||||
{ return _value < x._value; }
|
||||
convertible_to_bool operator==(const Wrapped1& x) const
|
||||
BOOST_CONSTEXPR convertible_to_bool operator==(const Wrapped1& x) const
|
||||
{ return _value == x._value; }
|
||||
|
||||
Wrapped1& operator+=(const Wrapped1& x)
|
||||
BOOST_CXX14_CONSTEXPR Wrapped1& operator+=(const Wrapped1& x)
|
||||
{ _value += x._value; return *this; }
|
||||
Wrapped1& operator-=(const Wrapped1& x)
|
||||
BOOST_CXX14_CONSTEXPR Wrapped1& operator-=(const Wrapped1& x)
|
||||
{ _value -= x._value; return *this; }
|
||||
Wrapped1& operator*=(const Wrapped1& x)
|
||||
BOOST_CXX14_CONSTEXPR Wrapped1& operator*=(const Wrapped1& x)
|
||||
{ _value *= x._value; return *this; }
|
||||
Wrapped1& operator/=(const Wrapped1& x)
|
||||
BOOST_CXX14_CONSTEXPR Wrapped1& operator/=(const Wrapped1& x)
|
||||
{ _value /= x._value; return *this; }
|
||||
Wrapped1& operator%=(const Wrapped1& x)
|
||||
BOOST_CXX14_CONSTEXPR Wrapped1& operator%=(const Wrapped1& x)
|
||||
{ _value %= x._value; return *this; }
|
||||
Wrapped1& operator|=(const Wrapped1& x)
|
||||
BOOST_CXX14_CONSTEXPR Wrapped1& operator|=(const Wrapped1& x)
|
||||
{ _value |= x._value; return *this; }
|
||||
Wrapped1& operator&=(const Wrapped1& x)
|
||||
BOOST_CXX14_CONSTEXPR Wrapped1& operator&=(const Wrapped1& x)
|
||||
{ _value &= x._value; return *this; }
|
||||
Wrapped1& operator^=(const Wrapped1& x)
|
||||
BOOST_CXX14_CONSTEXPR Wrapped1& operator^=(const Wrapped1& x)
|
||||
{ _value ^= x._value; return *this; }
|
||||
Wrapped1& operator<<=(const Wrapped1& x)
|
||||
BOOST_CXX14_CONSTEXPR Wrapped1& operator<<=(const Wrapped1& x)
|
||||
{ _value <<= x._value; return *this; }
|
||||
Wrapped1& operator>>=(const Wrapped1& x)
|
||||
BOOST_CXX14_CONSTEXPR Wrapped1& operator>>=(const Wrapped1& x)
|
||||
{ _value >>= x._value; return *this; }
|
||||
Wrapped1& operator++() { ++_value; return *this; }
|
||||
Wrapped1& operator--() { --_value; return *this; }
|
||||
BOOST_CXX14_CONSTEXPR Wrapped1& operator++() { ++_value; return *this; }
|
||||
BOOST_CXX14_CONSTEXPR Wrapped1& operator--() { --_value; return *this; }
|
||||
|
||||
private:
|
||||
T _value;
|
||||
@ -932,5 +932,64 @@ main()
|
||||
|
||||
cout << "Performed tests on MyLongInt objects.\n";
|
||||
|
||||
// Where C++11 constexpr is available, compile-time test some of the operators that are able to use it to propagate constexpr
|
||||
#ifndef BOOST_NO_CXX11_CONSTEXPR
|
||||
static_assert( ! static_cast<bool>( MyInt{ 1 } == MyInt{ 2 } ), "" );
|
||||
static_assert( MyInt{ 1 } != MyInt{ 2 }, "" );
|
||||
static_assert( MyInt{ 1 } < MyInt{ 2 }, "" );
|
||||
static_assert( MyInt{ 1 } <= MyInt{ 2 }, "" );
|
||||
static_assert( ! static_cast<bool>( MyInt{ 1 } > MyInt{ 2 } ), "" );
|
||||
static_assert( ! static_cast<bool>( MyInt{ 1 } >= MyInt{ 2 } ), "" );
|
||||
|
||||
static_assert( ! static_cast<bool>( MyInt{ 2 } == MyInt{ 1 } ), "" );
|
||||
static_assert( MyInt{ 2 } != MyInt{ 1 }, "" );
|
||||
static_assert( ! static_cast<bool>( MyInt{ 2 } < MyInt{ 1 } ), "" );
|
||||
static_assert( ! static_cast<bool>( MyInt{ 2 } <= MyInt{ 1 } ), "" );
|
||||
static_assert( MyInt{ 2 } > MyInt{ 1 }, "" );
|
||||
static_assert( MyInt{ 2 } >= MyInt{ 1 }, "" );
|
||||
|
||||
static_assert( MyInt{ 1 } == MyInt{ 1 }, "" );
|
||||
static_assert( ! static_cast<bool>( MyInt{ 1 } != MyInt{ 1 } ), "" );
|
||||
static_assert( ! static_cast<bool>( MyInt{ 1 } < MyInt{ 1 } ), "" );
|
||||
static_assert( MyInt{ 1 } <= MyInt{ 1 }, "" );
|
||||
static_assert( ! static_cast<bool>( MyInt{ 1 } > MyInt{ 1 } ), "" );
|
||||
static_assert( MyInt{ 1 } >= MyInt{ 1 }, "" );
|
||||
#endif
|
||||
|
||||
// Where C++14 constexpr is available, compile-time test some of the operators that are able to use it to propagate constexpr
|
||||
#ifndef BOOST_NO_CXX14_CONSTEXPR
|
||||
static_assert( ( MyInt{ 1 } + MyInt{ 2 } ) == MyInt{ 3 }, "" );
|
||||
static_assert( ( MyInt{ 2 } + MyInt{ 1 } ) == MyInt{ 3 }, "" );
|
||||
static_assert( ( MyInt{ 2 } + MyInt{ 1 } ) == MyInt{ 3 }, "" );
|
||||
static_assert( ( MyInt{ 2 } + MyInt{ 2 } ) == MyInt{ 4 }, "" );
|
||||
static_assert( ( MyInt{ 3 } + MyInt{ 2 } ) == MyInt{ 5 }, "" );
|
||||
|
||||
static_assert( ( MyInt{ 5 } - MyInt{ 1 } ) == MyInt{ 4 }, "" );
|
||||
|
||||
static_assert( ( MyInt{ 3 } * MyInt{ 3 } ) == MyInt{ 9 }, "" );
|
||||
static_assert( ( MyInt{ 4 } * MyInt{ 2 } ) == MyInt{ 8 }, "" );
|
||||
|
||||
static_assert( ( MyInt{ 8 } / MyInt{ 2 } ) == MyInt{ 4 }, "" );
|
||||
|
||||
static_assert( ( MyInt{ 4 } % MyInt{ 3 } ) == MyInt{ 1 }, "" );
|
||||
|
||||
|
||||
static_assert( ( MyInt{ 7 } & MyInt{ 2 } ) == MyInt{ 2 }, "" );
|
||||
|
||||
static_assert( ( MyInt{ 1 } | MyInt{ 2 } ) == MyInt{ 3 }, "" );
|
||||
static_assert( ( MyInt{ 1 } | MyInt{ 4 } ) == MyInt{ 5 }, "" );
|
||||
static_assert( ( MyInt{ 2 } | MyInt{ 1 } ) == MyInt{ 3 }, "" );
|
||||
static_assert( ( MyInt{ 2 } | MyInt{ 4 } ) == MyInt{ 6 }, "" );
|
||||
static_assert( ( MyInt{ 3 } | MyInt{ 4 } ) == MyInt{ 7 }, "" );
|
||||
static_assert( ( MyInt{ 5 } | MyInt{ 2 } ) == MyInt{ 7 }, "" );
|
||||
static_assert( ( MyInt{ 6 } | MyInt{ 1 } ) == MyInt{ 7 }, "" );
|
||||
|
||||
static_assert( ( MyInt{ 3 } ^ MyInt{ 1 } ) == MyInt{ 2 }, "" );
|
||||
|
||||
|
||||
static_assert( ( MyInt{ 1 } << MyInt{ 2 } ) == MyInt{ 4 }, "" );
|
||||
static_assert( ( MyInt{ 2 } >> MyInt{ 1 } ) == MyInt{ 1 }, "" );
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user