Does the std :: string insert method have ambiguous overloads?

Environment: VS2005 C ++ using STLPort 5.1.4.

Compilation of the following code snippet:

std::string copied = "asdf";
char ch = 's';
copied.insert(0,1,ch);

I get an error message:

Error   1   error C2668: 'stlpx_std::basic_string<_CharT,_Traits,_Alloc>::insert' : ambiguous call to overloaded function   

It seems like the problem is calling the insert method on the string object.

Two specific overloads -

void insert ( iterator p, size_t n, char c );
string& insert ( size_t pos1, size_t n, char c );

But given that STLPort uses a simple char * as its iterator, the literal zero in the insert method in my code is ambiguous.

Therefore, when I can easily overcome the problem, hinting, for example,

copied.insert(size_t(0),1,ch);

My question is: is this overload and possible ambiguity intentional in the specification? Or rather, an unintended side effect of a specific STLPort implementation?

(Note that the supplied Microsoft STL does not have this problem, since it has a class for an iterator, not a bare pointer)

+5
3

differents, .

size_t ( ssize_t), int.

, insert(int, int, char) , " ".

int size_t, insert() .

0

Intentionally or not, the problem has more in common with semantics 0than the member functions in question. Perhaps the developers of the Microsoft library (they used Dinkumware the last time I checked) were more cautious in this regard.

0
source

All Articles