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?
在尝试重载 << 运算符时,我无法编译以下代码。任何人都可以指出出了什么问题吗?
#include <iostream>
std::ostream& operator<<(std::ostream& i, int n)
{
return i;
}
int main()
{
std::cout << 5 << std::endl;
std::cin.get();
return 0;
}
Run Code Online (Sandbox Code Playgroud)