Tes*_*est 2 c++ fold-expression c++17
Reference fluentCPP article
The below code explanation says that this structure inherits from several lambdas, can be constructed from those lambdas, and folds over the using expression.
template<typename... Lambdas>
struct overloaded : public Lambdas...
{
explicit overloaded(Lambdas... lambdas) : Lambdas(lambdas)... {}
using Lambdas::operator()...;
};
Run Code Online (Sandbox Code Playgroud)
My doubt is that parentheses i.e () indicate a c++17 fold expression but I don't see any enclosing parentheses around the using statement. How will it fold?
这不是折叠表达式。类范围内不能有任何表达式语句。正如您所指出的,折叠表达式语法中没有括号。
这是一个带有参数包扩展的声明。包扩展可以在更多的上下文中使用,而不仅仅是折叠表达式。
这个声明会做什么?
它会声明
using L::operator();
Run Code Online (Sandbox Code Playgroud)
对于L参数包中的每种类型Lambdas。
通常使用与 typedef 相同
这不是该关键字的唯一用例。在此上下文中,它用于将基类的成员(函数)引入派生类。