forked from boostorg/variant2
Extend g++5 workaround for consistency to rvalue overloads
This commit is contained in:
@ -122,7 +122,7 @@ template<std::size_t I, class... T> constexpr variant_alternative_t<I, variant<T
|
||||
|
||||
#else
|
||||
|
||||
if( v.index() != I ) throw bad_variant_access();
|
||||
if( v.index() != I ) throw bad_variant_access();
|
||||
return v._get_impl( mp_size_t<I>() );
|
||||
|
||||
#endif
|
||||
@ -132,9 +132,16 @@ template<std::size_t I, class... T> constexpr variant_alternative_t<I, variant<T
|
||||
{
|
||||
static_assert( I < sizeof...(T), "Index out of bounds" );
|
||||
|
||||
if( v.index() != I ) throw bad_variant_access();
|
||||
#if BOOST_WORKAROUND( BOOST_GCC, < 60000 )
|
||||
|
||||
return (void)( v.index() != I? throw bad_variant_access(): 0), std::move( v._get_impl( mp_size_t<I>() ) );
|
||||
|
||||
#else
|
||||
|
||||
if( v.index() != I ) throw bad_variant_access();
|
||||
return std::move( v._get_impl( mp_size_t<I>() ) );
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
template<std::size_t I, class... T> constexpr variant_alternative_t<I, variant<T...>> const& get(variant<T...> const& v)
|
||||
@ -157,9 +164,16 @@ template<std::size_t I, class... T> constexpr variant_alternative_t<I, variant<T
|
||||
{
|
||||
static_assert( I < sizeof...(T), "Index out of bounds" );
|
||||
|
||||
if( v.index() != I ) throw bad_variant_access();
|
||||
#if BOOST_WORKAROUND( BOOST_GCC, < 60000 )
|
||||
|
||||
return (void)( v.index() != I? throw bad_variant_access(): 0), std::move( v._get_impl( mp_size_t<I>() ) );
|
||||
|
||||
#else
|
||||
|
||||
if( v.index() != I ) throw bad_variant_access();
|
||||
return std::move( v._get_impl( mp_size_t<I>() ) );
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
// get
|
||||
@ -186,9 +200,16 @@ template<class U, class... T> constexpr U&& get(variant<T...>&& v)
|
||||
static_assert( mp_count<variant<T...>, U>::value == 1, "The type must occur exactly once in the list of variant alternatives" );
|
||||
constexpr auto I = mp_find<variant<T...>, U>::value;
|
||||
|
||||
if( v.index() != I ) throw bad_variant_access();
|
||||
#if BOOST_WORKAROUND( BOOST_GCC, < 60000 )
|
||||
|
||||
return (void)( v.index() != I? throw bad_variant_access(): 0), std::move( v._get_impl( mp_size_t<I>() ) );
|
||||
|
||||
#else
|
||||
|
||||
if( v.index() != I ) throw bad_variant_access();
|
||||
return std::move( v._get_impl( mp_size_t<I>() ) );
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
template<class U, class... T> constexpr U const& get(variant<T...> const& v)
|
||||
@ -213,9 +234,16 @@ template<class U, class... T> constexpr U const&& get(variant<T...> const&& v)
|
||||
static_assert( mp_count<variant<T...>, U>::value == 1, "The type must occur exactly once in the list of variant alternatives" );
|
||||
constexpr auto I = mp_find<variant<T...>, U>::value;
|
||||
|
||||
if( v.index() != I ) throw bad_variant_access();
|
||||
#if BOOST_WORKAROUND( BOOST_GCC, < 60000 )
|
||||
|
||||
return (void)( v.index() != I? throw bad_variant_access(): 0), std::move( v._get_impl( mp_size_t<I>() ) );
|
||||
|
||||
#else
|
||||
|
||||
if( v.index() != I ) throw bad_variant_access();
|
||||
return std::move( v._get_impl( mp_size_t<I>() ) );
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
// get_if
|
||||
|
Reference in New Issue
Block a user