这样做在实现上提供了大量的性能优化,其中这些值是运行时值(小基准值为10倍,预期为5-7倍)。然而,我发现C++并不支持这个成语。我试图重构库,以使不太熟悉模板或元编程的开发人员更容易使用。例如,
class Example { static constexpr autoC = A + B; int b {0};cons
add(auto a, auto b); // the decltype(a) is needed to make clang happy// see: https://stackoverflow.com/questions/62779242
return number<decltype(a)>{a}.
这意味着std::bind表达式(不使用std::is_bind_expression)和带有auto参数的lambda。预期的返回类型和参数是已知的。例如:struct is_templated_functor { ... };
using ty = decltype(&decltype(fun)::operator()<int>);
&