#include <complex>
#include <iostream>
// +----- Template Parameter
// |
// V
template<typename T>
class A
{
public:
T mT = T();
};
// +----- Template Template Parameter
// |
// V
template< template<typename> class U >
class B
{
public:
U<int> mU;
};
// +----- Template Template Parameter
// |
// V
template< template<typename> class U >
class C
{
public:
U<std::complex<double>> mU;
};
int main()
{
B<A> b;
std::cout << b.mU.mT << " ";
C<A> c;
std::cout << c.mU.mT << std::endl;
return 0;
}
// Output: 0 (0,0)
Reference: https://en.wikipedia.org/wiki/C%2B%2B17
Tuesday, October 10, 2017
C++17: Template template parameter can be declared typename
Before C++17 , a template template parameter had to be declared class. Here is an example:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment