You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@stdcxx.apache.org by "Farid Zaripov (JIRA)" <ji...@apache.org> on 2008/09/05 17:16:44 UTC
[jira] Created: (STDCXX-1009)
std::string::{assign|append|insert|replace} ([iterator, iterator,]
size_type, value_type) ambiguous
std::string::{assign|append|insert|replace} ([iterator, iterator,] size_type, value_type) ambiguous
---------------------------------------------------------------------------------------------------
Key: STDCXX-1009
URL: https://issues.apache.org/jira/browse/STDCXX-1009
Project: C++ Standard Library
Issue Type: Improvement
Components: 21. Strings
Affects Versions: 4.2.1, 4.2.0, 4.1.4, 4.1.3, 4.1.2
Environment: All
Reporter: Farid Zaripov
Assignee: Farid Zaripov
Priority: Minor
Fix For: 4.3.0
The following test case fails to compile:
{code:title=test.cpp}
#include <string>
int main ()
{
char c = 5;
std::string s (4, '0' + c);
s.assign (4, '0' + c);
s.append (4, '0' + c);
s.insert (s.begin (), 4, '0' + c);
s.replace (s.begin (), s.end (), 4, '0' + c);
return 0;
}
{code}
{noformat}
test.cpp
D:\_Libs\stdcxx-4.2.2\include\string(370) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::assign' : 2 overloads have similar conversions
with
[
_CharT=char,
_Traits=std::char_traits<char>,
_Allocator=std::allocator<char>
]
D:\_Libs\stdcxx-4.2.2\include\string(381): could be 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::assign(std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
with
[
_CharT=char,
_Traits=std::char_traits<char>,
_Allocator=std::allocator<char>
]
D:\_Libs\stdcxx-4.2.2\include\string(374): or 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::assign<_InputIter>(_InputIter,_InputIter,void *)'
with
[
_CharT=char,
_Traits=std::char_traits<char>,
_Allocator=std::allocator<char>,
_InputIter=int
]
while trying to match the argument list '(int, int, int)'
test.cpp(7) : see reference to function template instantiation 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::assign<int>(_InputIter,_InputIter)' being compiled
with
[
_CharT=char,
_Traits=std::char_traits<char>,
_Allocator=std::allocator<char>,
_InputIter=int
]
D:\_Libs\stdcxx-4.2.2\include\string(320) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::append' : 2 overloads have similar conversions
with
[
_CharT=char,
_Traits=std::char_traits<char>,
_Allocator=std::allocator<char>
]
D:\_Libs\stdcxx-4.2.2\include\string(330): could be 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::append(std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
with
[
_CharT=char,
_Traits=std::char_traits<char>,
_Allocator=std::allocator<char>
]
D:\_Libs\stdcxx-4.2.2\include\string(324): or 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::append<_InputIter>(_InputIter,_InputIter,void *)'
with
[
_CharT=char,
_Traits=std::char_traits<char>,
_Allocator=std::allocator<char>,
_InputIter=int
]
while trying to match the argument list '(int, int, int)'
test.cpp(8) : see reference to function template instantiation 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::append<int>(_InputIter,_InputIter)' being compiled
with
[
_CharT=char,
_Traits=std::char_traits<char>,
_Allocator=std::allocator<char>,
_InputIter=int
]
D:\_Libs\stdcxx-4.2.2\include\string(422) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::insert' : 2 overloads have similar conversions
with
[
_CharT=char,
_Traits=std::char_traits<char>,
_Allocator=std::allocator<char>
]
D:\_Libs\stdcxx-4.2.2\include\string(432): could be 'void std::basic_string<_CharT,_Traits,_Allocator>::insert(std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
with
[
_CharT=char,
_Traits=std::char_traits<char>,
_Allocator=std::allocator<char>
]
D:\_Libs\stdcxx-4.2.2\include\string(426): or 'void std::basic_string<_CharT,_Traits,_Allocator>::insert<_InputIter>(std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter,void *)'
with
[
_CharT=char,
_Traits=std::char_traits<char>,
_Allocator=std::allocator<char>,
_InputIter=int
]
while trying to match the argument list '(std::basic_string<_CharT,_Traits,_Allocator>::iterator, int, int, int)'
with
[
_CharT=char,
_Traits=std::char_traits<char>,
_Allocator=std::allocator<char>
]
test.cpp(9) : see reference to function template instantiation 'void std::basic_string<_CharT,_Traits,_Allocator>::insert<int>(std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter)' being compiled
with
[
_CharT=char,
_Traits=std::char_traits<char>,
_Allocator=std::allocator<char>,
_InputIter=int
]
D:\_Libs\stdcxx-4.2.2\include\string(616) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::replace' : 2 overloads have similar conversions
with
[
_CharT=char,
_Traits=std::char_traits<char>,
_Allocator=std::allocator<char>
]
D:\_Libs\stdcxx-4.2.2\include\string(605): could be 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::replace(std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
with
[
_CharT=char,
_Traits=std::char_traits<char>,
_Allocator=std::allocator<char>
]
D:\_Libs\stdcxx-4.2.2\include\string.cc(493): or 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::replace<_InputIter>(std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter,void *)'
with
[
_CharT=char,
_Traits=std::char_traits<char>,
_Allocator=std::allocator<char>,
_InputIter=int
]
while trying to match the argument list '(std::basic_string<_CharT,_Traits,_Allocator>::iterator, std::basic_string<_CharT,_Traits,_Allocator>::iterator, int, int, int)'
with
[
_CharT=char,
_Traits=std::char_traits<char>,
_Allocator=std::allocator<char>
]
and
[
_CharT=char,
_Traits=std::char_traits<char>,
_Allocator=std::allocator<char>
]
test.cpp(10) : see reference to function template instantiation 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::replace<int>(std::basic_string<_CharT,_Traits,_Allocator>::ite
rator,std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter)' being compiled
with
[
_CharT=char,
_Traits=std::char_traits<char>,
_Allocator=std::allocator<char>,
_InputIter=int
]
{noformat}
The proposed patch:
{code:title=string.diff}
Index: include/string
===================================================================
--- include/string (revision 691313)
+++ include/string (working copy)
@@ -327,9 +327,10 @@
__first, __last), *this;
}
- basic_string& append (size_type __n, value_type __c, int) {
+ template <class _IntType>
+ basic_string& append (_IntType __n, _IntType __c, int) {
// unnamed arg is used for overload resolution
- return append (__n, __c);
+ return append (size_type (__n), value_type (__c));
}
#else // if defined (_RWSTD_NO_MEMBER_TEMPLATES)
@@ -378,9 +379,11 @@
_C_make_iter (_C_data + size ()), __first, __last);
}
- basic_string& assign (size_type __n, value_type __c, int) {
+ template <class _IntType>
+ basic_string& assign (_IntType __n, _IntType __c, int) {
// unnamed arg is used for overload resolution
- return replace (size_type (), size (), __n, __c);
+ return replace (size_type (), size (),
+ size_type (__n), value_type (__c));
}
#else // if defined (_RWSTD_NO_MEMBER_TEMPLATES)
@@ -429,9 +432,11 @@
replace (__p, __p, __first, __last);
}
- void insert (iterator __p, size_type __n, value_type __c, int) {
+ template <class _IntType>
+ void insert (iterator __p, _IntType __n, _IntType __c, int) {
// unnamed arg is used for overload resolution
- replace (_C_off (__p), size_type (), __n, __c);
+ replace (_C_off (__p), size_type (),
+ size_type (__n), value_type (__c));
}
void insert (iterator __p,
@@ -601,10 +606,12 @@
# endif // _RWSTD_NO_STRING_OUTLINED_MEMBER_TEMPLATES
+ template <class _IntType>
basic_string&
replace (iterator __first, iterator __last,
- size_type __n, value_type __c, int) {
- return replace (_C_off (__first), _C_off (__first, __last), __n, __c);
+ _IntType __n, _IntType __c, int) {
+ return replace (_C_off (__first), _C_off (__first, __last),
+ size_type (__n), value_type (__c));
}
// 21.3.5.6, p21
{code}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (STDCXX-1009)
std::string::{assign|append|insert|replace} ([iterator, iterator,]
size_type, value_type) ambiguous
Posted by "Farid Zaripov (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/STDCXX-1009?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Farid Zaripov updated STDCXX-1009:
----------------------------------
Fix Version/s: (was: 4.3.0)
4.2.2
Reverting fix for STDCXX-968 should help. Setting 'Fix Version' to 4.2.2
> std::string::{assign|append|insert|replace} ([iterator, iterator,] size_type, value_type) ambiguous
> ---------------------------------------------------------------------------------------------------
>
> Key: STDCXX-1009
> URL: https://issues.apache.org/jira/browse/STDCXX-1009
> Project: C++ Standard Library
> Issue Type: Bug
> Components: 21. Strings
> Affects Versions: 4.1.2, 4.1.3, 4.1.4, 4.2.0, 4.2.1
> Environment: All
> Reporter: Farid Zaripov
> Assignee: Farid Zaripov
> Priority: Minor
> Fix For: 4.2.2
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> The following test case fails to compile:
> {code:title=test.cpp}
> #include <string>
> int main ()
> {
> char c = 5;
> std::string s (4, '0' + c);
> s.assign (4, '0' + c);
> s.append (4, '0' + c);
> s.insert (s.begin (), 4, '0' + c);
> s.replace (s.begin (), s.end (), 4, '0' + c);
> return 0;
> }
> {code}
> {noformat}
> test.cpp
> D:\_Libs\stdcxx-4.2.2\include\string(370) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::assign' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(381): could be 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::assign(std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(374): or 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::assign<_InputIter>(_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(int, int, int)'
> test.cpp(7) : see reference to function template instantiation 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::assign<int>(_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(320) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::append' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(330): could be 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::append(std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(324): or 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::append<_InputIter>(_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(int, int, int)'
> test.cpp(8) : see reference to function template instantiation 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::append<int>(_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(422) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::insert' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(432): could be 'void std::basic_string<_CharT,_Traits,_Allocator>::insert(std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(426): or 'void std::basic_string<_CharT,_Traits,_Allocator>::insert<_InputIter>(std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(std::basic_string<_CharT,_Traits,_Allocator>::iterator, int, int, int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> test.cpp(9) : see reference to function template instantiation 'void std::basic_string<_CharT,_Traits,_Allocator>::insert<int>(std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(616) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::replace' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(605): could be 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::replace(std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string.cc(493): or 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::replace<_InputIter>(std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(std::basic_string<_CharT,_Traits,_Allocator>::iterator, std::basic_string<_CharT,_Traits,_Allocator>::iterator, int, int, int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> and
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> test.cpp(10) : see reference to function template instantiation 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::replace<int>(std::basic_string<_CharT,_Traits,_Allocator>::ite
> rator,std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> {noformat}
> The proposed patch:
> {code:title=string.diff}
> Index: include/string
> ===================================================================
> --- include/string (revision 691313)
> +++ include/string (working copy)
> @@ -327,9 +327,10 @@
> __first, __last), *this;
> }
>
> - basic_string& append (size_type __n, value_type __c, int) {
> + template <class _IntType>
> + basic_string& append (_IntType __n, _IntType __c, int) {
> // unnamed arg is used for overload resolution
> - return append (__n, __c);
> + return append (size_type (__n), value_type (__c));
> }
>
> #else // if defined (_RWSTD_NO_MEMBER_TEMPLATES)
> @@ -378,9 +379,11 @@
> _C_make_iter (_C_data + size ()), __first, __last);
> }
>
> - basic_string& assign (size_type __n, value_type __c, int) {
> + template <class _IntType>
> + basic_string& assign (_IntType __n, _IntType __c, int) {
> // unnamed arg is used for overload resolution
> - return replace (size_type (), size (), __n, __c);
> + return replace (size_type (), size (),
> + size_type (__n), value_type (__c));
> }
>
> #else // if defined (_RWSTD_NO_MEMBER_TEMPLATES)
> @@ -429,9 +432,11 @@
> replace (__p, __p, __first, __last);
> }
>
> - void insert (iterator __p, size_type __n, value_type __c, int) {
> + template <class _IntType>
> + void insert (iterator __p, _IntType __n, _IntType __c, int) {
> // unnamed arg is used for overload resolution
> - replace (_C_off (__p), size_type (), __n, __c);
> + replace (_C_off (__p), size_type (),
> + size_type (__n), value_type (__c));
> }
>
> void insert (iterator __p,
> @@ -601,10 +606,12 @@
>
> # endif // _RWSTD_NO_STRING_OUTLINED_MEMBER_TEMPLATES
>
> + template <class _IntType>
> basic_string&
> replace (iterator __first, iterator __last,
> - size_type __n, value_type __c, int) {
> - return replace (_C_off (__first), _C_off (__first, __last), __n, __c);
> + _IntType __n, _IntType __c, int) {
> + return replace (_C_off (__first), _C_off (__first, __last),
> + size_type (__n), value_type (__c));
> }
>
> // 21.3.5.6, p21
> {code}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (STDCXX-1009)
std::string::{assign|append|insert|replace} ([iterator, iterator,]
size_type, value_type) ambiguous
Posted by "Farid Zaripov (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/STDCXX-1009?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Farid Zaripov updated STDCXX-1009:
----------------------------------
Regression: [Regression]
Hmm. The 21.string.exceptions.cpp test fails to compile due to this bug, but this test compiles successfully with stdcxx-4.2.1 !!!
The only difference is [this|http://svn.apache.org/viewvc?view=rev&revision=682771] change.
The 21.string.stdcxx-1009.cpp regression test also compiles fine with stdcxx-4.2.1.
Making the issue as regression.
> std::string::{assign|append|insert|replace} ([iterator, iterator,] size_type, value_type) ambiguous
> ---------------------------------------------------------------------------------------------------
>
> Key: STDCXX-1009
> URL: https://issues.apache.org/jira/browse/STDCXX-1009
> Project: C++ Standard Library
> Issue Type: Bug
> Components: 21. Strings
> Affects Versions: 4.1.2, 4.1.3, 4.1.4, 4.2.0, 4.2.1
> Environment: All
> Reporter: Farid Zaripov
> Assignee: Farid Zaripov
> Priority: Minor
> Fix For: 4.3.0
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> The following test case fails to compile:
> {code:title=test.cpp}
> #include <string>
> int main ()
> {
> char c = 5;
> std::string s (4, '0' + c);
> s.assign (4, '0' + c);
> s.append (4, '0' + c);
> s.insert (s.begin (), 4, '0' + c);
> s.replace (s.begin (), s.end (), 4, '0' + c);
> return 0;
> }
> {code}
> {noformat}
> test.cpp
> D:\_Libs\stdcxx-4.2.2\include\string(370) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::assign' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(381): could be 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::assign(std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(374): or 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::assign<_InputIter>(_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(int, int, int)'
> test.cpp(7) : see reference to function template instantiation 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::assign<int>(_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(320) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::append' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(330): could be 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::append(std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(324): or 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::append<_InputIter>(_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(int, int, int)'
> test.cpp(8) : see reference to function template instantiation 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::append<int>(_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(422) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::insert' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(432): could be 'void std::basic_string<_CharT,_Traits,_Allocator>::insert(std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(426): or 'void std::basic_string<_CharT,_Traits,_Allocator>::insert<_InputIter>(std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(std::basic_string<_CharT,_Traits,_Allocator>::iterator, int, int, int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> test.cpp(9) : see reference to function template instantiation 'void std::basic_string<_CharT,_Traits,_Allocator>::insert<int>(std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(616) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::replace' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(605): could be 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::replace(std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string.cc(493): or 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::replace<_InputIter>(std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(std::basic_string<_CharT,_Traits,_Allocator>::iterator, std::basic_string<_CharT,_Traits,_Allocator>::iterator, int, int, int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> and
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> test.cpp(10) : see reference to function template instantiation 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::replace<int>(std::basic_string<_CharT,_Traits,_Allocator>::ite
> rator,std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> {noformat}
> The proposed patch:
> {code:title=string.diff}
> Index: include/string
> ===================================================================
> --- include/string (revision 691313)
> +++ include/string (working copy)
> @@ -327,9 +327,10 @@
> __first, __last), *this;
> }
>
> - basic_string& append (size_type __n, value_type __c, int) {
> + template <class _IntType>
> + basic_string& append (_IntType __n, _IntType __c, int) {
> // unnamed arg is used for overload resolution
> - return append (__n, __c);
> + return append (size_type (__n), value_type (__c));
> }
>
> #else // if defined (_RWSTD_NO_MEMBER_TEMPLATES)
> @@ -378,9 +379,11 @@
> _C_make_iter (_C_data + size ()), __first, __last);
> }
>
> - basic_string& assign (size_type __n, value_type __c, int) {
> + template <class _IntType>
> + basic_string& assign (_IntType __n, _IntType __c, int) {
> // unnamed arg is used for overload resolution
> - return replace (size_type (), size (), __n, __c);
> + return replace (size_type (), size (),
> + size_type (__n), value_type (__c));
> }
>
> #else // if defined (_RWSTD_NO_MEMBER_TEMPLATES)
> @@ -429,9 +432,11 @@
> replace (__p, __p, __first, __last);
> }
>
> - void insert (iterator __p, size_type __n, value_type __c, int) {
> + template <class _IntType>
> + void insert (iterator __p, _IntType __n, _IntType __c, int) {
> // unnamed arg is used for overload resolution
> - replace (_C_off (__p), size_type (), __n, __c);
> + replace (_C_off (__p), size_type (),
> + size_type (__n), value_type (__c));
> }
>
> void insert (iterator __p,
> @@ -601,10 +606,12 @@
>
> # endif // _RWSTD_NO_STRING_OUTLINED_MEMBER_TEMPLATES
>
> + template <class _IntType>
> basic_string&
> replace (iterator __first, iterator __last,
> - size_type __n, value_type __c, int) {
> - return replace (_C_off (__first), _C_off (__first, __last), __n, __c);
> + _IntType __n, _IntType __c, int) {
> + return replace (_C_off (__first), _C_off (__first, __last),
> + size_type (__n), value_type (__c));
> }
>
> // 21.3.5.6, p21
> {code}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (STDCXX-1009)
std::string::{assign|append|insert|replace} ([iterator, iterator,]
size_type, value_type) ambiguous
Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/STDCXX-1009?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12628711#action_12628711 ]
Martin Sebor commented on STDCXX-1009:
--------------------------------------
Similar errors with gcc 4.3:
{noformat}
$ make t
gcc -c -I/amd/devco/sebor/stdcxx-4.2.x/include/ansi -D_RWSTDDEBUG -pthread -I/amd/devco/sebor/stdcxx-4.2.x/include -I/build/sebor/stdcxx-4.2.x-gcc-4.3.0-15D/include -I/amd/devco/sebor/stdcxx-4.2.x/tests/include -pedantic -nostdinc++ -g -W -Wall -Wcast-qual -Winline -Wshadow -Wwrite-strings -Wno-long-long -Wcast-align t.cpp
/amd/devco/sebor/stdcxx-4.2.x/include/string: In member function 'std::basic_string<_CharT, _Traits, _Allocator>& std::basic_string<_CharT, _Traits, _Allocator>::replace(__rw::__rw_debug_iter<std::basic_string<_CharT, _Traits, _Allocator>, typename _Allocator::pointer, typename _Allocator::pointer>, __rw::__rw_debug_iter<std::basic_string<_CharT, _Traits, _Allocator>, typename _Allocator::pointer, typename _Allocator::pointer>, _InputIter, _InputIter) [with _InputIter = int, _CharT = char, _Traits = std::char_traits<char>, _Allocator = std::allocator<char>]':
/amd/devco/sebor/stdcxx-4.2.x/include/string:190: instantiated from 'std::basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIter, _InputIter, const _Allocator&) [with _InputIter = int, _CharT = char, _Traits = std::char_traits<char>, _Allocator = std::allocator<char>]'
t.cpp:6: instantiated from here
/amd/devco/sebor/stdcxx-4.2.x/include/string:616: error: call of overloaded 'replace(__rw::__rw_debug_iter<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, char*, char*>&, __rw::__rw_debug_iter<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, char*, char*>&, int&, int&, int)' is ambiguous
/amd/devco/sebor/stdcxx-4.2.x/include/string.cc:494: note: candidates are: std::basic_string<_CharT, _Traits, _Allocator>& std::basic_string<_CharT, _Traits, _Allocator>::replace(__rw::__rw_debug_iter<std::basic_string<_CharT, _Traits, _Allocator>, typename _Allocator::pointer, typename _Allocator::pointer>, __rw::__rw_debug_iter<std::basic_string<_CharT, _Traits, _Allocator>, typename _Allocator::pointer, typename _Allocator::pointer>, _InputIter, _InputIter, void*) [with _InputIter = int, _CharT = char, _Traits = std::char_traits<char>, _Allocator = std::allocator<char>]
/amd/devco/sebor/stdcxx-4.2.x/include/string:606: note: std::basic_string<_CharT, _Traits, _Allocator>& std::basic_string<_CharT, _Traits, _Allocator>::replace(__rw::__rw_debug_iter<std::basic_string<_CharT, _Traits, _Allocator>, typename _Allocator::pointer, typename _Allocator::pointer>, __rw::__rw_debug_iter<std::basic_string<_CharT, _Traits, _Allocator>, typename _Allocator::pointer, typename _Allocator::pointer>, typename _Allocator::size_type, typename _Traits::char_type, int) [with _CharT = char, _Traits = std::char_traits<char>, _Allocator = std::allocator<char>]
...
{noformat}
> std::string::{assign|append|insert|replace} ([iterator, iterator,] size_type, value_type) ambiguous
> ---------------------------------------------------------------------------------------------------
>
> Key: STDCXX-1009
> URL: https://issues.apache.org/jira/browse/STDCXX-1009
> Project: C++ Standard Library
> Issue Type: Improvement
> Components: 21. Strings
> Affects Versions: 4.1.2, 4.1.3, 4.1.4, 4.2.0, 4.2.1
> Environment: All
> Reporter: Farid Zaripov
> Assignee: Farid Zaripov
> Priority: Minor
> Fix For: 4.3.0
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> The following test case fails to compile:
> {code:title=test.cpp}
> #include <string>
> int main ()
> {
> char c = 5;
> std::string s (4, '0' + c);
> s.assign (4, '0' + c);
> s.append (4, '0' + c);
> s.insert (s.begin (), 4, '0' + c);
> s.replace (s.begin (), s.end (), 4, '0' + c);
> return 0;
> }
> {code}
> {noformat}
> test.cpp
> D:\_Libs\stdcxx-4.2.2\include\string(370) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::assign' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(381): could be 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::assign(std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(374): or 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::assign<_InputIter>(_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(int, int, int)'
> test.cpp(7) : see reference to function template instantiation 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::assign<int>(_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(320) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::append' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(330): could be 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::append(std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(324): or 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::append<_InputIter>(_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(int, int, int)'
> test.cpp(8) : see reference to function template instantiation 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::append<int>(_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(422) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::insert' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(432): could be 'void std::basic_string<_CharT,_Traits,_Allocator>::insert(std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(426): or 'void std::basic_string<_CharT,_Traits,_Allocator>::insert<_InputIter>(std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(std::basic_string<_CharT,_Traits,_Allocator>::iterator, int, int, int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> test.cpp(9) : see reference to function template instantiation 'void std::basic_string<_CharT,_Traits,_Allocator>::insert<int>(std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(616) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::replace' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(605): could be 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::replace(std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string.cc(493): or 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::replace<_InputIter>(std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(std::basic_string<_CharT,_Traits,_Allocator>::iterator, std::basic_string<_CharT,_Traits,_Allocator>::iterator, int, int, int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> and
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> test.cpp(10) : see reference to function template instantiation 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::replace<int>(std::basic_string<_CharT,_Traits,_Allocator>::ite
> rator,std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> {noformat}
> The proposed patch:
> {code:title=string.diff}
> Index: include/string
> ===================================================================
> --- include/string (revision 691313)
> +++ include/string (working copy)
> @@ -327,9 +327,10 @@
> __first, __last), *this;
> }
>
> - basic_string& append (size_type __n, value_type __c, int) {
> + template <class _IntType>
> + basic_string& append (_IntType __n, _IntType __c, int) {
> // unnamed arg is used for overload resolution
> - return append (__n, __c);
> + return append (size_type (__n), value_type (__c));
> }
>
> #else // if defined (_RWSTD_NO_MEMBER_TEMPLATES)
> @@ -378,9 +379,11 @@
> _C_make_iter (_C_data + size ()), __first, __last);
> }
>
> - basic_string& assign (size_type __n, value_type __c, int) {
> + template <class _IntType>
> + basic_string& assign (_IntType __n, _IntType __c, int) {
> // unnamed arg is used for overload resolution
> - return replace (size_type (), size (), __n, __c);
> + return replace (size_type (), size (),
> + size_type (__n), value_type (__c));
> }
>
> #else // if defined (_RWSTD_NO_MEMBER_TEMPLATES)
> @@ -429,9 +432,11 @@
> replace (__p, __p, __first, __last);
> }
>
> - void insert (iterator __p, size_type __n, value_type __c, int) {
> + template <class _IntType>
> + void insert (iterator __p, _IntType __n, _IntType __c, int) {
> // unnamed arg is used for overload resolution
> - replace (_C_off (__p), size_type (), __n, __c);
> + replace (_C_off (__p), size_type (),
> + size_type (__n), value_type (__c));
> }
>
> void insert (iterator __p,
> @@ -601,10 +606,12 @@
>
> # endif // _RWSTD_NO_STRING_OUTLINED_MEMBER_TEMPLATES
>
> + template <class _IntType>
> basic_string&
> replace (iterator __first, iterator __last,
> - size_type __n, value_type __c, int) {
> - return replace (_C_off (__first), _C_off (__first, __last), __n, __c);
> + _IntType __n, _IntType __c, int) {
> + return replace (_C_off (__first), _C_off (__first, __last),
> + size_type (__n), value_type (__c));
> }
>
> // 21.3.5.6, p21
> {code}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (STDCXX-1009)
std::string::{assign|append|insert|replace} ([iterator, iterator,]
size_type, value_type) ambiguous
Posted by "Farid Zaripov (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/STDCXX-1009?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Farid Zaripov updated STDCXX-1009:
----------------------------------
Issue Type: Bug (was: Improvement)
Issue type changed to 'bug'.
> std::string::{assign|append|insert|replace} ([iterator, iterator,] size_type, value_type) ambiguous
> ---------------------------------------------------------------------------------------------------
>
> Key: STDCXX-1009
> URL: https://issues.apache.org/jira/browse/STDCXX-1009
> Project: C++ Standard Library
> Issue Type: Bug
> Components: 21. Strings
> Affects Versions: 4.1.2, 4.1.3, 4.1.4, 4.2.0, 4.2.1
> Environment: All
> Reporter: Farid Zaripov
> Assignee: Farid Zaripov
> Priority: Minor
> Fix For: 4.3.0
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> The following test case fails to compile:
> {code:title=test.cpp}
> #include <string>
> int main ()
> {
> char c = 5;
> std::string s (4, '0' + c);
> s.assign (4, '0' + c);
> s.append (4, '0' + c);
> s.insert (s.begin (), 4, '0' + c);
> s.replace (s.begin (), s.end (), 4, '0' + c);
> return 0;
> }
> {code}
> {noformat}
> test.cpp
> D:\_Libs\stdcxx-4.2.2\include\string(370) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::assign' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(381): could be 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::assign(std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(374): or 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::assign<_InputIter>(_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(int, int, int)'
> test.cpp(7) : see reference to function template instantiation 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::assign<int>(_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(320) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::append' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(330): could be 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::append(std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(324): or 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::append<_InputIter>(_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(int, int, int)'
> test.cpp(8) : see reference to function template instantiation 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::append<int>(_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(422) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::insert' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(432): could be 'void std::basic_string<_CharT,_Traits,_Allocator>::insert(std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(426): or 'void std::basic_string<_CharT,_Traits,_Allocator>::insert<_InputIter>(std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(std::basic_string<_CharT,_Traits,_Allocator>::iterator, int, int, int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> test.cpp(9) : see reference to function template instantiation 'void std::basic_string<_CharT,_Traits,_Allocator>::insert<int>(std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(616) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::replace' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(605): could be 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::replace(std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string.cc(493): or 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::replace<_InputIter>(std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(std::basic_string<_CharT,_Traits,_Allocator>::iterator, std::basic_string<_CharT,_Traits,_Allocator>::iterator, int, int, int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> and
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> test.cpp(10) : see reference to function template instantiation 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::replace<int>(std::basic_string<_CharT,_Traits,_Allocator>::ite
> rator,std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> {noformat}
> The proposed patch:
> {code:title=string.diff}
> Index: include/string
> ===================================================================
> --- include/string (revision 691313)
> +++ include/string (working copy)
> @@ -327,9 +327,10 @@
> __first, __last), *this;
> }
>
> - basic_string& append (size_type __n, value_type __c, int) {
> + template <class _IntType>
> + basic_string& append (_IntType __n, _IntType __c, int) {
> // unnamed arg is used for overload resolution
> - return append (__n, __c);
> + return append (size_type (__n), value_type (__c));
> }
>
> #else // if defined (_RWSTD_NO_MEMBER_TEMPLATES)
> @@ -378,9 +379,11 @@
> _C_make_iter (_C_data + size ()), __first, __last);
> }
>
> - basic_string& assign (size_type __n, value_type __c, int) {
> + template <class _IntType>
> + basic_string& assign (_IntType __n, _IntType __c, int) {
> // unnamed arg is used for overload resolution
> - return replace (size_type (), size (), __n, __c);
> + return replace (size_type (), size (),
> + size_type (__n), value_type (__c));
> }
>
> #else // if defined (_RWSTD_NO_MEMBER_TEMPLATES)
> @@ -429,9 +432,11 @@
> replace (__p, __p, __first, __last);
> }
>
> - void insert (iterator __p, size_type __n, value_type __c, int) {
> + template <class _IntType>
> + void insert (iterator __p, _IntType __n, _IntType __c, int) {
> // unnamed arg is used for overload resolution
> - replace (_C_off (__p), size_type (), __n, __c);
> + replace (_C_off (__p), size_type (),
> + size_type (__n), value_type (__c));
> }
>
> void insert (iterator __p,
> @@ -601,10 +606,12 @@
>
> # endif // _RWSTD_NO_STRING_OUTLINED_MEMBER_TEMPLATES
>
> + template <class _IntType>
> basic_string&
> replace (iterator __first, iterator __last,
> - size_type __n, value_type __c, int) {
> - return replace (_C_off (__first), _C_off (__first, __last), __n, __c);
> + _IntType __n, _IntType __c, int) {
> + return replace (_C_off (__first), _C_off (__first, __last),
> + size_type (__n), value_type (__c));
> }
>
> // 21.3.5.6, p21
> {code}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (STDCXX-1009)
std::string::{assign|append|insert|replace} ([iterator, iterator,]
size_type, value_type) ambiguous
Posted by "Farid Zaripov (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/STDCXX-1009?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Farid Zaripov resolved STDCXX-1009.
-----------------------------------
Resolution: Fixed
Resolved thus: http://svn.apache.org/viewvc?view=rev&revision=694649
Will be closed after merging into trunk and 4.3.x branch.
> std::string::{assign|append|insert|replace} ([iterator, iterator,] size_type, value_type) ambiguous
> ---------------------------------------------------------------------------------------------------
>
> Key: STDCXX-1009
> URL: https://issues.apache.org/jira/browse/STDCXX-1009
> Project: C++ Standard Library
> Issue Type: Bug
> Components: 21. Strings
> Affects Versions: 4.1.2, 4.1.3, 4.1.4, 4.2.0, 4.2.1
> Environment: All
> Reporter: Farid Zaripov
> Assignee: Farid Zaripov
> Priority: Minor
> Fix For: 4.2.2
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> The following test case fails to compile:
> {code:title=test.cpp}
> #include <string>
> int main ()
> {
> char c = 5;
> std::string s (4, '0' + c);
> s.assign (4, '0' + c);
> s.append (4, '0' + c);
> s.insert (s.begin (), 4, '0' + c);
> s.replace (s.begin (), s.end (), 4, '0' + c);
> return 0;
> }
> {code}
> {noformat}
> test.cpp
> D:\_Libs\stdcxx-4.2.2\include\string(370) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::assign' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(381): could be 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::assign(std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(374): or 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::assign<_InputIter>(_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(int, int, int)'
> test.cpp(7) : see reference to function template instantiation 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::assign<int>(_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(320) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::append' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(330): could be 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::append(std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(324): or 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::append<_InputIter>(_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(int, int, int)'
> test.cpp(8) : see reference to function template instantiation 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::append<int>(_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(422) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::insert' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(432): could be 'void std::basic_string<_CharT,_Traits,_Allocator>::insert(std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(426): or 'void std::basic_string<_CharT,_Traits,_Allocator>::insert<_InputIter>(std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(std::basic_string<_CharT,_Traits,_Allocator>::iterator, int, int, int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> test.cpp(9) : see reference to function template instantiation 'void std::basic_string<_CharT,_Traits,_Allocator>::insert<int>(std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(616) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::replace' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(605): could be 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::replace(std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string.cc(493): or 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::replace<_InputIter>(std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(std::basic_string<_CharT,_Traits,_Allocator>::iterator, std::basic_string<_CharT,_Traits,_Allocator>::iterator, int, int, int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> and
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> test.cpp(10) : see reference to function template instantiation 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::replace<int>(std::basic_string<_CharT,_Traits,_Allocator>::ite
> rator,std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> {noformat}
> The proposed patch:
> {code:title=string.diff}
> Index: include/string
> ===================================================================
> --- include/string (revision 691313)
> +++ include/string (working copy)
> @@ -327,9 +327,10 @@
> __first, __last), *this;
> }
>
> - basic_string& append (size_type __n, value_type __c, int) {
> + template <class _IntType>
> + basic_string& append (_IntType __n, _IntType __c, int) {
> // unnamed arg is used for overload resolution
> - return append (__n, __c);
> + return append (size_type (__n), value_type (__c));
> }
>
> #else // if defined (_RWSTD_NO_MEMBER_TEMPLATES)
> @@ -378,9 +379,11 @@
> _C_make_iter (_C_data + size ()), __first, __last);
> }
>
> - basic_string& assign (size_type __n, value_type __c, int) {
> + template <class _IntType>
> + basic_string& assign (_IntType __n, _IntType __c, int) {
> // unnamed arg is used for overload resolution
> - return replace (size_type (), size (), __n, __c);
> + return replace (size_type (), size (),
> + size_type (__n), value_type (__c));
> }
>
> #else // if defined (_RWSTD_NO_MEMBER_TEMPLATES)
> @@ -429,9 +432,11 @@
> replace (__p, __p, __first, __last);
> }
>
> - void insert (iterator __p, size_type __n, value_type __c, int) {
> + template <class _IntType>
> + void insert (iterator __p, _IntType __n, _IntType __c, int) {
> // unnamed arg is used for overload resolution
> - replace (_C_off (__p), size_type (), __n, __c);
> + replace (_C_off (__p), size_type (),
> + size_type (__n), value_type (__c));
> }
>
> void insert (iterator __p,
> @@ -601,10 +606,12 @@
>
> # endif // _RWSTD_NO_STRING_OUTLINED_MEMBER_TEMPLATES
>
> + template <class _IntType>
> basic_string&
> replace (iterator __first, iterator __last,
> - size_type __n, value_type __c, int) {
> - return replace (_C_off (__first), _C_off (__first, __last), __n, __c);
> + _IntType __n, _IntType __c, int) {
> + return replace (_C_off (__first), _C_off (__first, __last),
> + size_type (__n), value_type (__c));
> }
>
> // 21.3.5.6, p21
> {code}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (STDCXX-1009)
std::string::{assign|append|insert|replace} ([iterator, iterator,]
size_type, value_type) ambiguous
Posted by "Farid Zaripov (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/STDCXX-1009?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12629220#action_12629220 ]
Farid Zaripov commented on STDCXX-1009:
---------------------------------------
The regression test added thus:
http://svn.apache.org/viewvc?rev=693158&view=rev
http://svn.apache.org/viewvc?rev=693160&view=rev
http://svn.apache.org/viewvc?rev=693161&view=rev
> std::string::{assign|append|insert|replace} ([iterator, iterator,] size_type, value_type) ambiguous
> ---------------------------------------------------------------------------------------------------
>
> Key: STDCXX-1009
> URL: https://issues.apache.org/jira/browse/STDCXX-1009
> Project: C++ Standard Library
> Issue Type: Bug
> Components: 21. Strings
> Affects Versions: 4.1.2, 4.1.3, 4.1.4, 4.2.0, 4.2.1
> Environment: All
> Reporter: Farid Zaripov
> Assignee: Farid Zaripov
> Priority: Minor
> Fix For: 4.3.0
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> The following test case fails to compile:
> {code:title=test.cpp}
> #include <string>
> int main ()
> {
> char c = 5;
> std::string s (4, '0' + c);
> s.assign (4, '0' + c);
> s.append (4, '0' + c);
> s.insert (s.begin (), 4, '0' + c);
> s.replace (s.begin (), s.end (), 4, '0' + c);
> return 0;
> }
> {code}
> {noformat}
> test.cpp
> D:\_Libs\stdcxx-4.2.2\include\string(370) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::assign' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(381): could be 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::assign(std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(374): or 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::assign<_InputIter>(_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(int, int, int)'
> test.cpp(7) : see reference to function template instantiation 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::assign<int>(_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(320) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::append' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(330): could be 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::append(std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(324): or 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::append<_InputIter>(_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(int, int, int)'
> test.cpp(8) : see reference to function template instantiation 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::append<int>(_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(422) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::insert' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(432): could be 'void std::basic_string<_CharT,_Traits,_Allocator>::insert(std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(426): or 'void std::basic_string<_CharT,_Traits,_Allocator>::insert<_InputIter>(std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(std::basic_string<_CharT,_Traits,_Allocator>::iterator, int, int, int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> test.cpp(9) : see reference to function template instantiation 'void std::basic_string<_CharT,_Traits,_Allocator>::insert<int>(std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(616) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::replace' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(605): could be 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::replace(std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string.cc(493): or 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::replace<_InputIter>(std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(std::basic_string<_CharT,_Traits,_Allocator>::iterator, std::basic_string<_CharT,_Traits,_Allocator>::iterator, int, int, int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> and
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> test.cpp(10) : see reference to function template instantiation 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::replace<int>(std::basic_string<_CharT,_Traits,_Allocator>::ite
> rator,std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> {noformat}
> The proposed patch:
> {code:title=string.diff}
> Index: include/string
> ===================================================================
> --- include/string (revision 691313)
> +++ include/string (working copy)
> @@ -327,9 +327,10 @@
> __first, __last), *this;
> }
>
> - basic_string& append (size_type __n, value_type __c, int) {
> + template <class _IntType>
> + basic_string& append (_IntType __n, _IntType __c, int) {
> // unnamed arg is used for overload resolution
> - return append (__n, __c);
> + return append (size_type (__n), value_type (__c));
> }
>
> #else // if defined (_RWSTD_NO_MEMBER_TEMPLATES)
> @@ -378,9 +379,11 @@
> _C_make_iter (_C_data + size ()), __first, __last);
> }
>
> - basic_string& assign (size_type __n, value_type __c, int) {
> + template <class _IntType>
> + basic_string& assign (_IntType __n, _IntType __c, int) {
> // unnamed arg is used for overload resolution
> - return replace (size_type (), size (), __n, __c);
> + return replace (size_type (), size (),
> + size_type (__n), value_type (__c));
> }
>
> #else // if defined (_RWSTD_NO_MEMBER_TEMPLATES)
> @@ -429,9 +432,11 @@
> replace (__p, __p, __first, __last);
> }
>
> - void insert (iterator __p, size_type __n, value_type __c, int) {
> + template <class _IntType>
> + void insert (iterator __p, _IntType __n, _IntType __c, int) {
> // unnamed arg is used for overload resolution
> - replace (_C_off (__p), size_type (), __n, __c);
> + replace (_C_off (__p), size_type (),
> + size_type (__n), value_type (__c));
> }
>
> void insert (iterator __p,
> @@ -601,10 +606,12 @@
>
> # endif // _RWSTD_NO_STRING_OUTLINED_MEMBER_TEMPLATES
>
> + template <class _IntType>
> basic_string&
> replace (iterator __first, iterator __last,
> - size_type __n, value_type __c, int) {
> - return replace (_C_off (__first), _C_off (__first, __last), __n, __c);
> + _IntType __n, _IntType __c, int) {
> + return replace (_C_off (__first), _C_off (__first, __last),
> + size_type (__n), value_type (__c));
> }
>
> // 21.3.5.6, p21
> {code}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Issue Comment Edited: (STDCXX-1009)
std::string::{assign|append|insert|replace} ([iterator, iterator,]
size_type, value_type) ambiguous
Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/STDCXX-1009?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12628711#action_12628711 ]
sebor edited comment on STDCXX-1009 at 9/5/08 12:50 PM:
---------------------------------------------------------------
Similar errors with gcc 4.3:
{noformat}
$ make t
gcc -c -I/amd/devco/sebor/stdcxx-4.2.x/include/ansi -D_RWSTDDEBUG -pthread -I/amd/devco/sebor/stdcxx-4.2.x/include -I/build/sebor/stdcxx-4.2.x-gcc-4.3.0-15D/include -I/amd/devco/sebor/stdcxx-4.2.x/tests/include -pedantic -nostdinc++ -g -W -Wall -Wcast-qual -Winline -Wshadow -Wwrite-strings -Wno-long-long -Wcast-align t.cpp
/amd/devco/sebor/stdcxx-4.2.x/include/string: In member function 'std::basic_string<_CharT, _Traits, _Allocator>& std::basic_string<_CharT, _Traits, _Allocator>::replace(__rw::__rw_debug_iter<std::basic_string<_CharT, _Traits, _Allocator>, typename _Allocator::pointer, typename _Allocator::pointer>, __rw::__rw_debug_iter<std::basic_string<_CharT, _Traits, _Allocator>, typename _Allocator::pointer, typename _Allocator::pointer>, _InputIter, _InputIter) [with _InputIter = int, _CharT = char, _Traits = std::char_traits<char>, _Allocator = std::allocator<char>]':
/amd/devco/sebor/stdcxx-4.2.x/include/string:190: instantiated from 'std::basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIter, _InputIter, const _Allocator&) [with _InputIter = int, _CharT = char, _Traits = std::char_traits<char>, _Allocator = std::allocator<char>]'
t.cpp:6: instantiated from here
/amd/devco/sebor/stdcxx-4.2.x/include/string:616: error: call of overloaded 'replace(__rw::__rw_debug_iter<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, char*, char*>&, __rw::__rw_debug_iter<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, char*, char*>&, int&, int&, int)' is ambiguous
/amd/devco/sebor/stdcxx-4.2.x/include/string.cc:494: note: candidates are: std::basic_string<_CharT, _Traits, _Allocator>& std::basic_string<_CharT, _Traits, _Allocator>::replace(__rw::__rw_debug_iter<std::basic_string<_CharT, _Traits, _Allocator>, typename _Allocator::pointer, typename _Allocator::pointer>, __rw::__rw_debug_iter<std::basic_string<_CharT, _Traits, _Allocator>, typename _Allocator::pointer, typename _Allocator::pointer>, _InputIter, _InputIter, void*) [with _InputIter = int, _CharT = char, _Traits = std::char_traits<char>, _Allocator = std::allocator<char>]
/amd/devco/sebor/stdcxx-4.2.x/include/string:606: note: std::basic_string<_CharT, _Traits, _Allocator>& std::basic_string<_CharT, _Traits, _Allocator>::replace(__rw::__rw_debug_iter<std::basic_string<_CharT, _Traits, _Allocator>, typename _Allocator::pointer, typename _Allocator::pointer>, __rw::__rw_debug_iter<std::basic_string<_CharT, _Traits, _Allocator>, typename _Allocator::pointer, typename _Allocator::pointer>, typename _Allocator::size_type, typename _Traits::char_type, int) [with _CharT = char, _Traits = std::char_traits<char>, _Allocator = std::allocator<char>]
...
{noformat}
Here's a simplified test case:
{noformat}
#include <string>
int main ()
{
std::string s (4, int ('5'));
s.assign (4, int ('5'));
s.append (4, int ('5'));
s.insert (s.begin (), 4, int ('5'));
s.replace (s.begin (), s.end (), 4, int ('5'));
}
{noformat}
was (Author: sebor):
Similar errors with gcc 4.3:
{noformat}
$ make t
gcc -c -I/amd/devco/sebor/stdcxx-4.2.x/include/ansi -D_RWSTDDEBUG -pthread -I/amd/devco/sebor/stdcxx-4.2.x/include -I/build/sebor/stdcxx-4.2.x-gcc-4.3.0-15D/include -I/amd/devco/sebor/stdcxx-4.2.x/tests/include -pedantic -nostdinc++ -g -W -Wall -Wcast-qual -Winline -Wshadow -Wwrite-strings -Wno-long-long -Wcast-align t.cpp
/amd/devco/sebor/stdcxx-4.2.x/include/string: In member function 'std::basic_string<_CharT, _Traits, _Allocator>& std::basic_string<_CharT, _Traits, _Allocator>::replace(__rw::__rw_debug_iter<std::basic_string<_CharT, _Traits, _Allocator>, typename _Allocator::pointer, typename _Allocator::pointer>, __rw::__rw_debug_iter<std::basic_string<_CharT, _Traits, _Allocator>, typename _Allocator::pointer, typename _Allocator::pointer>, _InputIter, _InputIter) [with _InputIter = int, _CharT = char, _Traits = std::char_traits<char>, _Allocator = std::allocator<char>]':
/amd/devco/sebor/stdcxx-4.2.x/include/string:190: instantiated from 'std::basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIter, _InputIter, const _Allocator&) [with _InputIter = int, _CharT = char, _Traits = std::char_traits<char>, _Allocator = std::allocator<char>]'
t.cpp:6: instantiated from here
/amd/devco/sebor/stdcxx-4.2.x/include/string:616: error: call of overloaded 'replace(__rw::__rw_debug_iter<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, char*, char*>&, __rw::__rw_debug_iter<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, char*, char*>&, int&, int&, int)' is ambiguous
/amd/devco/sebor/stdcxx-4.2.x/include/string.cc:494: note: candidates are: std::basic_string<_CharT, _Traits, _Allocator>& std::basic_string<_CharT, _Traits, _Allocator>::replace(__rw::__rw_debug_iter<std::basic_string<_CharT, _Traits, _Allocator>, typename _Allocator::pointer, typename _Allocator::pointer>, __rw::__rw_debug_iter<std::basic_string<_CharT, _Traits, _Allocator>, typename _Allocator::pointer, typename _Allocator::pointer>, _InputIter, _InputIter, void*) [with _InputIter = int, _CharT = char, _Traits = std::char_traits<char>, _Allocator = std::allocator<char>]
/amd/devco/sebor/stdcxx-4.2.x/include/string:606: note: std::basic_string<_CharT, _Traits, _Allocator>& std::basic_string<_CharT, _Traits, _Allocator>::replace(__rw::__rw_debug_iter<std::basic_string<_CharT, _Traits, _Allocator>, typename _Allocator::pointer, typename _Allocator::pointer>, __rw::__rw_debug_iter<std::basic_string<_CharT, _Traits, _Allocator>, typename _Allocator::pointer, typename _Allocator::pointer>, typename _Allocator::size_type, typename _Traits::char_type, int) [with _CharT = char, _Traits = std::char_traits<char>, _Allocator = std::allocator<char>]
...
{noformat}
> std::string::{assign|append|insert|replace} ([iterator, iterator,] size_type, value_type) ambiguous
> ---------------------------------------------------------------------------------------------------
>
> Key: STDCXX-1009
> URL: https://issues.apache.org/jira/browse/STDCXX-1009
> Project: C++ Standard Library
> Issue Type: Improvement
> Components: 21. Strings
> Affects Versions: 4.1.2, 4.1.3, 4.1.4, 4.2.0, 4.2.1
> Environment: All
> Reporter: Farid Zaripov
> Assignee: Farid Zaripov
> Priority: Minor
> Fix For: 4.3.0
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> The following test case fails to compile:
> {code:title=test.cpp}
> #include <string>
> int main ()
> {
> char c = 5;
> std::string s (4, '0' + c);
> s.assign (4, '0' + c);
> s.append (4, '0' + c);
> s.insert (s.begin (), 4, '0' + c);
> s.replace (s.begin (), s.end (), 4, '0' + c);
> return 0;
> }
> {code}
> {noformat}
> test.cpp
> D:\_Libs\stdcxx-4.2.2\include\string(370) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::assign' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(381): could be 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::assign(std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(374): or 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::assign<_InputIter>(_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(int, int, int)'
> test.cpp(7) : see reference to function template instantiation 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::assign<int>(_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(320) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::append' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(330): could be 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::append(std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(324): or 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::append<_InputIter>(_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(int, int, int)'
> test.cpp(8) : see reference to function template instantiation 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::append<int>(_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(422) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::insert' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(432): could be 'void std::basic_string<_CharT,_Traits,_Allocator>::insert(std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(426): or 'void std::basic_string<_CharT,_Traits,_Allocator>::insert<_InputIter>(std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(std::basic_string<_CharT,_Traits,_Allocator>::iterator, int, int, int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> test.cpp(9) : see reference to function template instantiation 'void std::basic_string<_CharT,_Traits,_Allocator>::insert<int>(std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(616) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::replace' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(605): could be 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::replace(std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string.cc(493): or 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::replace<_InputIter>(std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(std::basic_string<_CharT,_Traits,_Allocator>::iterator, std::basic_string<_CharT,_Traits,_Allocator>::iterator, int, int, int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> and
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> test.cpp(10) : see reference to function template instantiation 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::replace<int>(std::basic_string<_CharT,_Traits,_Allocator>::ite
> rator,std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> {noformat}
> The proposed patch:
> {code:title=string.diff}
> Index: include/string
> ===================================================================
> --- include/string (revision 691313)
> +++ include/string (working copy)
> @@ -327,9 +327,10 @@
> __first, __last), *this;
> }
>
> - basic_string& append (size_type __n, value_type __c, int) {
> + template <class _IntType>
> + basic_string& append (_IntType __n, _IntType __c, int) {
> // unnamed arg is used for overload resolution
> - return append (__n, __c);
> + return append (size_type (__n), value_type (__c));
> }
>
> #else // if defined (_RWSTD_NO_MEMBER_TEMPLATES)
> @@ -378,9 +379,11 @@
> _C_make_iter (_C_data + size ()), __first, __last);
> }
>
> - basic_string& assign (size_type __n, value_type __c, int) {
> + template <class _IntType>
> + basic_string& assign (_IntType __n, _IntType __c, int) {
> // unnamed arg is used for overload resolution
> - return replace (size_type (), size (), __n, __c);
> + return replace (size_type (), size (),
> + size_type (__n), value_type (__c));
> }
>
> #else // if defined (_RWSTD_NO_MEMBER_TEMPLATES)
> @@ -429,9 +432,11 @@
> replace (__p, __p, __first, __last);
> }
>
> - void insert (iterator __p, size_type __n, value_type __c, int) {
> + template <class _IntType>
> + void insert (iterator __p, _IntType __n, _IntType __c, int) {
> // unnamed arg is used for overload resolution
> - replace (_C_off (__p), size_type (), __n, __c);
> + replace (_C_off (__p), size_type (),
> + size_type (__n), value_type (__c));
> }
>
> void insert (iterator __p,
> @@ -601,10 +606,12 @@
>
> # endif // _RWSTD_NO_STRING_OUTLINED_MEMBER_TEMPLATES
>
> + template <class _IntType>
> basic_string&
> replace (iterator __first, iterator __last,
> - size_type __n, value_type __c, int) {
> - return replace (_C_off (__first), _C_off (__first, __last), __n, __c);
> + _IntType __n, _IntType __c, int) {
> + return replace (_C_off (__first), _C_off (__first, __last),
> + size_type (__n), value_type (__c));
> }
>
> // 21.3.5.6, p21
> {code}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Closed: (STDCXX-1009)
std::string::{assign|append|insert|replace} ([iterator, iterator,]
size_type, value_type) ambiguous
Posted by "Farid Zaripov (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/STDCXX-1009?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Farid Zaripov closed STDCXX-1009.
---------------------------------
Merged into trunk and 4.3.x branch thus:
http://svn.apache.org/viewvc?view=rev&revision=704438
http://svn.apache.org/viewvc?view=rev&revision=704442
> std::string::{assign|append|insert|replace} ([iterator, iterator,] size_type, value_type) ambiguous
> ---------------------------------------------------------------------------------------------------
>
> Key: STDCXX-1009
> URL: https://issues.apache.org/jira/browse/STDCXX-1009
> Project: C++ Standard Library
> Issue Type: Bug
> Components: 21. Strings
> Affects Versions: 4.1.2, 4.1.3, 4.1.4, 4.2.0, 4.2.1
> Environment: All
> Reporter: Farid Zaripov
> Assignee: Farid Zaripov
> Priority: Minor
> Fix For: 4.2.2
>
> Original Estimate: 1h
> Remaining Estimate: 1h
>
> The following test case fails to compile:
> {code:title=test.cpp}
> #include <string>
> int main ()
> {
> char c = 5;
> std::string s (4, '0' + c);
> s.assign (4, '0' + c);
> s.append (4, '0' + c);
> s.insert (s.begin (), 4, '0' + c);
> s.replace (s.begin (), s.end (), 4, '0' + c);
> return 0;
> }
> {code}
> {noformat}
> test.cpp
> D:\_Libs\stdcxx-4.2.2\include\string(370) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::assign' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(381): could be 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::assign(std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(374): or 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::assign<_InputIter>(_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(int, int, int)'
> test.cpp(7) : see reference to function template instantiation 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::assign<int>(_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(320) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::append' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(330): could be 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::append(std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(324): or 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::append<_InputIter>(_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(int, int, int)'
> test.cpp(8) : see reference to function template instantiation 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::append<int>(_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(422) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::insert' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(432): could be 'void std::basic_string<_CharT,_Traits,_Allocator>::insert(std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(426): or 'void std::basic_string<_CharT,_Traits,_Allocator>::insert<_InputIter>(std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(std::basic_string<_CharT,_Traits,_Allocator>::iterator, int, int, int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> test.cpp(9) : see reference to function template instantiation 'void std::basic_string<_CharT,_Traits,_Allocator>::insert<int>(std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(616) : error C2666: 'std::basic_string<_CharT,_Traits,_Allocator>::replace' : 2 overloads have similar conversions
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string(605): could be 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::replace(std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::size_type,std::basic_string<_CharT,_Traits,_Allocator>::value_type,int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> D:\_Libs\stdcxx-4.2.2\include\string.cc(493): or 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::replace<_InputIter>(std::basic_string<_CharT,_Traits,_Allocator>::iterator,std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter,void *)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> while trying to match the argument list '(std::basic_string<_CharT,_Traits,_Allocator>::iterator, std::basic_string<_CharT,_Traits,_Allocator>::iterator, int, int, int)'
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> and
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>
> ]
> test.cpp(10) : see reference to function template instantiation 'std::basic_string<_CharT,_Traits,_Allocator> &std::basic_string<_CharT,_Traits,_Allocator>::replace<int>(std::basic_string<_CharT,_Traits,_Allocator>::ite
> rator,std::basic_string<_CharT,_Traits,_Allocator>::iterator,_InputIter,_InputIter)' being compiled
> with
> [
> _CharT=char,
> _Traits=std::char_traits<char>,
> _Allocator=std::allocator<char>,
> _InputIter=int
> ]
> {noformat}
> The proposed patch:
> {code:title=string.diff}
> Index: include/string
> ===================================================================
> --- include/string (revision 691313)
> +++ include/string (working copy)
> @@ -327,9 +327,10 @@
> __first, __last), *this;
> }
>
> - basic_string& append (size_type __n, value_type __c, int) {
> + template <class _IntType>
> + basic_string& append (_IntType __n, _IntType __c, int) {
> // unnamed arg is used for overload resolution
> - return append (__n, __c);
> + return append (size_type (__n), value_type (__c));
> }
>
> #else // if defined (_RWSTD_NO_MEMBER_TEMPLATES)
> @@ -378,9 +379,11 @@
> _C_make_iter (_C_data + size ()), __first, __last);
> }
>
> - basic_string& assign (size_type __n, value_type __c, int) {
> + template <class _IntType>
> + basic_string& assign (_IntType __n, _IntType __c, int) {
> // unnamed arg is used for overload resolution
> - return replace (size_type (), size (), __n, __c);
> + return replace (size_type (), size (),
> + size_type (__n), value_type (__c));
> }
>
> #else // if defined (_RWSTD_NO_MEMBER_TEMPLATES)
> @@ -429,9 +432,11 @@
> replace (__p, __p, __first, __last);
> }
>
> - void insert (iterator __p, size_type __n, value_type __c, int) {
> + template <class _IntType>
> + void insert (iterator __p, _IntType __n, _IntType __c, int) {
> // unnamed arg is used for overload resolution
> - replace (_C_off (__p), size_type (), __n, __c);
> + replace (_C_off (__p), size_type (),
> + size_type (__n), value_type (__c));
> }
>
> void insert (iterator __p,
> @@ -601,10 +606,12 @@
>
> # endif // _RWSTD_NO_STRING_OUTLINED_MEMBER_TEMPLATES
>
> + template <class _IntType>
> basic_string&
> replace (iterator __first, iterator __last,
> - size_type __n, value_type __c, int) {
> - return replace (_C_off (__first), _C_off (__first, __last), __n, __c);
> + _IntType __n, _IntType __c, int) {
> + return replace (_C_off (__first), _C_off (__first, __last),
> + size_type (__n), value_type (__c));
> }
>
> // 21.3.5.6, p21
> {code}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.