about summary refs log tree commit diff
path: root/absl/strings/substitute.h
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2019-05-16T14·40-0700
committerAndy Soffer <asoffer@google.com>2019-05-16T19·48-0400
commitdaf381e8535a1f1f1b8a75966a74e7cca63dee89 (patch)
treed2914ddce7cd62d2e9696e5448dd40884c4d3c26 /absl/strings/substitute.h
parentfa00c321073c7ea40a4fc3dfc8a06309eae3d025 (diff)
Export of internal Abseil changes.
--
6fca451d74e509671f0996e15ea05008f73c9957 by Eric Fiselier <ericwf@google.com>:

Support vector<bool>::reference and ::const_reference
in absl::Substitute.

PiperOrigin-RevId: 248524270

--
a4b298c74acb8ae0688ed681052593623d8021c7 by Abseil Team <absl-team@google.com>:

Clarify that a static `SpinLock` using the `LinkerInitialized` constructor is
initialized in non-cooperative mode.

PiperOrigin-RevId: 248386381
GitOrigin-RevId: 6fca451d74e509671f0996e15ea05008f73c9957
Change-Id: I13d54c2034695e7677170cdc7b86384b7d7d9cb5
Diffstat (limited to 'absl/strings/substitute.h')
-rw-r--r--absl/strings/substitute.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/absl/strings/substitute.h b/absl/strings/substitute.h
index 507bc4ff295f..32dec30b63a0 100644
--- a/absl/strings/substitute.h
+++ b/absl/strings/substitute.h
@@ -69,6 +69,8 @@
 
 #include <cstring>
 #include <string>
+#include <type_traits>
+#include <vector>
 
 #include "absl/base/macros.h"
 #include "absl/base/port.h"
@@ -151,6 +153,17 @@ class Arg {
   Arg(Hex hex);  // NOLINT(runtime/explicit)
   Arg(Dec dec);  // NOLINT(runtime/explicit)
 
+  // vector<bool>::reference and const_reference require special help to
+  // convert to `AlphaNum` because it requires two user defined conversions.
+  template <typename T,
+            absl::enable_if_t<
+                std::is_class<T>::value &&
+                (std::is_same<T, std::vector<bool>::reference>::value ||
+                 std::is_same<T, std::vector<bool>::const_reference>::value)>* =
+                nullptr>
+  Arg(T value)  // NOLINT(google-explicit-constructor)
+      : Arg(static_cast<bool>(value)) {}
+
   // `void*` values, with the exception of `char*`, are printed as
   // "0x<hex value>". However, in the case of `nullptr`, "NULL" is printed.
   Arg(const void* value);  // NOLINT(runtime/explicit)