https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89130
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |glisse at gcc dot gnu.org
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This fixes the example above:
--- a/libstdc++-v3/include/bits/stl_uninitialized.h
+++ b/libstdc++-v3/include/bits/stl_uninitialized.h
@@ -883,7 +883,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#if __cplusplus >= 201103L
template<typename _Tp, typename _Up, typename _Allocator>
- inline void
+ inline __enable_if_t<is_constructible<_Tp, _Up>::value>
__relocate_object_a(_Tp* __dest, _Up* __orig, _Allocator& __alloc)
noexcept(noexcept(std::allocator_traits<_Allocator>::construct(__alloc,
__dest, std::move(*__orig)))
@@ -895,6 +895,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__traits::destroy(__alloc, std::__addressof(*__orig));
}
+ template<typename _Tp, typename _Up, typename _Allocator>
+ inline __enable_if_t<!is_constructible<_Tp, _Up>::value>
+ __relocate_object_a(_Tp*, _Up*, _Allocator&) noexcept(false)
+ { }
+
// This class may be specialized for specific types.
template<typename _Tp, typename = void>
struct __is_trivially_relocatable
The trick here is to select an overload of __relocate_object_a that has a
potentially throwing noexcept-specifier, which means that std::vector will
never try to use it.
This only works if allocator_traits::construct forwards the arguments
unchanged, because otherwise the is_constructible<Tp, _Up> check is wrong.
Maybe as discussed we need to detect when allocator_traits::construct has been
specialized, and not try to relocate in that case.
Or maybe we should just revert this relocation stuff for now.