user975989
user975989

Reputation: 2648

Casting an alias template to the aliased type

Consider this code:

struct foo {/* stuff */};

template <typename T>
using bar = foo;

// Elsewhere
bar<int> A;
auto &B = static_cast<foo&>(A);

Is using B legal?

Upvotes: 1

Views: 363

Answers (1)

alexeykuzmin0
alexeykuzmin0

Reputation: 6440

Yes, it is. bar<T> is exactly the same type as foo for any T.

Upvotes: 4

Related Questions