auto thing = [](int x){ /* Stuff */ };
我想省去“x”值,稍后再调用它,所以我要:
auto other = boost::hana::partial(thing, 42);
现在,因为我想对这个做一些类型擦除,我想取 operator()
operator()
using type = decltype(other); void (type::*ptr)(void) = &type::operator();
克朗抱怨说 other 对象的函数不足以满足以下要求: godbolt
other
看来 partial void ?)……为什么这不起作用?
partial
void
它(运算符())具有 & const& && etc重载;成员函数指针不符合 *this 按常量或r/l值。所以不匹配。
&
const&
&&
*this
添加 & 或 常量; && 或 const&& 之前 = 在无法编译的行上,它将编译。
常量;
const&&
=
这里有一个[MCVE]:
struct foo { void bar()&{} }; int main(){ auto p = &foo::bar; void(foo::*p2)() = p; // lacks & }