Compile error

P

Piotr

I have this compile error and I have narrowed down the following piece
of code.
stddev.cpp:133: error: no matching function for call to
'transform(<unknown type>, <unknown type>,
__gnu_cxx::__normal_iterator<float*, std::vector<float,
std::allocator<float> > >, Div)'
gmake[5]: *** [stddev.o] Error 1

I can't figure it out why, I appreciate if anyone can help.



struct Div
{
public:
Div(int max):_max(max) {}
float operator()(int i)
{
return ((float)i/ _max);
}
private:
int _max;
};


float StatUtils::std_dev_max( vector<int>& v , int max)
{

vector<float> v1(v.size());

transform(v.begin, v.end, v1.begin(), Div(max));
return 0.0;
}
 
P

Piotr

Try donig this, but it still does not work:

struct Div : public unary_function<int, float>
{
public:
Div(int max):_max(max) {}
float operator()(int i)
{
return ((float)i/ _max);
}
private:
int _max;
};
 
T

Thomas Tutone

Piotr said:
I have this compile error and I have narrowed down the following piece
of code.
stddev.cpp:133: error: no matching function for call to
'transform(<unknown type>, <unknown type>,
__gnu_cxx::__normal_iterator<float*, std::vector<float,
std::allocator<float> > >, Div)'
[snip]

vector<float> v1(v.size());

transform(v.begin, v.end, v1.begin(), Div(max));

You forgot the "()" after begin and end.

Best regards,

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,235
Latest member
Top Crypto Podcasts_

Latest Threads

Top