Initializer-lists as parameters for class constructor

Viewed 89

I have a following class

template <class T>
class Graph {
    private:
        std::vector < std::vector<T> > data;
    public:
        class Edge {
            private:
                T source;
                T destination;
        };
};

I will be trying to model digraph using edge-centric approach (https://stackoverflow.com/a/2157012/1864702).

I want to be able to construct objects of this class in a following way:

enum Country {Poland, Ukraine, Germany, USA};
typedef Graph<Country> GC;

GC gc{
    { Poland, {Ukraine, Germany} },
    { Germany, {Poland, Ukraine, USA} },
    { USA, {Poland, Ukraine, USA} }
};

What kind of arguments should constructor of class Graph take to allow such a syntax?

1 Answers
Related