Remove C++14 constexpr due to MSVC/GCC problems

This commit is contained in:
Tony Lewis 2018-12-22 15:52:13 +00:00
parent e8d2b2ba76
commit 91ebdcd1dd
3 changed files with 87 additions and 122 deletions

View File

@ -174,43 +174,43 @@ struct equality_comparable1 : B
// If the compiler has no NRVO, this is the best symmetric
// implementation available.
#define BOOST_BINARY_OPERATOR_COMMUTATIVE( NAME, OP ) \
template <class T, class U, class B = operators_detail::empty_base<T> > \
struct NAME##2 : B \
{ \
friend BOOST_CXX14_CONSTEXPR T operator OP( const T& lhs, const U& rhs ) \
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
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 BOOST_CXX14_CONSTEXPR T operator OP( const T& lhs, const T& rhs ) \
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
#define BOOST_BINARY_OPERATOR_COMMUTATIVE( NAME, OP ) \
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 ) \
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
friend 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 ) \
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
};
#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 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 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 BOOST_CXX14_CONSTEXPR T operator OP( const T& lhs, const T& rhs ) \
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
#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( 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 ) \
{ 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 ) \
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
};
#else // 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 BOOST_CXX14_CONSTEXPR T operator++(T& x, int)
friend 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 BOOST_CXX14_CONSTEXPR T operator--(T& x, int)
friend T operator--(T& x, int)
{
decrementable_type nrv(x);
--x;
@ -322,19 +322,19 @@ struct indexable : B
#if defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS)
#define BOOST_BINARY_OPERATOR( NAME, OP ) \
template <class T, class U, class B = operators_detail::empty_base<T> > \
struct NAME##2 : B \
{ \
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 BOOST_CXX14_CONSTEXPR T operator OP( const T& lhs, const T& rhs ) \
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
#define BOOST_BINARY_OPERATOR( NAME, OP ) \
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 ) \
{ 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 ) \
{ T nrv( lhs ); nrv OP##= rhs; return nrv; } \
};
#else // defined(BOOST_HAS_NRVO) || defined(BOOST_FORCE_SYMMETRIC_OPERATORS)

View File

@ -559,7 +559,7 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>Since <code>C++14</code></td>
<td>No</td>
</tr>
<tr>
@ -573,7 +573,7 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>Since <code>C++14</code></td>
<td>No</td>
</tr>
<tr>
@ -587,7 +587,7 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>Since <code>C++14</code></td>
<td>No</td>
</tr>
<tr>
@ -601,7 +601,7 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>Since <code>C++14</code></td>
<td>No</td>
</tr>
<tr>
@ -613,7 +613,7 @@ const point&lt;float&gt; 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>
<td>No</td>
</tr>
<tr>
@ -627,7 +627,7 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>Since <code>C++14</code></td>
<td>No</td>
</tr>
<tr>
@ -642,7 +642,7 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>Since <code>C++14</code></td>
<td>No</td>
</tr>
<tr>
@ -655,7 +655,7 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>Since <code>C++14</code></td>
<td>No</td>
</tr>
<tr>
@ -668,7 +668,7 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>Since <code>C++14</code></td>
<td>No</td>
</tr>
<tr>
@ -680,7 +680,7 @@ const point&lt;float&gt; 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>
<td>No</td>
</tr>
<tr>
@ -693,7 +693,7 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>Since <code>C++14</code></td>
<td>No</td>
</tr>
<tr>
@ -706,7 +706,7 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>Since <code>C++14</code></td>
<td>No</td>
</tr>
<tr>
@ -718,7 +718,7 @@ const point&lt;float&gt; 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>
<td>No</td>
</tr>
<tr>
@ -731,7 +731,7 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>Since <code>C++14</code></td>
<td>No</td>
</tr>
<tr>
@ -745,7 +745,7 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>Since <code>C++14</code></td>
<td>No</td>
</tr>
<tr>
@ -758,7 +758,7 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>Since <code>C++14</code></td>
<td>No</td>
</tr>
<tr>
@ -772,7 +772,7 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>Since <code>C++14</code></td>
<td>No</td>
</tr>
<tr>
@ -785,7 +785,7 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>Since <code>C++14</code></td>
<td>No</td>
</tr>
<tr>
@ -799,7 +799,7 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>Since <code>C++14</code></td>
<td>No</td>
</tr>
<tr>
@ -811,7 +811,7 @@ const point&lt;float&gt; 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>
<td>No</td>
</tr>
<tr>
@ -823,7 +823,7 @@ const point&lt;float&gt; 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>
<td>No</td>
</tr>
<tr>
@ -837,7 +837,7 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>Since <code>C++14</code></td>
<td>No</td>
</tr>
<tr>
@ -851,7 +851,7 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>Since <code>C++14</code></td>
<td>No</td>
</tr>
<tr>
@ -865,7 +865,7 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>Since <code>C++14</code></td>
<td>No</td>
</tr>
<tr>
@ -879,7 +879,7 @@ const point&lt;float&gt; pi_over_4_normalized = pi_over_4 / length(pi_over_4);
Return convertible to <code>T</code>. See the <a href=
"#symmetry">Symmetry Note</a>.</td>
<td>Since <code>C++14</code></td>
<td>No</td>
</tr>
<tr>

View File

@ -72,28 +72,28 @@ namespace
BOOST_CONSTEXPR convertible_to_bool operator==(const Wrapped1& x) const
{ return _value == x._value; }
BOOST_CXX14_CONSTEXPR Wrapped1& operator+=(const Wrapped1& x)
Wrapped1& operator+=(const Wrapped1& x)
{ _value += x._value; return *this; }
BOOST_CXX14_CONSTEXPR Wrapped1& operator-=(const Wrapped1& x)
Wrapped1& operator-=(const Wrapped1& x)
{ _value -= x._value; return *this; }
BOOST_CXX14_CONSTEXPR Wrapped1& operator*=(const Wrapped1& x)
Wrapped1& operator*=(const Wrapped1& x)
{ _value *= x._value; return *this; }
BOOST_CXX14_CONSTEXPR Wrapped1& operator/=(const Wrapped1& x)
Wrapped1& operator/=(const Wrapped1& x)
{ _value /= x._value; return *this; }
BOOST_CXX14_CONSTEXPR Wrapped1& operator%=(const Wrapped1& x)
Wrapped1& operator%=(const Wrapped1& x)
{ _value %= x._value; return *this; }
BOOST_CXX14_CONSTEXPR Wrapped1& operator|=(const Wrapped1& x)
Wrapped1& operator|=(const Wrapped1& x)
{ _value |= x._value; return *this; }
BOOST_CXX14_CONSTEXPR Wrapped1& operator&=(const Wrapped1& x)
Wrapped1& operator&=(const Wrapped1& x)
{ _value &= x._value; return *this; }
BOOST_CXX14_CONSTEXPR Wrapped1& operator^=(const Wrapped1& x)
Wrapped1& operator^=(const Wrapped1& x)
{ _value ^= x._value; return *this; }
BOOST_CXX14_CONSTEXPR Wrapped1& operator<<=(const Wrapped1& x)
Wrapped1& operator<<=(const Wrapped1& x)
{ _value <<= x._value; return *this; }
BOOST_CXX14_CONSTEXPR Wrapped1& operator>>=(const Wrapped1& x)
Wrapped1& operator>>=(const Wrapped1& x)
{ _value >>= x._value; return *this; }
BOOST_CXX14_CONSTEXPR Wrapped1& operator++() { ++_value; return *this; }
BOOST_CXX14_CONSTEXPR Wrapped1& operator--() { --_value; return *this; }
Wrapped1& operator++() { ++_value; return *this; }
Wrapped1& operator--() { --_value; return *this; }
private:
T _value;
@ -956,40 +956,5 @@ main()
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();
}