C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

why there is no function named mem_data in c++ standard?

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards
View previous topic :: View next topic  
Author Message
Leo Jay
Guest





PostPosted: Mon Oct 16, 2006 6:14 pm    Post subject: why there is no function named mem_data in c++ standard? Reply with quote



since there is a function named mem_fun in c++ standard which returns
an adptor for member functions, i'd like to know, why there is no
function named mem_data which may return an adptor for member data?

if there was one, we could do something like this:

typedef pair<int, double> IDPAIR;
vector<IDPAIR> vct;

// get the sum of the first elements
int sf = sum(vct.begin(), vct.end(), mem_data(&IDPAIR::first));

// get the sum of the second elements
double ss = sum(vct.begin(), vct.end(), mem_data(&IDPAIR::second));


am i right?

thanks,

--
Best Regards,
Leo Jay

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Back to top
Pete Becker
Guest





PostPosted: Mon Oct 16, 2006 10:17 pm    Post subject: Re: why there is no function named mem_data in c++ standard? Reply with quote



Leo Jay wrote:
Quote:
since there is a function named mem_fun in c++ standard which returns
an adptor for member functions, i'd like to know, why there is no
function named mem_data which may return an adptor for member data?


Its name is std::tr1::mem_fn. Also std::tr1::bind. In addition, the
function call operators for std::tr1::reference_wrapper and
std::tr1:function also treat a pointer to member data as a callable
object. For more details, see chapter 6 of my book, "The Standard C++
Library Extensions."

--

-- Pete

Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." For more information about this book, see
www.petebecker.com/tr1book.

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.