Boost C++ Libraries: Ticket #12896: [Utility] string_view's comparison operators are not marked "constexpr" https://svn.boost.org/trac10/ticket/12896 <p> During the implementation of my GSoC static_map competency project, I found that in Boost 1.63, string_view's comparison operator was not marked as constexpr(<a href="http://www.boost.org/doc/libs/1_63_0/boost/utility/string_view.hpp">http://www.boost.org/doc/libs/1_63_0/boost/utility/string_view.hpp</a>). According to cppreference, string_view in C++17's standard library includes constexpr comparison operators, and actually the implementation of Boost's comparison operators calls constexpr compare() method. However, constexpr compare() in Boost never works in C++14, since it uses std::char_traits in standard library, of which char_traits::compare is not marked constexpr until C++17. It seems possible to backport C++17's constexpr char_traits into Boost's library. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12896 Trac 1.4.3 Marshall Clow Thu, 04 May 2017 01:30:01 GMT owner changed https://svn.boost.org/trac10/ticket/12896#comment:1 https://svn.boost.org/trac10/ticket/12896#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">No-Maintainer</span> to <span class="trac-author">Marshall Clow</span> </li> </ul> <p> All the variations of <code>basic_string_view::compare</code> are marked as constexpr. (well, <code>BOOST_CXX14_CONSTEXPR</code>). But, as you correctly point out, the operators (<code>&lt; &lt;= == != &gt; &gt; =</code> are not. </p> <blockquote class="citation"> <p> However, constexpr compare() in Boost never works in C++14, since it uses std::char_traits in standard library. </p> </blockquote> <p> That's not strictly true; merely a default. You are free to use your own traits class. </p> <p> I'll fix the operators. </p> Ticket Marshall Clow Thu, 04 May 2017 02:59:05 GMT <link>https://svn.boost.org/trac10/ticket/12896#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12896#comment:2</guid> <description> <p> Commit 330b49d602e0f3b1a7697bd0c816d6031b59f80c addresses this. </p> </description> <category>Ticket</category> </item> </channel> </rss>