about summary refs log tree commit diff
path: root/absl/strings/str_cat.h
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2018-03-21T04·10-0700
committerkatzdm <katzdm@google.com>2018-03-21T14·51-0400
commit4e2e6c5c0071e6430056a8ef0a6c8a1fe584d8ff (patch)
tree37fb874b61a1ef7dac7cc6efa36de0b2cc2f40d7 /absl/strings/str_cat.h
parent506fb4b56a339314fde23802bd749dbc3b3c1c79 (diff)
Changes imported from Abseil "staging" branch:
  - 1320147f7597a9490562d439ecea46faa1793a24 Support Hex formatting of pointers without forcing a cast... by Jorg Brown <jorg@google.com>
  - 13c793d6e14a52063c2d4ee327b6c976631b690e Add support for native WebAssembly llvm backend. by Abseil Team <absl-team@google.com>

GitOrigin-RevId: 1320147f7597a9490562d439ecea46faa1793a24
Change-Id: Ibd4dbf288903ab45387932e5b11a28f5accdf166
Diffstat (limited to 'absl/strings/str_cat.h')
-rw-r--r--absl/strings/str_cat.h27
1 files changed, 19 insertions, 8 deletions
diff --git a/absl/strings/str_cat.h b/absl/strings/str_cat.h
index 0c33b6ccd243..e38369cab7ff 100644
--- a/absl/strings/str_cat.h
+++ b/absl/strings/str_cat.h
@@ -127,21 +127,32 @@ struct Hex {
   char fill;
 
   template <typename Int>
-  explicit Hex(Int v, PadSpec spec = absl::kNoPad,
-               typename std::enable_if<sizeof(Int) == 1>::type* = nullptr)
+  explicit Hex(
+      Int v, PadSpec spec = absl::kNoPad,
+      typename std::enable_if<sizeof(Int) == 1 &&
+                              !std::is_pointer<Int>::value>::type* = nullptr)
       : Hex(spec, static_cast<uint8_t>(v)) {}
   template <typename Int>
-  explicit Hex(Int v, PadSpec spec = absl::kNoPad,
-               typename std::enable_if<sizeof(Int) == 2>::type* = nullptr)
+  explicit Hex(
+      Int v, PadSpec spec = absl::kNoPad,
+      typename std::enable_if<sizeof(Int) == 2 &&
+                              !std::is_pointer<Int>::value>::type* = nullptr)
       : Hex(spec, static_cast<uint16_t>(v)) {}
   template <typename Int>
-  explicit Hex(Int v, PadSpec spec = absl::kNoPad,
-               typename std::enable_if<sizeof(Int) == 4>::type* = nullptr)
+  explicit Hex(
+      Int v, PadSpec spec = absl::kNoPad,
+      typename std::enable_if<sizeof(Int) == 4 &&
+                              !std::is_pointer<Int>::value>::type* = nullptr)
       : Hex(spec, static_cast<uint32_t>(v)) {}
   template <typename Int>
-  explicit Hex(Int v, PadSpec spec = absl::kNoPad,
-               typename std::enable_if<sizeof(Int) == 8>::type* = nullptr)
+  explicit Hex(
+      Int v, PadSpec spec = absl::kNoPad,
+      typename std::enable_if<sizeof(Int) == 8 &&
+                              !std::is_pointer<Int>::value>::type* = nullptr)
       : Hex(spec, static_cast<uint64_t>(v)) {}
+  template <typename Pointee>
+  explicit Hex(Pointee* v, PadSpec spec = absl::kNoPad)
+      : Hex(spec, reinterpret_cast<uintptr_t>(v)) {}
 
  private:
   Hex(PadSpec spec, uint64_t v)