c++ - Derived class in multiple inheritance behaves like an aggregate -
i following code (also found in cppreference http://en.cppreference.com/w/cpp/utility/variant/visit) compile (https://wandbox.org/permlink/stcfki0vqlf49bxr)
#include <type_traits> #include <utility> template <typename... types> struct overload : public types... { using types::operator()...; }; template <typename... types> auto make_overload(types&&... instances) { return overload<std::decay_t<types>...>{std::forward<types>(instances)...}; } int main() { auto overloaded = make_overload([](int) {}, [](double) {}); static_cast<void>(overloaded); } how code above compile in c++17? not compile in c++14. happening behind scenes? why variadic using declaration not work in c++14? new feature this?
as can read in parameter_pack,
introduced in c++17
the following list of allowed contexts: [...]
using-declarations
in using declaration, ellipsis may appear in list of declarators, useful when deriving parameter pack:
template <typename... bases> struct x : bases... { using bases::g...; }; x<b, d> x; // ok: b::g , d::g introduced
Comments
Post a Comment