Edit: The problem has been found; there was an asterisk where there shouldn't have been.
here's a trimmed down version of the class:
It compiles fine like this:
however when I had code to construct with an iterator class I wrote:
specifically, when I attempted to construct with the first parameter of the filter class constuctor as vv_row_iterator<double, vector<vector<double> >::iterator, long long> as the first parameter of the filter class constuctor, I get an error like
in Visual Studio (2005 Express and 2010 Express)
I should note, that the actual class attempting to be constructed is not filter but a similiar class, however the constuctor is the same except the name change. I have not attempted to compile construction of the simpler filter class using vv_row_iterator yet.
Why won't this compile?
here's a trimmed down version of the class:
Code:
#ifndef FILTER_HPP
#define FILTER_HPP
#include <algorithm>
class filter
{
private:
double *h, *h_end;
public:
template<typename It, typename Size>
filter(It impulse_response, Size filter_size)
: h(new double[filter_size]), h_end(h + filter_size)
{
for(double* hi=h; hi < h + filter_size; ++hi)
{
*hi = *impulse_response;
++impulse_response;
}
}
filter& operator=(const filter& rhs)
{
if(rhs.size() != this->size())
{
delete[] h;
h = new double[rhs.size()];
}
std::copy(rhs.h, rhs.h_end, h);
return *this;
}
template<typename It, typename size>
void load_filter(It * impulse_response, size filter_size)
{
//allocate if necessary
if(filter_size != this->size())
{
delete[] h;
h = new double[filter_size];
}
//copy data into filter impulse response h
for(double* hi=h; hi < h + filter_size; ++hi)
{
*hi = *impulse_response;
++impulse_response;
}
}
//returns pointer to begining of impulse reponse
const double * begin() const
{
return h;
}
//returns pointer to one past last element of h
const double * end() const
{
return h_end;
}
int size() const
{
return h_end - h;
}
~filter()
{
delete[] h;
}
};
#endif
It compiles fine like this:
Code:
double h[] = {5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0};
filter* f = new filter(h, 8);
however when I had code to construct with an iterator class I wrote:
Code:
template <typename T, typename RowIt, typename ColSize>
class vv_row_iterator
{
RowIt row;
ColSize col;
public:
vv_row_iterator(RowIt _row, ColSize _col)
:row(_row), col(_col)
{
}
vv_row_iterator(const vv_row_iterator& arg)
: row(arg.row), col(arg.col)
{
}
vv_row_iterator & operator=(const vv_row_iterator& rhs)
{
row = rhs.row;
col = rhs.col;
}
T& operator*()
{
return (*row)[col];
}
vv_row_iterator & operator++()
{
++row;
return *this;
}
vv_row_iterator & operator--()
{
--row;
return *this;
}
vv_row_iterator operator++(int)
{
vv_row_iterator temp = *this;
++row;
return temp;
}
vv_row_iterator operator--(int)
{
vv_row_iterator temp = *this;
--row;
return temp;
}
};
specifically, when I attempted to construct with the first parameter of the filter class constuctor as vv_row_iterator<double, vector<vector<double> >::iterator, long long> as the first parameter of the filter class constuctor, I get an error like
Code:
error C2661: 'filter::filter: no overloaded function takes 2 arguments
I should note, that the actual class attempting to be constructed is not filter but a similiar class, however the constuctor is the same except the name change. I have not attempted to compile construction of the simpler filter class using vv_row_iterator yet.
Why won't this compile?