|
-
May 14th, 2006, 11:34 PM
#1
Template function not generated?
I'm trying to make a simple vector class using meta programming. I'm using GCC's 3.3.4 compiler. Here's the code.
Code:
template<int N, int I = 0, int Stride = 1>
class VecOps
{
enum { loopflag = (I < N-1) ? 1 : 0 };
public:
template<class expr>
static inline void Zero(typename expr::iterator v) {
v[I] = typename expr::value_type();
VecOps<loopflag*N, loopflag*(I+1)>::Zero(v);
}
};
template<>
class VecOps<0>
{
public:
template<class expr>
static inline void Zero(typename expr::iterator v) {
}
};
template<class T, std::size_t dims>
class Vector
{
public: //exactly the same a boosts array class definitions
typedef T value_type;
typedef T* iterator;
typedef const T* const_iterator;
typedef std::reverse_iterator<iterator> reverse_iterator;
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
typedef T& reference;
typedef const T& const_reference;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
private:
value_type v[dims];
public:
Vector() {
VecOps<dims>::Zero(begin()); //error references this
}
iterator begin() {
return &v[0];
}
iterator end() {
return &v[dims-1];
}
};
When compiling, I get the following error:
error: no matching function for call to `VecOps<3, 0, 1>::Zero(int*)
What am I doing wrong? GCC compiled the blitz++ library perfectly.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|