First, I must point out that this is my first stack question, so please bear with me.
I am having problems with function overloading in C ++. I am trying to create a function with the following prototypes:
void push_at_command(std::string, std::vector<std::string>, int);
void push_at_command(std::string, std::vector<std::string>, std::vector<std::string>, int);
void push_at_command(std::string, std::vector<std::string>, std::vector<std::string>, std::vector<std::string>, int);
void push_at_command(std::string, std::vector<std::string>, bool, int);
I initially needed the last overload (one with a boolean) to accept boost :: regex instead of a string vector;
void push_at_command(std::string, boost::regex, int);
but ran into ambiguity errors ... so in order to get the code “working” quickly, I thought I would add a prototype to accept the flag and use the first element in the vector to store the regex string, but I seem to encounter similar problems having a logical value.
Here is what I am trying to name these various overloads:
push_at_command(
"AT?S",
boost::assign::list_of("(\\d{3}.\\d{3})"),
true,
0);
push_at_command(
"AT?S",
boost::assign::list_of("L11")("L12"),
0);
push_at_command(
"AT?S",
boost::assign::list_of("L11"),
boost::assign::list_of("L21")("L22"),
0);
And this is the error I get:
error: call of overloaded ‘push_at_command(const char [5], boost::assign_detail::generic_list<char [4]>, boost::assign_detail::generic_list<char [4]>, int)’ is ambiguous
note: candidates are:
note: void push_at_command(std::string, std::vector<std::basic_string<char> >, std::vector<std::basic_string<char> >, int)
note: void push_at_command(std::string, std::vector<std::basic_string<char> >, bool, int)
... which refers to the third function call.
, , bool ( ).
, - , boost:: assign , , , " ".
... , ++.