Overloaded function ambiguity

Viewed 1411

Firstly I should point out that this is my first stackoverflow question, so please bear with me.

I'm having some problems overloading a function in c++. I'm 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 originally wanted the last overload (the one with the boolean) to accept a boost::regex instead of a string vector;

void push_at_command(std::string, boost::regex, int);

but ran into ambiguity errors... so just to quickly get the code 'working' I thought I'd add a prototype to accept a flag, and use the first element in the vector to store a regex string, but I seem to be running into similar problems having the boolean.

This is how I'm trying to call 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'm getting:

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 relates to the third function call.

Just to note, I had no problems before I added the overload with the bool (or changing the string vector to regex).

I am assuming the problem has something to do with me using boost::assign in the function call, and I realise that I don't need to, but I really need 'single line' function calls. ... Any advice welcome, as I am fairly new to C++.

Thanks

2 Answers
Related