 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Leo Jay Guest
|
Posted: Mon Oct 16, 2006 6:14 pm Post subject: why there is no function named mem_data in c++ standard? |
|
|
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
|
Posted: Mon Oct 16, 2006 10:17 pm Post subject: Re: why there is no function named mem_data in c++ standard? |
|
|
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 |
|
 |
|
|
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
|
|