Note that there are some explanatory texts on larger screens.

plurals
  1. POC++: Replacing part of string using iterators is not working
    primarykey
    data
    text
    <p>I am writing a simple program, which is trying to find next palindrome number after given number.</p> <p>As for now, I am stuck at this point:</p> <pre><code>string::iterator iter; // iterators for the string string::iterator riter; //testcases is a vector&lt;string&gt; with strings representing numbers. for (unsigned int i = 0; i &lt; testcases.size() ; ++i) { iter = testcases[i].begin(); riter = testcases[i].end(); while ( !isPalin(testcases[i]) ) { //isPalin(string) is a function //which is checking if given string //is a palindrome //if n-th digit from the end is different from the //n-th digit, then I want to replace latter one, so they will //be the same. if ( *iter != *riter ) { testcases[i].replace(riter, riter, *iter); } ++iter; // advancing forward iterator; --riter; // advancing backward iterator; } cout &lt;&lt; testcases[i] &lt;&lt; " -&gt; ok\n"; } </code></pre> <p>When I am compiling this one using Microsoft Visual Studio 2008, I am getting this error:</p> <pre><code>Compiling... main.cpp .\main.cpp(53) : error C2664: 'std::basic_string&lt;_Elem,_Traits,_Ax&gt; &amp;std::basic_string&lt;_Elem,_Traits,_Ax&gt;::replace(unsigned int,unsigned int,const std::basic_string&lt;_Elem,_Traits,_Ax&gt; &amp;)' : cannot convert parameter 1 from 'std::_String_iterator&lt;_Elem,_Traits,_Alloc&gt;' to 'unsigned int' with [ _Elem=char, _Traits=std::char_traits, _Ax=std::allocator ] and [ _Elem=char, _Traits=std::char_traits, _Alloc=std::allocator ] No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called </code></pre> <p>Am I doing something stupid or am I missing something? I would be grateful for any help / suggestion.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload