jeudi 31 janvier 2019

Why does std::is_copy_constructible not behave as expected?

#include <type_traits>

int main()
{
    std::is_constructible_v<int&, const int&>; // false, as expected.
    std::is_copy_constructible_v<int&>; // true, not as expected!
}

According to cppref:

If T is an object or reference type and the variable definition T obj(std::declval()...); is well-formed, provides the member constant value equal to true. In all other cases, value is false.

std::is_copy_constructible_v<int&> should give the same result as std::is_constructible_v<int&, const int&>, however, clang 7.0 gives different results as shown above.

Is this conforming to the C++ standards?

Aucun commentaire:

Enregistrer un commentaire