Dependent types with variable patterns

Can you see something wrong with this function declaration?

template<typename... Containers>
std::tuple<typename Containers::value_type...>
foo(const Containers &...args);

When I try to call it like this:

foo(std::list<int>(), std::vector<float>());

MSVC2013 says error C2027: use of undefined type 'std::tuple<Containers::value_type>.

I tried to rewrite the function declaration with the syntax "late return", and it did not matter.

Is there any way to achieve what this code is trying to do?

+3
source share
1 answer

You got the right to fill out a bug report on microsoft connect ... The code is ok on clang and gcc.

Workaround on VS2013 and possibly gcc 4.7:

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

template<typename... Containers>
std::tuple<ValueType<Containers>...>
foo( const Containers &...args ) { return {}; }
+4
source

All Articles