Talk:cpp/utility/functional/ref
From cppreference.com
< Talk:cpp | utility | functional
[edit] Example
The current example is not easy to understand from my point of view.
I would prefer the simpler above one inspired from wikipedia C++11 Wrapper_reference. The above example is also available on coliru.stacked-crooked.com. Oli (talk) 09:14, 21 July 2014 (PDT)
void increment( int &count )
{
++count;
}
template< class F, class A >
void intermediate( F func, A arg )
{
func(arg);
}
int main()
{
int i = 0;
intermediate( increment, i );
std::cout << "Without std::ref => i="<< i << '\n';
intermediate( increment, std::ref(i) );
std::cout << "Using std::ref => i="<< i << '\n';
}