mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-31 11:57:15 +02:00
Workaround visibility bug in gcc-6 by un-nesting lambdas
This commit is contained in:
@ -975,6 +975,40 @@ public:
|
|||||||
static constexpr auto pocma=
|
static constexpr auto pocma=
|
||||||
alloc_traits::propagate_on_container_move_assignment::value;
|
alloc_traits::propagate_on_container_move_assignment::value;
|
||||||
|
|
||||||
|
/* Avoid using nested lambdas with a `this` capture as it seems to trigger
|
||||||
|
* a bug in GCC:
|
||||||
|
* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80947
|
||||||
|
*
|
||||||
|
* Rather than directly attempting to manipulate the visibility of the
|
||||||
|
* table class, it's easier to work around the bug by simply un-nesting the
|
||||||
|
* lambdas
|
||||||
|
*/
|
||||||
|
auto const move_element=[this](value_type* p){
|
||||||
|
unchecked_insert(std::move(*p));
|
||||||
|
};
|
||||||
|
|
||||||
|
auto const elementwise_move=[&,this]{
|
||||||
|
/* The check above is redundant: we're setting up a compile-time
|
||||||
|
* barrier so that the compiler is convinced we're not throwing
|
||||||
|
* under noexcept(true) conditions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
reserve(x.size());
|
||||||
|
BOOST_TRY{
|
||||||
|
/* This works because subsequent x.clear() does not depend on the
|
||||||
|
* elements' values.
|
||||||
|
*/
|
||||||
|
|
||||||
|
x.for_all_elements(move_element);
|
||||||
|
}
|
||||||
|
BOOST_CATCH(...){
|
||||||
|
x.clear();
|
||||||
|
BOOST_RETHROW
|
||||||
|
}
|
||||||
|
BOOST_CATCH_END
|
||||||
|
x.clear();
|
||||||
|
};
|
||||||
|
|
||||||
if(this!=&x){
|
if(this!=&x){
|
||||||
clear();
|
clear();
|
||||||
h()=std::move(x.h());
|
h()=std::move(x.h());
|
||||||
@ -987,29 +1021,8 @@ public:
|
|||||||
swap(arrays,x.arrays);
|
swap(arrays,x.arrays);
|
||||||
swap(ml,x.ml);
|
swap(ml,x.ml);
|
||||||
}
|
}
|
||||||
else if_constexpr<!alloc_traits::is_always_equal::value>([&,this]{
|
else if_constexpr<!alloc_traits::is_always_equal::value>(
|
||||||
/* The check above is redundant: we're setting up a compile-time
|
elementwise_move);
|
||||||
* barrier so that the compiler is convinced we're not throwing
|
|
||||||
* under noexcept(true) conditions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
reserve(x.size());
|
|
||||||
BOOST_TRY{
|
|
||||||
/* This works because subsequent x.clear() does not depend on the
|
|
||||||
* elements' values.
|
|
||||||
*/
|
|
||||||
|
|
||||||
x.for_all_elements([this](value_type* p){
|
|
||||||
unchecked_insert(type_policy::move(*p));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
BOOST_CATCH(...){
|
|
||||||
x.clear();
|
|
||||||
BOOST_RETHROW
|
|
||||||
}
|
|
||||||
BOOST_CATCH_END
|
|
||||||
x.clear();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user