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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #1)
> Even if we remove the constrained function template and just write an
> assertion based on the underlying built-in, there's no more information:
> 
> struct A {
>     explicit A(int) {}
> };
> 
> template <typename T>
> struct Foo {
>     T a = 1;
> };
> 
> auto tryit() {
>   static_assert( __is_constructible(Foo<A>) );
> }

For this simpler case, Clang gives:

def.cc:7:11: error: no viable conversion from 'int' to 'A'
    7 |     T a = 1;
      |           ^
def.cc:6:8: note: in instantiation of default member initializer 'Foo<A>::a'
requested here
    6 | struct Foo {
      |        ^
def.cc:11:18: note: in evaluation of exception specification for 'Foo<A>::Foo'
needed here
   11 |   static_assert( __is_constructible(Foo<A>) );
      |                  ^
def.cc:1:8: note: candidate constructor (the implicit copy constructor) not
viable: no known conversion from 'int' to 'const A &' for 1st argument
    1 | struct A {
      |        ^
def.cc:1:8: note: candidate constructor (the implicit move constructor) not
viable: no known conversion from 'int' to 'A &&' for 1st argument
    1 | struct A {
      |        ^
def.cc:2:14: note: explicit constructor is not a candidate
    2 |     explicit A(int) {}
      |              ^
1 error generated.


Which I suppose is much closer to what Barry is asking for. So it's certainly
possible, and I'm just not very imaginative.

Reply via email to