How can I return any container of ints from a member function? In the following code I've tried maany permutations between the two test classes but nothing seems to compile using g++-4.8.2:

```
#include "vector"

struct test {
    template<class Container> Container<int> ret() {
        return Container<int>();
    }
};

struct test {
    template<
        template<class Int> class Container,
        class Int
    > typename Container<Int> ret() {
        return Container<Int>();
    }
};

int main() {
    std::vector<int> v = test().ret<std::vector<int> >();
    return 0;
}

```

Ideally the program would be c++03 and compile only if int is the contained type. Printing a readable error to the user in other cases would also be nice but I guess that would require either boost or std static\_assert(). Thanks!

**EDIT 1**

Unfortunately the 2 template parameter version only works for a few std containers, the commented out ones cause a compilation error as they require different template parameters:

```
struct test {
    template<
        template<class, class> class Container
    > Container<int, std::allocator<int> > ret() {
        return Container<int, std::allocator<int> >();
    }
};

int main() {
    std::vector<int> v = test().ret<std::vector>();
    std::list<int> l = test().ret<std::list>();
    //std::set<int> se = test().ret<std::set>();
    std::deque<int> d = test().ret<std::deque>();
    //std::stack<int> st = test().ret<std::stack>();
    //std::queue<int> q = test().ret<std::queue>();
    //std::priority_queue<int> p = test().ret<std::priority_queue>();
    return 0;
}

```

but the following c++11 version seems to work for each container:

```
struct test {
    template<
        template<class, class...> class Container,
        class... Container_Params
    > Container<int, Container_Params... > ret() {
        return Container<int, Container_Params... >();
    }
};

int main() {
    auto v = test().ret<std::vector>();
    auto l = test().ret<std::list>();
    auto se = test().ret<std::set>();
    auto d = test().ret<std::deque>();
    auto st = test().ret<std::stack>();
    auto q = test().ret<std::queue>();
    auto p = test().ret<std::priority_queue>();
    auto us = test().ret<boost::unordered_set>();
    return 0;
}

```