forked from boostorg/variant2
Move index() into variant_base to avoid needless ix_ >= 0 checks when single buffered
This commit is contained in:
@ -413,6 +413,11 @@ template<class... T> struct variant_base_impl<true, true, T...>
|
||||
{
|
||||
}
|
||||
|
||||
constexpr std::size_t index() const noexcept
|
||||
{
|
||||
return ix_ - 1;
|
||||
}
|
||||
|
||||
template<std::size_t I> constexpr mp_at_c<variant<T...>, I>& _get_impl( mp_size_t<I> ) noexcept
|
||||
{
|
||||
size_t const J = I+1;
|
||||
@ -486,6 +491,11 @@ template<class... T> struct variant_base_impl<true, false, T...>
|
||||
{
|
||||
}
|
||||
|
||||
constexpr std::size_t index() const noexcept
|
||||
{
|
||||
return ix_ >= 0? ix_ - 1: -ix_ - 1;
|
||||
}
|
||||
|
||||
template<std::size_t I> constexpr mp_at_c<variant<T...>, I>& _get_impl( mp_size_t<I> ) noexcept
|
||||
{
|
||||
size_t const J = I+1;
|
||||
@ -555,6 +565,11 @@ template<class... T> struct variant_base_impl<false, true, T...>
|
||||
_destroy();
|
||||
}
|
||||
|
||||
constexpr std::size_t index() const noexcept
|
||||
{
|
||||
return ix_ - 1;
|
||||
}
|
||||
|
||||
template<std::size_t I> constexpr mp_at_c<variant<T...>, I>& _get_impl( mp_size_t<I> ) noexcept
|
||||
{
|
||||
size_t const J = I+1;
|
||||
@ -661,6 +676,11 @@ template<class... T> struct variant_base_impl<false, false, T...>
|
||||
_destroy();
|
||||
}
|
||||
|
||||
constexpr std::size_t index() const noexcept
|
||||
{
|
||||
return ix_ >= 0? ix_ - 1: -ix_ - 1;
|
||||
}
|
||||
|
||||
template<std::size_t I> constexpr mp_at_c<variant<T...>, I>& _get_impl( mp_size_t<I> ) noexcept
|
||||
{
|
||||
size_t const J = I+1;
|
||||
@ -958,10 +978,7 @@ public:
|
||||
|
||||
// value status
|
||||
|
||||
constexpr size_t index() const noexcept
|
||||
{
|
||||
return this->ix_ >= 0? this->ix_ - 1 : -this->ix_ - 1;
|
||||
}
|
||||
using variant_base::index;
|
||||
|
||||
// swap
|
||||
|
||||
|
Reference in New Issue
Block a user