summaryrefslogtreecommitdiff
path: root/absl/strings/internal
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2019-05-17 10:51:37 -0700
committerGravatar Andy Soffer <asoffer@google.com>2019-05-17 14:57:29 -0400
commit8a394b19c149cab50534b04c5e21d42bc2217a7d (patch)
tree3ea451639d15b28cb2d5749be5267818669247ec /absl/strings/internal
parentdaf381e8535a1f1f1b8a75966a74e7cca63dee89 (diff)
Export of internal Abseil changes.
-- cae9f0c87632d690ec3f471e181be247fe4fb025 by Abseil Team <absl-team@google.com>: Run IWYU on some headers. PiperOrigin-RevId: 248749194 -- f57dcac97cacbe31769a8646020a99b6686987dc by Samuel Benzaquen <sbenza@google.com>: Accept vector<bool>::reference in StrFormat and friends. The proxy types might overload `operator&`. Use std::addressof instead. PiperOrigin-RevId: 248619661 GitOrigin-RevId: cae9f0c87632d690ec3f471e181be247fe4fb025 Change-Id: Iacf5d46a59d1d5f1fa1fd4a1e0d0de8c6cbedb3e
Diffstat (limited to 'absl/strings/internal')
-rw-r--r--absl/strings/internal/str_format/arg.h3
-rw-r--r--absl/strings/internal/str_format/convert_test.cc11
2 files changed, 13 insertions, 1 deletions
diff --git a/absl/strings/internal/str_format/arg.h b/absl/strings/internal/str_format/arg.h
index 4d48af06..5cb3a14d 100644
--- a/absl/strings/internal/str_format/arg.h
+++ b/absl/strings/internal/str_format/arg.h
@@ -7,6 +7,7 @@
#include <cstdio>
#include <iomanip>
#include <limits>
+#include <memory>
#include <sstream>
#include <string>
#include <type_traits>
@@ -292,7 +293,7 @@ class FormatArgImpl {
struct Manager<T, ByPointer> {
static Data SetValue(const T& value) {
Data data;
- data.ptr = &value;
+ data.ptr = std::addressof(value);
return data;
}
diff --git a/absl/strings/internal/str_format/convert_test.cc b/absl/strings/internal/str_format/convert_test.cc
index 3b4d4b0c..814ccf4c 100644
--- a/absl/strings/internal/str_format/convert_test.cc
+++ b/absl/strings/internal/str_format/convert_test.cc
@@ -367,6 +367,17 @@ typedef ::testing::Types<
INSTANTIATE_TYPED_TEST_CASE_P(TypedFormatConvertTestWithAllIntTypes,
TypedFormatConvertTest, AllIntTypes);
+TEST_F(FormatConvertTest, VectorBool) {
+ // Make sure vector<bool>'s values behave as bools.
+ std::vector<bool> v = {true, false};
+ const std::vector<bool> cv = {true, false};
+ EXPECT_EQ("1,0,1,0",
+ FormatPack(UntypedFormatSpecImpl("%d,%d,%d,%d"),
+ absl::Span<const FormatArgImpl>(
+ {FormatArgImpl(v[0]), FormatArgImpl(v[1]),
+ FormatArgImpl(cv[0]), FormatArgImpl(cv[1])})));
+}
+
TEST_F(FormatConvertTest, Uint128) {
absl::uint128 v = static_cast<absl::uint128>(0x1234567890abcdef) * 1979;
absl::uint128 max = absl::Uint128Max();