小编Tes*_*est的帖子

Where is the fold expression ()?

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?

c++ fold-expression c++17

2
推荐指数
1
解决办法
105
查看次数

尝试重载 &lt;&lt; 运算符时出错

在尝试重载 << 运算符时,我无法编译以下代码。任何人都可以指出出了什么问题吗?

#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)

c++ operator-overloading stream c++11

0
推荐指数
1
解决办法
76
查看次数