Kommentar
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
Constructs a reference_wrapper.
explicit reference_wrapper(Ty& val);
Parameters
Ty
The type to wrap.val
The value to wrap.
Remarks
The constructor sets the stored value ptr to &val.
Example
// std_tr1__functional__reference_wrapper_reference_wrapper.cpp
// compile with: /EHsc
#include <functional>
#include <iostream>
int neg(int val)
{
return (-val);
}
int main()
{
int i = 1;
std::reference_wrapper<int> rwi(i);
std::cout << "i = " << i << std::endl;
std::cout << "rwi = " << rwi << std::endl;
rwi.get() = -1;
std::cout << "i = " << i << std::endl;
return (0);
}
i = 1 rwi = 1 i = -1
Requirements
Header: <functional>
Namespace: std