https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70483

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2016-04-01 00:00:00         |2017-5-18

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Standalone testcase using C++17 std::string_view:

#include <string_view>

struct constexpr_char_traits: public std::char_traits<char> {
  static constexpr size_t length(const char* val) {
    size_t res = 0;
    for (; val[res] != '\0'; ++res)
      ;
    return res;
  }

  static constexpr int compare(const char* lhs, const char* rhs, std::size_t
count) {
    for (size_t pos = 0; pos < count; ++pos) {
      if (lhs[pos] != rhs[pos])
        return lhs[pos] - rhs[pos];
    }
    return 0;
  }
};

using string_view = std::basic_string_view<char, constexpr_char_traits>;

constexpr
string_view get() {
    string_view res;
    constexpr string_view start_pattern = "x";
    res = res.substr(res.find(start_pattern) + start_pattern.size());
    res = res.substr(0, res.find_first_of(";]"));
    res = res.substr(res.rfind("::"));
    return res;
}

static_assert( get() == get(), "" );

Reply via email to