more dependent types with variadic templates

This follows yesterday's question, where I gave some C++ code that Visual Studio 2013 couldn't handle, and @galop1n kindly provided a workaround, which worked perfectly for that case. But now I've gone a tiny bit further and Visual Studio is giving me grief again.

template <typename T>
using ValueType = typename T::value_type;

template<typename... Containers>
void
foo(const Containers &...args) {
    std::tuple<ValueType<Containers>...> x;
}

template<typename... Containers>
struct Foo {
    std::tuple<ValueType<Containers>...> x;
};

Whenever I try to instantiate either function template foo or class template Foo, I get these two messages:

Test.cpp(21): error C3546: '...' : there are no parameter packs available to expand

and

Test.cpp(21): error C3203: 'ValueType' : unspecialized alias template can't be used as a template argument for template parameter '_Types', expected a real type

In each case (instantiating foo or instantiating Foo), both messages point to the line that defines "x".

UPDATE: My Microsoft bug report now has (in its attachment) all the basic variants of this problem. So that would be the place to watch for a fix.


也许下面的工作VS2013(更详细:/):

template<typename... Containers>
void foo(const Containers &...args) {
    std::tuple<typename std::decay<decltype(*args.begin())>::type...> x;
}

template<typename... Containers>
struct Foo {
    std::tuple<typename std::decay<decltype(*std::declval<Containers>().begin())>::type...> x;
};
链接地址: http://www.djcxy.com/p/66536.html

上一篇: 调用与方法名称相同的函数

下一篇: 使用可变参数模板的更多依赖类型