It seems that is_copy_constructible<T&&>
is false
even when is_copy_constructible<T>
is true
for identical types T
. I've tested this with gcc and with clang and get the same results. Is this expected behaviour? Where does the standard define this? What is the reasoning for this behaviour?
Sample code which compiles with the error "int&& doesn't work"
:
#include <type_traits>
int main() {
static_assert(std::is_copy_constructible<int>::value, "int doesn't work");
static_assert(std::is_copy_constructible<int&>::value, "int& doesn't work");
static_assert(std::is_copy_constructible<int&&>::value, "int&& doesn't work");
return 0;
}
I encountered this situation when I was trying to create a constraint on a template parameter to ensure that the template only works on copy constructible types. Will I need to create a special case for r-value reference types in order to get my template to work with r-value references to copy constructible types?
Aucun commentaire:
Enregistrer un commentaire