[Bug libstdc++/107525] propagate_const should not be using SFINAE on its conversion operators
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Nov 4 14:26:28 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107525
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
And the spec seems wrong as well. The const overload should be constrained for
const T being convertible to const element_type*.
This should probably not compile:
#include <experimental/propagate_const>
struct X
{
int& operator*() { return *i; }
const int& operator*() const { return *i; }
int* get() { return i; }
const int* get() const { return i; }
int* i = nullptr;
operator int*() { return i; }
operator const int*() const = delete;
};
int main()
{
using std::experimental::propagate_const;
X x;
const propagate_const<X> px(x);
static_assert(!std::is_convertible_v<const X, const int*>);
static_assert(std::is_convertible_v<const propagate_const<X>, const int*>);
const int* pi = px;
}
More information about the Gcc-bugs
mailing list