Вопрос

The following code does not compile with gcc 4.7 (20120114) , but compiles fine with clang++ 3.0. Is this a bug in gcc, clang or just because what I try to do is not allowed in c++11?

template< typename... args >
struct A {
    template< typename head, typename... tags >
    struct Inner : public Inner<tags...> {
    };

    template< typename head >
    struct Inner<head> {
        // assume both args... and tags... must be used to
        // calculate TYPE
        typedef int TYPE;
    };
};

template< typename... args >
struct B : A<args...> {
    template<typename... tags>
    typename A<args...>::template Inner<tags...>::TYPE x() {
        return 0;
    }
};

int main(int argc, const char *argv[]) {
    B<int, int, int> b;
    b.x<char, short, long, double>();

    return 0;
}

The code above is a very simplified example of what I try to do, but the essence is that I need both the args... types and the tags... types to calculate the return type of the function. How can this be done?

Нет правильного решения

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top