std::is_constructible on incomplete types

The behavior is undefined.

[meta.unary.prop]

template <class T, class... Args> struct is_constructible;

T and all types in the parameter pack Args shall be complete types,
(possibly cv-qualified) void, or arrays of unknown bound.

That’s a precondition of the meta-function. A contract that your code violates. libc++ is being generous by notifying you.


Mind you, that putting that precondition there and leaving it undefined otherwise is for a reason. A program where two points of instantiation of a template have different meanings is ill-formed NDR. The only sane course of action is demand complete types. And after all, that’s when the trait is most useful anyway.

Leave a Comment