?
Solved

problems using bind2nd

Posted on 2002-05-03
2
Medium Priority
?
267 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses
Course of the Month10 days, 10 hours left to enroll

764 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