initializer list - C++ map within map initialization -



initializer list - C++ map within map initialization -

i have map defined in following:

map<string, command> _cmd_map;

where command class defined

class command { public: const string description; const map<string, argument> *arguments; const commandfunction function; command(const string &desc, commandfunction func, map<string, argument> *args = nullptr); command(const string &desc, commandfunction func, const map<string, argument> &args); };

how initialize @ origin of .cpp? far can using initializer_list command, *args = nullptr:

const map<string, command> _cmd_map{ { "help", command("show help menu", (commandfunction)&(_cmd_help)) }, { "exit", command("exit ", (commandfunction)&(_cmd_exit)) }, { "quit", command("exit ", (commandfunction)&(_cmd_exit)) }, }

however cannot initialize map within command class way, without creating map before , passing argument. possible directly, like

const map<string, command> _cmd_map{ { "quit", command("exit ", (commandfunction)&(_cmd_exit)), { {"d1", argument("dummy argument 1")}, {"d2", argument("dummy argument 2")}, } } }

c++ initializer-list

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -