-
Notifications
You must be signed in to change notification settings - Fork 53
Closed
Description
struct Foo {
Foo(int num) : num_(num) {}
void print_add(int i) const { std::cout << num_+i << '\n'; }
int num_;
};
const Foo foo1(1);
// fu2::function<int(const Foo&)> fn3 = &Foo::num_; // report fail here
std::function<int(const Foo&)> stdfn3 = &Foo::num_;
std::cout << stdfn3(2) << std::endl;
std::cout << stdfn3(foo1) << std::endl;
error: conversion from 'int Foo::*' to non-scalar type....
gcc version 6.3.0 (GCC)
but it worked with std::bind
fu2::function<int(const Foo&)> fn5 = std::bind(&Foo::num_, _1); // this is ok
cout << fn5(foo1) << endl;
Metadata
Metadata
Assignees
Labels
No labels