Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does std::is_assignable return false with related pointer types?

Tags:

Given two very simple classes:

class X { };  class Y : public X { }; 

Why is it that, with Clang and GCC targeting C++14, std::is_assignable<X*, Y*>::value is false? It is true with Clang on my setup when I target C++11.

like image 522
zneak Avatar asked Oct 01 '15 17:10

zneak


Video Answer


1 Answers

This is because in your case X* becomes an rvalue. You can't assign to an rvalue. Change to an lvalue instead:

std::is_assignable<X*&, Y*>::value //                  ~^~ 
like image 120
Piotr Skotnicki Avatar answered Nov 27 '22 11:11

Piotr Skotnicki