Warum behauptet is_constructible, dass etwas konstruierbar ist, wenn dies nicht der Fall ist?
Das folgende Programm erzeugt, wenn es mit GCC 4.7 oder Clang 3.2 kompiliert wird, "1" als Ausgabe.
#include <type_traits>
struct foo {
template<typename T>
foo(T) {
static_assert(not std::is_same<int, T>(), "no ints please");
}
};
#include <iostream>
int main() {
std::cout << std::is_constructible<foo, int>();
}
Das ist verwirrend.foo
ist ganz klar nicht konstruierbar ausint
! Wenn ich mich änderemain
Im Folgenden lehnen beide Compiler es ab, da die statische Zusicherung fehlschlägt:
int main() {
foo(0);
}
Wie kommt es, dass beide Compiler sagen, dass es konstruierbar ist?