c++ - Stl methods with cmath functions -


I was trying to write a STL method to take a vector log:

 < Code> for_each (vec.begin (), vec.end (), log in);  

but I get it

  to call 'for_each (__ gnu_cxx :: ___ normal_example & lt; double *, std :: vector & Lt; double, std:: allocated  gt; gt; __gnu_cxx :: ___ normal_interface >  

What I collect is due to several versions of the log function, obviously I have to log the function of the log I can write a simple cover around it and call it on it I am here. Which is a simple way to specify which log function I want to inline?

Yes you can put the function in the appropriate type:

  For_each (vec.begin (), vec.end (), (double (*) (double)) logs;  

Another possibility is creating your draft that will accept any type of:

  struct log_f {template  

And, as Billy O'Neill said, you want transform instead of for_each .


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -