Reproducible example:
#include <type_traits>
static_assert(std::is_constructible_v<int[2], int, int>, "fails against my expectations");
I tested this with clang 5 and gcc 7.
Reproducible example:
#include <type_traits>
static_assert(std::is_constructible_v<int[2], int, int>, "fails against my expectations");
I tested this with clang 5 and gcc 7.
From the ref:
If T is an object or reference type and the variable definition
T obj(std::declval<Args>()...);
is well-formed, provides the member constant value equal to true. In all other cases, value is false.
In your example T obj(std::declval<Args>()...);
is not well-formed.
This is because int[2]
is a plain array, which doesn't have any constructor whatsoever.
As a result, this:
int obj[2](int, int);
is ill-formed.
Arrays are aggregates, thus aggregate initialization comes into play here, not construction.
The purpose and definition of std::is_constructible
is to check if an object of the specified type may be constructed as in:
T obj(std::declval<Args>()...);
And the above is simply not well-formed for an array. An array doesn't have any constructors, it is an aggregate and should be initialized with aggregate initialization.