- /* implicit */ FunctionRef(Fun&& fun) noexcept {
- using ReferencedType = typename std::remove_reference<Fun>::type;
-
- static_assert(
- std::is_convertible<
- typename std::result_of<ReferencedType&(Args && ...)>::type,
- ReturnType>::value,
- "FunctionRef cannot be constructed from object with "
- "incompatible function signature");
-
- // `Fun` may be a const type, in which case we have to do a const_cast
- // to store the address in a `void*`. This is safe because the `void*`
- // will be cast back to `Fun*` (which is a const pointer whenever `Fun`
- // is a const type) inside `FunctionRef::call`
- object_ = const_cast<void*>(static_cast<void const*>(std::addressof(fun)));
- call_ = &FunctionRef::call<ReferencedType>;
- }
+ constexpr /* implicit */ FunctionRef(Fun&& fun) noexcept
+ // `Fun` may be a const type, in which case we have to do a const_cast
+ // to store the address in a `void*`. This is safe because the `void*`
+ // will be cast back to `Fun*` (which is a const pointer whenever `Fun`
+ // is a const type) inside `FunctionRef::call`
+ : object_(
+ const_cast<void*>(static_cast<void const*>(std::addressof(fun)))),
+ call_(&FunctionRef::call<Fun>) {}