templates compile time error


I am writing a generic wrapper over STL priority queue class as follows

template <class TBLOCKTYPE , class TSORTING_CRITERIA>
class CCL_BlockPriorityQueue
{
public:

// Constructor that takes a fully initialised PQ as argument.
// Same is passed from component factory
CCL_BlockPriorityQueue
(

priority_queue<TBLOCKTYPE *, vector<TBLOCKTYPE
*> ,TSORTING_CRITERIA > * pPriorityQ = 0
) ;
};

I intend to have different sorting criterias predicate classes as follows
// Generic interfcae for sorting design blocks of any type

class CCL_BlockSorter
{
public:


// Predicate for sorting block of any type
virtual bool operator () () = 0;

protected:

private:


} ;

//--------------------------SPECIALISED CASE -----------------------------------

class CCL_BlockSorter_Degree:public CCL_BlockSorter
{
public:

virtual bool operator () () ;

protected:

private:


} ;

why doesnt the following line of code compiles ?
PQ_MACRO_GENERIC * pBlockDegreeSorter = new PQ_MACRO_DEGREE ( new priority_queue< CCL_MacroBlock *,
MACRO_BLK_LIST ,MACRO_SORTER_DEGREE > () ) ;

Where following are the typedefs used
typedef CCL_BlockSorter MACRO_SORTER_GENERIC ;
typedef CCL_BlockPriorityQueue<CCL_MacroBlock,MACRO_SORTER_GENERIC * > PQ_MACRO_GENERIC ;


typedef CCL_BlockSorter_Degree MACRO_SORTER_DEGREE ;
typedef CCL_BlockPriorityQueue<CCL_MacroBlock,MACRO_SORTER_DEGREE * > PQ_MACRO_DEGREE ;

typedef vector<CCL_MacroBlock *> MACRO_BLK_LIST ;

I am getting the following compile time error when comiling on VC6.0 compiler

cannot convert parameter 1 from 'class std::priority_queue<class CCL_Mac
roBlock *,class std::vector<class CCL_MacroBlock *,class std::allocator<class CCL_MacroBlock *> >,class CCL_BlockSorter_Degree> *' to 'class std::priority_queue<class CCL_MacroBlock *,class std::vector<class CCL_MacroBlock *,class std::allocator<cla
ss CCL_MacroBlock *> >,class CCL_BlockSorter_Degree *> *'

Can anyone please help me on this
Thanks
Himanshu Srivastava
STMicroelectronics

It's because all of your typedefs are making the problem harder to see.

PQ_MACRO_DEGREE is a typedef for a CCL_BlockPriorityQueue<> template instantiation whose last template parameter is a pointer to a CCL_BlockSorter_Degree.

But your new PQ_MACRO_DEGREE line passes is MACRO_SORTER_DEGREE as the last template parameter, which is not a pointer.

Topic archived. No new replies allowed.