Jai
Jai

Reputation: 1332

in template<template<class> class T1, class T2>, what is the meaning of <class>?

I found some example of template in Modern C++ Design by A. Alexenderscu
where author used following lines

template
<
class T,
template <class> class CheckingPolicy  // <---- Please explain this line
>
class SmartPtr : public CheckingPolicy<T>
{
...
template
<
class T1,
template <class> class CP1,
>
SmartPtr(const SmartPtr<T1, CP1>& other)
    : pointee_(other.pointee_), CheckingPolicy<T>(other)
{ ... }
};

i do not understand meaning of in marked line. Please explain that line

Upvotes: 1

Views: 3106

Answers (1)

Constructor
Constructor

Reputation: 7473

In this code example SmartPtr class template has one type parameter T and one template parameter CheckingPolicy. CheckingPolicy template template parameter itself has one type parameter: template <class> class CheckingPolicy. I recommend you to format template code which is unclear for you in the following way to make it more understandable:

template
    <
        class T, // type parameter of a SmartPtr class template
        template
            <
                class // type parameter of a template parameter CheckingPolicy
            >
        class CheckingPolicy // template parameter of a SmartPtr class template
    >
class SmartPtr // class template

Upvotes: 2

Related Questions