Scott Zhong wrote:
std::string xmant = x.before_ + x.after_;

if (y.before_.length() > x.before_.length()) {

    xmant.insert(0, y.before_.length() - x.before_.length(), '0' );

  }

gcc -D_RWCONFIG=12d -I. -I./../../../../include -I.. -fPIC -O2 -pthread
-ftemplate-depth-32 -D_RWCONFIG=12d -I/build/sourcepro/include -c
../t.cpp

call of overloaded `insert(int, unsigned int, char)' is

   ambiguous

It looks like it's actually a bug (or accident) that's allowed by
the standard.

As we discussed privately, there are two overloads of insert that
match the call:

    insert(size_type, size_type, value_type);

and

    insert(iterator, size_type, value_type);

An implementation is allowed to define iterator to whatever type
it wants, including pointer. Since the literal 0 is an integer as
well the null pointer constant, the call is ambiguous. So it's a
matter of quality of implementation (rather than one of conformance)
to handle this case.

Anyway, the answer to your question ("Is this something that needs
to fixed or just need to be noted somewhere?") is "it would be nice
to handle this case without the error" so we should have an issue
for it in Jira. The test case is simple:

#include <string>
int main ()
{
    std::string s;
    unsigned n = 3;

    s.insert (0, n, 'x');
}

Martin


/build/sourcepro/include/string:406: candidates

   are: std::basic_string<_CharT, _Traits, _Allocator>&

   std::basic_string<_CharT, _Traits,

   _Allocator>::insert(_Allocator::size_type, _Allocator::const_pointer,

   _Allocator::size_type) [with _CharT = char, _Traits =

   std::char_traits<char>, _Allocator = std::allocator<char>] <near
match>

/build/sourcepro/include/string:434:

         void std::basic_string<_CharT, _Traits,

   _Allocator>::insert(_Allocator::pointer, _Allocator::const_pointer,

   _Allocator::const_pointer) [with _CharT = char, _Traits =

   std::char_traits<char>, _Allocator = std::allocator<char>] <near
match>

/build/sourcepro/include/string:444:

         void std::basic_string<_CharT, _Traits,

   _Allocator>::insert(_Allocator::pointer, _Allocator::pointer,

   _Allocator::pointer) [with _CharT = char, _Traits =
std::char_traits<char>,

   _Allocator = std::allocator<char>] <near match>

/build/sourcepro/include/string:470:

         void std::basic_string<_CharT, _Traits,

   _Allocator>::insert(_Allocator::pointer, _Allocator::size_type,

   _Traits::char_type) [with _CharT = char, _Traits =
std::char_traits<char>,

   _Allocator = std::allocator<char>]

/build/sourcepro/include/string:475:

         std::basic_string<_CharT, _Traits, _Allocator>&

   std::basic_string<_CharT, _Traits,

   _Allocator>::insert(_Allocator::size_type, _Allocator::size_type,

   _Traits::char_type) [with _CharT = char, _Traits =
std::char_traits<char>,

   _Allocator = std::allocator<char>]



Reply via email to