C++ 调用表达式中可调用参数的完美转发目的?

C++ 调用表达式中可调用参数的完美转发目的?,c++,lambda,c++14,auto,perfect-forwarding,C++,Lambda,C++14,Auto,Perfect Forwarding,在Scott Meyer的书(印刷版)中,他给出了以下示例: auto timeFuncInvocation = [](auto&& func, auto&&... params) { // start timer; std::forward<decltype(func)>(func)( std::forward<decltype(params)>(params)... ); // stop timer and re

在Scott Meyer的书(印刷版)中,他给出了以下示例:

auto timeFuncInvocation = [](auto&& func, auto&&... params) {
  // start timer;
  std::forward<decltype(func)>(func)(
    std::forward<decltype(params)>(params)...
  );
  // stop timer and record elapsed time;
};

出于与参数相同的目的:因此当
Func::operator()
是一个ref限定值时:

struct Functor
{
    void operator ()() const &  { std::cout << "lvalue functor\n"; }
    void operator ()() const && { std::cout << "rvalue functor\n"; }
};
结构函子 {
void操作符()()const&{std::cout当
func
有一个ref限定的函数调用操作符时。Ohhhhh…非常有意义。删除
const
部分,它会更有意义。否,因为
const
右值引用将首选
const&
重载而不是
&
重载:
const Functor f(){返回函子{};};f()();
struct Functor
{
    void operator ()() const &  { std::cout << "lvalue functor\n"; }
    void operator ()() const && { std::cout << "rvalue functor\n"; }
};