Reputation: 760
In the following code, which of the assignment to handler is correct or are they both equivalent to each other
#include <string>
#include <functional>
struct mything {
using handler_t = std::function<void(const std::string&, double)>;
void register_handler(handler_t&& handler) {
/*option1:*/ handler_ = std::move(handler);
/*option2:*/ handler_ = handler;
}
handler_t handler_;
};
int main() {
mything mt;
mt.register_handler([](const std::string&, double)->void {});
return 0;
}
Upvotes: 6
Views: 55