10template<
typename Type>
16template<
typename Type>
26 stream <<
"Before calling increment(n): " << n <<
endl;
28 stream <<
"After calling increment(n): " << n <<
endl;
30 stream <<
"Before calling increment<int&>(n): " << n <<
endl;
32 stream <<
"After calling increment<int&>(n): " << n <<
endl;
34 stream <<
"Before calling increment(std::ref(n)): " << n <<
endl;
36 stream <<
"After calling increment(std::ref(n)): " << n <<
endl;
39 std::thread t{ increment<int>, n};
43 stream <<
"After the thread t finished: " << n <<
endl;
46 std::thread s{ increment<int&>,
std::ref(n)};
50 stream <<
"After the thread s finished: " << n <<
endl;
64 stream <<
"After the thread u finished: " << n <<
endl;
81 std::thread w{ [](
auto&& arg){
return arg *= arg; },
87 stream <<
"After the thread w finished: " << n <<
endl;
91template<
typename Type>
99 template<
typename UType>
102 Type& lvalue = std::forward<UType>(val);
107 this->m_ptr = std::addressof(lvalue);
110 operator Type&()
const noexcept
111 {
return *this->m_ptr; }
113 Type&
get() const noexcept
114 {
return *this->m_ptr; }
117template<
typename Type>
127 stream <<
"Before calling increment(n): " << n <<
endl;
129 stream <<
"After calling increment(n): " << n <<
endl;
131 stream <<
"Before calling increment<int&>(n): " << n <<
endl;
133 stream <<
"After calling increment<int&>(n): " << n <<
endl;
135 stream <<
"Before calling increment(std::ref(n)): " << n <<
endl;
137 stream <<
"After calling increment(std::ref(n)): " << n <<
endl;
140 std::thread t{ increment<int>, n};
144 stream <<
"After the thread t finished: " << n <<
endl;
147 std::thread s{ increment<int&>,
ref(n)};
151 stream <<
"After the thread s finished: " << n <<
endl;
165 stream <<
"After the thread u finished: " << n <<
endl;
182 std::thread w{ [](
auto&& arg){
return arg *= arg; },
188 stream <<
"After the thread w finished: " << n <<
endl;
void examples_for_custom_ref()
void examples_for_std_ref()
reference_wrapper< Type > ref(Type &val) noexcept
Type & get() const noexcept
reference_wrapper(UType &&val)
Stream output operators << are implemented.