Solved

problems using bind2nd

Posted on 2002-05-03
2
262 Views
Last Modified: 2006-11-17
Hi,
I'm using following line in Visual Studio:
for_each(Array.begin(),Array.end(),
bind2nd(mem_fun(&Vertex::Calculate),Radius));

when Array is a std::vector of pointers to Vertex.
class Vertex
{
public:
...
   void Calculate(double Radius);
...
}

But then I get the following error:
error C2784: 'class std::mem_fun_t<_R,_Ty> __cdecl std::mem_fun(_R (__thiscall _Ty::*)(void))' : could not deduce template argument for '<Unknown>' from 'void (__thiscall Vertex::*)(double)'

what could be the problem? And how to fix it?
thanks
0
Comment
Question by:borlip
  • 2
2 Comments
 
LVL 3

Accepted Solution

by:
GGRUNDY earned 50 total points
ID: 6989235
Initial comment....
as your member function takes and argument you need to be using mem_fun1.

(I know it doesnt' say this in Bjarne's 3rd edition)
0
 
LVL 3

Expert Comment

by:GGRUNDY
ID: 6989262
and...
I had to make the Calculate function return an integer just to keeps the templates happy :-(

class Vertex
{
public:
...
  int Calculate(double Radius);
...
}

see http://cpptips.hyperformix.com/cpptips/ret_void_ref
for more info. Bjarne is onto it :-)

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Create string splitting user defined function in C++ 23 291
Implementing a ResolveEventHandler in C++ 13 115
Would like to move button in a function 3 72
Issues with C++ Class 19 81
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now