With c++17 we have fancy new is_invocable and fancy new prvalues that aren\'t really values.
This permits you to create an object without having to first logically const
You are misusing the Invocable concept. This concept means nothing more than the ability to use std::invoke
on the given function and the provided arguments.
You can't do std::invoke(f, no_move(1))
, as this would provoke a copy/move of the forwarded argument. It is impossible for a prvalue to be used as a parameter through a forwarded call like invoke
. You can pass a prvalue to the forwarding call, but the eventual call to the given function will get an xvalue.
This is a good reason to avoid using immobile types as value parameters in functions. Take them by const&
instead.
C++ does not have a type trait to see if a function can be called with specific parameters in the way that you want.