Boost C++ Libraries: Ticket #5714: replace_all does not allow to replace single chars https://svn.boost.org/trac10/ticket/5714 <p> Following code does not compile: </p> <pre class="wiki">#include &lt;string&gt; #include &lt;boost/algorithm/string.hpp&gt; using namespace std; using namespace boost; using namespace boost::algorithm; int main() { string str = "abc"; replace_all(str, 'a', 'A'); } </pre><pre class="wiki">/usr/include/boost/algorithm/string/replace.hpp: In function 'void boost::algori thm::replace_all(SequenceT&amp;, const Range1T&amp;, const Range2T&amp;) [with SequenceT = s td::string, Range1T = char, Range2T = char]': x.cc:11: instantiated from here /usr/include/boost/algorithm/string/replace.hpp:654: error: no matching function for call to 'first_finder(const char&amp;)' /usr/include/boost/algorithm/string/replace.hpp:654: error: no matching function for call to 'const_formatter(const char&amp;)' </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5714 Trac 1.4.3 Pavol Droba Tue, 19 Jul 2011 18:07:28 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/5714#comment:1 https://svn.boost.org/trac10/ticket/5714#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> 'a' is not string-type supported by boost::range, therefore it is not a valid argument to function replace_all. Use "a" insteda. </p> Ticket anonymous Wed, 20 Jul 2011 15:24:49 GMT <link>https://svn.boost.org/trac10/ticket/5714#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5714#comment:2</guid> <description> <p> I agree that boost::range modification just to support this case may be undesirable. On the other hand it will be good to provide specialized version of replace_all() and other functions in this library, which are optimized for single characters. Please consider adding them. </p> </description> <category>Ticket</category> </item> </channel> </rss>