aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrebecca “wiggles” turner <rbt@sent.as>2024-09-03 18:48:37 +0000
committerGerrit Code Review <gerrit@localhost>2024-09-03 18:48:37 +0000
commit644176a631b5f56bb877926ac78dcd935c6296c3 (patch)
tree8dc697eeadb6d6084cd3f1940fbc22a119002fd0 /src
parentb7b1b9723f7f0a39b47000c18eb4b89252d02c71 (diff)
parent9d8f433246088baeb878050f3022a6a738db526c (diff)
Merge "Expand comment on `std::string operator+`" into main
Diffstat (limited to 'src')
-rw-r--r--src/libutil/strings.hh12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/libutil/strings.hh b/src/libutil/strings.hh
index ebafab9ad..782807b61 100644
--- a/src/libutil/strings.hh
+++ b/src/libutil/strings.hh
@@ -200,8 +200,18 @@ std::string showBytes(uint64_t bytes);
/**
- * Provide an addition operator between strings and string_views
+ * Provide an addition operator between `std::string` and `std::string_view`
* inexplicably omitted from the standard library.
+ *
+ * > The reason for this is given in n3512 string_ref: a non-owning reference
+ * to a string, revision 2 by Jeffrey Yasskin:
+ * >
+ * > > I also omitted operator+(basic_string, basic_string_ref) because LLVM
+ * > > returns a lightweight object from this overload and only performs the
+ * > > concatenation lazily. If we define this overload, we'll have a hard time
+ * > > introducing that lightweight concatenation later.
+ *
+ * See: https://stackoverflow.com/a/47735624
*/
inline std::string operator + (const std::string & s1, std::string_view s2)
{