Petar Velev
Petar Velev

Reputation: 2355

Using two types with one template definition

Is it possible to use two different types, one is a subtype of the other, with one template definition?

Something like:

template<typename T>
void foo(T a, T::bar b);

Upvotes: 1

Views: 67

Answers (1)

Cory Kramer
Cory Kramer

Reputation: 117876

You would need one more usage of typename

template <typename T>
void foo(T a, typename T::bar b);

because bar is a "dependent type" of T. See here for more details.

Upvotes: 2

Related Questions