https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115854

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I thought I'd opened a bug report about this years ago, but maybe I just
mentioned it on the mailing list.

I have a local patch somewhere that does:

--- a/libstdc++-v3/testsuite/util/testsuite_allocator.h
+++ b/libstdc++-v3/testsuite/util/testsuite_allocator.h
@@ -517,6 +517,7 @@ namespace __gnu_test
       constexpr SimpleAllocator() noexcept { }

       template <class T>
+       explicit
         SimpleAllocator(const SimpleAllocator<T>&) { }

       Tp *allocate(std::size_t n)

And it breaks a few places like this.

I don't really care though, because making the allocator's converting
constructor explicit is nearly as silly as making a copy constructor explicit.

The standards committee discussed this point in February, with Peter Dimov
asking whether https://cplusplus.github.io/LWG/issue2081 should also have been
extended to the converting constructor (and whether not doing so was
intentional or accidental).

I pointed out that the std::uses_allocator trait is defined in terms of
is_convertible not is_constructible, so it doesn't work for your allocator
type. That strongly suggests that types with explicit conversions are not
expected to work properly as allocators.

The conclusion was that we should fix the standard so that implicit conversions
are required to meet the Allocator requirements.

Reply via email to