fork download
#include <vector>
#include <set>
#include <iostream>

using namespace std;

class Container
{
public:
    Container() {}
    Container(int _i) : i(_i) {}

    int get_i() const {return i;}

    int i;
};

    template <
        class U, 
        class V, 
        template <typename...> class T1,
        template <typename...> class T2
    >

    T2<V> WugMap(
        T1<U>& unmapped, 
        V (U::*method)() const)
    {
        T2<V> collection;
	for (typename T1<U>::iterator i = unmapped.begin(); i != unmapped.end(); ++i)
            collection.insert(collection.end(), ((*i).*method)());

        return collection;
    }

int main()
{
    vector<Container> containers;
    for (int i = 0; i < 10; ++i) containers.push_back((Container(i)));

    set<int> contained = WugMap<Container, int, std::vector, std::set>(containers, &Container::get_i);
    for (set<int>::iterator derp = contained.begin(); derp != contained.end(); ++derp) cout << *derp << " " << endl;
}
Success #stdin #stdout 0s 3020KB
stdin
Standard input is empty
stdout
0 
1 
2 
3 
4 
5 
6 
7 
8 
9