Boost C++ Libraries: Ticket #12897: [Utility] string_view's comparison operators are not marked "constexpr" https://svn.boost.org/trac10/ticket/12897 <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/12897 Trac 1.4.3 Andrey Semashev Mon, 13 Mar 2017 13:21:41 GMT owner changed https://svn.boost.org/trac10/ticket/12897#comment:1 https://svn.boost.org/trac10/ticket/12897#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> As I mentioned on the mailing list, unless we can select an optimized runtime versions of the algorithms provided by <code>char_traits</code> based on <code>constexpr</code>-ness of their arguments (or better yet until <code>char_traits</code> does that), <code>constexpr</code> versions of <code>string_view</code> operations or constructors are not feasible. I don't think sacrificing runtime performance is an acceptable solution. </p> <p> Assigning the ticket to Marshall Clow. </p> Ticket Marshall Clow Mon, 08 May 2017 17:08:07 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/12897#comment:2 https://svn.boost.org/trac10/ticket/12897#comment:2 <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">fixed</span> </li> </ul> <p> I have added constexpr to the <code>string_view</code> comparison calls (and operators), so that if you use a traits class that has a constexpr <code>compare</code> method, you'll get constexpr comparisons. </p> <p> Boost doesn't have a char_traits implementation, constexpr or otherwise. </p> Ticket