T
toton
Hi,
I want to specialize template member function of a template class .
It is creating some syntax problem ....
Can anyone say how to do it ?
The class is something like this
template<typename T,typename Alloc = std::allocator<T> >
class CircularBuffer4 {
public:
typedef typename CircularBuffer<T,Alloc>::size_type
size_type;
private:
CircularBuffer<T,Alloc> x_;
CircularBuffer<T,Alloc> y_;
CircularBuffer<T,Alloc> xd_;
CircularBuffer<T,Alloc> yd_;
template<DirectionType dt> const CircularBuffer<T,Alloc>& buf()const;
}
where
enum DirectionType{
dtX,dtY
};
I want to specialize buf for dtX & dtY
template<typename T,typename Alloc>
template<>const CircularBuffer<T,Alloc>&
CircularBuffer4<T,Alloc>::buf<dtX>()const{
return x_;
}
This does not compile,
but,
template<typename T,typename Alloc>
template<DirectionType dt>const CircularBuffer<T,Alloc>&
CircularBuffer4<T,Alloc>::buf()const{
return x_;
}
this compiles ....
In both cases all of the codes are in header (I hadn't made the
specialized template code in a cpp file, hope that doesn't cause
problem)
thanks in advance
abir
I want to specialize template member function of a template class .
It is creating some syntax problem ....
Can anyone say how to do it ?
The class is something like this
template<typename T,typename Alloc = std::allocator<T> >
class CircularBuffer4 {
public:
typedef typename CircularBuffer<T,Alloc>::size_type
size_type;
private:
CircularBuffer<T,Alloc> x_;
CircularBuffer<T,Alloc> y_;
CircularBuffer<T,Alloc> xd_;
CircularBuffer<T,Alloc> yd_;
template<DirectionType dt> const CircularBuffer<T,Alloc>& buf()const;
}
where
enum DirectionType{
dtX,dtY
};
I want to specialize buf for dtX & dtY
template<typename T,typename Alloc>
template<>const CircularBuffer<T,Alloc>&
CircularBuffer4<T,Alloc>::buf<dtX>()const{
return x_;
}
This does not compile,
but,
template<typename T,typename Alloc>
template<DirectionType dt>const CircularBuffer<T,Alloc>&
CircularBuffer4<T,Alloc>::buf()const{
return x_;
}
this compiles ....
In both cases all of the codes are in header (I hadn't made the
specialized template code in a cpp file, hope that doesn't cause
problem)
thanks in advance
abir