For a class containing a vector of strings, suppose we want a constructor which can either pass in a list or a single value. How can the second constructor call the first in an initializer list?
class A {
private:
std::vector<const char*> paths;
public:
A(std::vector<const char*>& paths) : paths(paths) {}
A(const char* p) : A(std::vector<const char*>( { p } ) {}
};
The second constructor is not legal. I can't think of the syntax.
A(const char* p) : A( {p} ) {}
Not that either.