In regards to C++17; GCC, Clang, and MSVC consider a trival class type not to be constructible by any of its data member types. Since C++20, GCC and MSVC changed this, allowing the example below to compile.
#include <type_traits>
struct t {
int a;
};
static_assert(std::is_constructible<t, int>{});
Unfortunately, Clang seems to disagree and rejects this code when compiling with -std=c++20
as well. Is this a compiler bug of Clang? And why do all compilers not consider a type like t
to be constructible with an int
when compiling with -std=c++17
? After all, t{0}
seems to be pretty constructible that way.
( )
, not{ }
, and Clang doesn't implement C++20( )
initialization for aggregates yet. – Cavicorn