help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

object ptr as template parameter


From: Michael D. Berger & Rosalie A. Clavez
Subject: object ptr as template parameter
Date: Tue, 28 May 2002 13:59:17 -0400

Using gcc 2.95.3-5(in Cygwin), I would have expected the following attempt to
pass a class pointer through a template parameter to work.  It fails,
as indicated below.  Anyone know why?

Thanks for your advice,
Mike.  

--

In external space:

MyAlloc myAlloc;

main()
{
        ArrayAllocBridge<int,MyAlloc,&myAlloc>          bridge;
}

In another included file:

template<class TYP,class ALLOC,ALLOC* ALC=0>
class ArrayAllocBridge
{
public:
        ArrayAllocBridge();
...
private:
        ALLOC*  allocator_;
...
};

template<class TYP,class ALLOC,ALLOC* ALC>
ArrayAllocBridge<TYP,ALLOC,ALLOC*>::
ArrayAllocBridge()
{
        allocator_ = ALC;
}

Here is the diagnostic:

ArrayAlloc.ii:215: type/value mismatch at argument 3 in template parameter
list for `template <class TYP, class ALLOC, ALLOC * ALC = 0>
ArrayAllocBridge<TYP,ALLOC,ALC>'
../MdbUtil/ArrayAlloc.ii:215:   expected a constant of type `ALLOC *',
got `ALLOC *'   
-- 
Michael D. Berger
Rosalie A. Clavez
m.d.berger@ieee.org



reply via email to

[Prev in Thread] Current Thread [Next in Thread]