Q:

C++ templates: Accessing template variables

I am new to C++ world. 
I am trying to implement code using templates.
template<class PageType>
class Book
{
 //implementation
public:
  PageType* FreeQ; //holds the pointers to pages which are yet to be written
  PageType* BusyQ; //holds the pointers to pages which are being written 
  PageType* DoneQ; //holds the pointers to pages which were written
  getPagetoWrite(); //Get from FreeQ and put in BusyQ 
  setPageAsFree();  //Erase data and put in FreeQ
}

//example for PageType implementation
class PlasticType
{
  mutex; // must
  status; // must
  *prev; // must
  *next; // must
  Write( );
  Read();  
}

I want to know whether there is any way to inform the compiler that implementation of PageType must contain specific variables which will be used in class Book implementation (in getPagetoWrite and setPageAsFree)   without creating the instance of the type PageType.
Hope i made myself clear. 

A:

I dont think that it is possible to enforce that PageType  contain specific variables, this is done simple at compile time during template instantiation - and you really dont need anything else. You can use C++11 std::is_base_of to enforce with static_assert that your PageType implements some base class to which you could put getPagetoWrite  and setPageAsFree, but still you will have to instantiate your templates - which is OK.
#include <type_traits>

class Base {
};

class X : public Base {
};

class Z {
};

template <typename T> 
class Foo {
    static_assert(std::is_base_of<Base,T>::value,"must be derived from Base");
public:
    Foo() {
    }
};

int main(int argc, char** argv) {
    Foo<Z> foo_z_type; // gives compile error: static assertion failed: must be derived from Base
    Foo<X> foo_z_type; // OK
    return 0;
}

http://coliru.stacked-crooked.com/a/bf91079681af3b0e

