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;
}

Reply via email to