可以用参数包编译c++17 lambda继承的编译器
Compiler which can compile c++17 lambda inheritance with parameter pack
我读到了 using function declaration,我想编译最后一个例子。这是:
#include <iostream>
template <typename... Ts>
struct Overloader : Ts... {
using Ts::operator()...; // exposes operator() from every base
};
template <typename... T>
constexpr auto make_overloader(T&&... t) {
return Overloader<T...>{std::forward<T>(t)...};
}
int main() {
auto o = make_overloader([] (auto const& a) {std::cout << a;},
[] (float f) {std::cout << 13 << f;});
}
即使我已经知道并理解它会做什么,我也想编译和测试它。
但是,clang-4.0 和 g++-7.0 目前似乎都无法编译它。有没有我可以尝试的任何编译器的地方?
P0195,提议的语言扩展允许:
template <typename... Ts>
struct Overloader : Ts... {
using Ts::operator()...; // <== ill-formed without p0195
};
几周前(2016 年 11 月)才在 Issaquah 中被 C++ 接受。 gcc 或 clang 还没有实现它也就不足为奇了。给他们时间。
目前的解决方法是为 Overloader
创建线性层次结构。
我读到了 using function declaration,我想编译最后一个例子。这是:
#include <iostream>
template <typename... Ts>
struct Overloader : Ts... {
using Ts::operator()...; // exposes operator() from every base
};
template <typename... T>
constexpr auto make_overloader(T&&... t) {
return Overloader<T...>{std::forward<T>(t)...};
}
int main() {
auto o = make_overloader([] (auto const& a) {std::cout << a;},
[] (float f) {std::cout << 13 << f;});
}
即使我已经知道并理解它会做什么,我也想编译和测试它。 但是,clang-4.0 和 g++-7.0 目前似乎都无法编译它。有没有我可以尝试的任何编译器的地方?
P0195,提议的语言扩展允许:
template <typename... Ts>
struct Overloader : Ts... {
using Ts::operator()...; // <== ill-formed without p0195
};
几周前(2016 年 11 月)才在 Issaquah 中被 C++ 接受。 gcc 或 clang 还没有实现它也就不足为奇了。给他们时间。
目前的解决方法是为 Overloader
创建线性层次结构。