[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

problems using bind2nd

Posted on 2002-05-03
2
Medium Priority
?
268 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 3

Accepted Solution

by:
GGRUNDY earned 200 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

650 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