Skip to content

Commit

Permalink
move_only_function/op_constructor: fix example
Browse files Browse the repository at this point in the history
  • Loading branch information
yohhoy committed Oct 31, 2023
1 parent 6df7cab commit 1146719
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions reference/functional/move_only_function/op_constructor.md
Expand Up @@ -137,29 +137,29 @@ int main()
// (4) 関数ポインタを受け取って構築
{
std::function<int(int)> f = ident_func;
std::move_only_function<int(int)> f = ident_func;
int result = f(1);
std::cout << "(4) function pointer : " << result << std::endl;
}
// (4) 関数オブジェクトを受け取って構築
{
std::function<int(int)> f = ident_functor();
std::move_only_function<int(int)> f = ident_functor();
int result = f(1);
std::cout << "(4) function object : " << result << std::endl;
}
// (4) メンバ関数ポインタを受け取った構築
{
std::function<int(const X&, int)> f = &X::add_member_func;
std::move_only_function<int(const X&, int)> f = &X::add_member_func;
X x{2};
int result = f(x, 1);
std::cout << "(4) member function pointer : " << result << std::endl;
}
// (4) メンバ変数ポインタを受け取った構築
{
std::function<int(const X&)> f = &X::value;
std::move_only_function<int(const X&)> f = &X::value;
X x{2};
int result = f(x);
std::cout << "(4) member variable pointer : " << result << std::endl;
Expand Down

0 comments on commit 1146719

Please sign in to comment.