[all-commits] [llvm/llvm-project] a3181b: [ADT] Teach StringRef to derive from std::string_v...

Kazu Hirata via All-commits all-commits at lists.llvm.org
Sat Oct 26 10:02:33 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a3181b11b5b758cfa852c0d27465f84ab3b079bb
      https://github.com/llvm/llvm-project/commit/a3181b11b5b758cfa852c0d27465f84ab3b079bb
  Author: Kazu Hirata <kazu at google.com>
  Date:   2024-10-26 (Sat, 26 Oct 2024)

  Changed paths:
    M llvm/include/llvm/ADT/StringRef.h

  Log Message:
  -----------
  [ADT] Teach StringRef to derive from std::string_view (#113752)

This patch makes minimum changes to have StringRef derive from
std::string_view, with an eventual goal of removing StringRef
completely.  Subsequent patches will further clean up the remaining
bits.

I've chosen public inheritance over private one because our codebase
relies on implicit conversions to std::string_view, which is currently
provided by:

  constexpr operator std::string_view() const {
    return std::string_view(data(), size());
  }

This implicit conversion stops applying once we use std::string_view
as a base class, public or private.  If we chose a private base class,
we would lose the implicit conversion.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list