Boost C++ Libraries: Ticket #3158: is_iless throws exception in string algorithms library https://svn.boost.org/trac10/ticket/3158 <p> I'm using g++ 4.3.2 in Linux. <code>is_iless' throws a </code>std::bad_cast' exception: </p> <pre class="wiki">#include &lt;string&gt; #include "/tmp/testsvn/boost/algorithm/string/compare.hpp" int main() { boost::algorithm::is_less()(std::string("a"), std::string("b")); // this is ok boost::algorithm::is_iless()(std::string("a"), std::string("b")); // this throws `std::bad_cast' return 0; } </pre><p> I assume I using <code>is_iless' correctly since </code>is_less' gives me a correct return value. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/3158 Trac 1.4.3 Pavol Droba Tue, 09 Jun 2009 20:41:47 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/3158#comment:1 https://svn.boost.org/trac10/ticket/3158#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> is_iless was never intended nor designed to compare strings. its function is to compare characters. It uses C++ locale facet to convert the case of the input and that facet is obviously not specialized for std::string. </p> <p> use boost::ilexicographical_compare instead. </p> Ticket anonymous Fri, 03 Jan 2014 11:56:21 GMT <link>https://svn.boost.org/trac10/ticket/3158#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3158#comment:2</guid> <description> <p> But manual sayis nothing about this: </p> <p> "boost::algorithm::is_iless — case insensitive version of is_less.<br /> Case insensitive comparison predicate. Comparison is done using specified locales." </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Steven Watanabe</dc:creator> <pubDate>Fri, 04 Apr 2014 02:23:58 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/3158#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/3158#comment:3</guid> <description> <p> is_less is also not intended to work on strings, although they way it's defined allows it to work. </p> <p> "Header &lt;boost/algorithm/string/compare.hpp&gt; </p> <p> Defines element comparison predicates. Many algorithms in this library can take an additional argument with a predicate used to compare elements. This makes it possible, for instance, to have case insensitive versions of the algorithms." </p> </description> <category>Ticket</category> </item> </channel> </rss>