GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::mem_fun_ref(3) C++ Standard Libary std::mem_fun_ref(3)

std::mem_fun_ref - std::mem_fun_ref


Defined in header <functional>
template< class Res, class T > (1) (deprecated in C++11)
std::mem_fun_ref_t<Res,T> mem_fun_ref( Res (T::*f)() ); (removed in C++17)
template< class Res, class T > (deprecated in C++11)
std::const_mem_fun_ref_t<Res,T> mem_fun_ref( Res (T::*f)() (1) (removed in C++17)
const );
template< class Res, class T, class Arg > (deprecated in C++11)
std::mem_fun1_ref_t<Res,T,Arg> mem_fun_ref( Res (2) (removed in C++17)
(T::*f)(Arg) );
template< class Res, class T, class Arg > (deprecated in C++11)
std::const_mem_fun1_ref_t<Res,T,Arg> mem_fun_ref( Res (2) (removed in C++17)
(T::*f)(Arg) const );


Creates a member function wrapper object, deducing the target type from the template
arguments. The wrapper object expects a reference to an object of type T as the
first parameter to its operator().


1) Effectively calls std::mem_fun_ref_t<S,T>(f) or std::const_mem_fun_ref_t<S,T>(f).
2) Effectively calls std::mem_fun1_ref_t<S,T>(f) or
std::const_mem_fun1_ref_t<S,T>(f).


This function and the related types were deprecated in C++11 and removed in C++17 in
favor of the more general std::mem_fn and std::bind, both of which create callable
adaptor-compatible function objects from member functions.


f - pointer to a member function to create a wrapper for


A function object wrapping f.


May throw implementation-defined exceptions.


The difference between std::mem_fun and std::mem_fun_ref is that the former produces
an function wrapper that expects a pointer to an object, whereas the latter -- a
reference.


Uses std::mem_fun_ref to bind std::string's member function size().

// Run this code


#include <functional>
#include <vector>
#include <string>
#include <iterator>
#include <algorithm>
#include <iostream>


int main()
{
std::vector<std::string> v = {"once", "upon", "a", "time"};
std::transform(v.begin(), v.end(),
std::ostream_iterator<std::size_t>(std::cout, " "),
std::mem_fun_ref(&std::string::size));
}


4 4 1 4


mem_fun creates a wrapper from a pointer to member function, callable
(deprecated in C++11) with a pointer to object
(removed in C++17) (function template)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.