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

--- Comment #2 from Antony Polukhin <antoshkka at gmail dot com> ---
You are right.

But those wrong usages are simple to catch and a static_assert with a readable
message would be a huge help for users:

template <class T>
struct assert_complete {
    typedef char yes_type;
    struct no_type { char data[10]; };

    template <class U> static yes_type test(std::integral_constant<std::size_t,
sizeof(U)>* = 0);
    template <class U> static no_type test(...);

    static_assert(sizeof(test<T>(0)) == sizeof(yes_type), "T must be a complete
type");
};

// ...
template<typename _Tp, typename... _Args>
  struct is_constructible
  : public __is_constructible_impl<_Tp, _Args...>::type
  {
    static constexpr assert_complete<_Tp> _complete{};
  };



Now user will get a nice error message:


main.cpp: In instantiation of 'struct assert_complete<foo>':
main.cpp:16:10:   required from 'struct is_constructible<foo, foo>'
main.cpp:25:31:   required from here
main.cpp:12:5: error: static assertion failed: T must be a complete type

Reply via email to