diff options
Diffstat (limited to 'absl/types')
-rw-r--r-- | absl/types/optional.h | 5 | ||||
-rw-r--r-- | absl/types/span_test.cc | 15 |
2 files changed, 18 insertions, 2 deletions
diff --git a/absl/types/optional.h b/absl/types/optional.h index fd185f353f3e..d800ca684267 100644 --- a/absl/types/optional.h +++ b/absl/types/optional.h @@ -295,7 +295,7 @@ class optional_data<T, false> : public optional_data_base<T> { optional_data() = default; - optional_data(const optional_data& rhs) { + optional_data(const optional_data& rhs) : optional_data_base<T>() { if (rhs.engaged_) { this->construct(rhs.data_); } @@ -303,7 +303,8 @@ class optional_data<T, false> : public optional_data_base<T> { optional_data(optional_data&& rhs) noexcept( absl::default_allocator_is_nothrow::value || - std::is_nothrow_move_constructible<T>::value) { + std::is_nothrow_move_constructible<T>::value) + : optional_data_base<T>() { if (rhs.engaged_) { this->construct(std::move(rhs.data_)); } diff --git a/absl/types/span_test.cc b/absl/types/span_test.cc index bd739ff2a070..f4203b5233b6 100644 --- a/absl/types/span_test.cc +++ b/absl/types/span_test.cc @@ -779,4 +779,19 @@ TEST(Span, SpanSize) { EXPECT_LE(sizeof(absl::Span<BigStruct>), 2 * sizeof(void*)); } +TEST(Span, Hash) { + int array[] = {1, 2, 3, 4}; + int array2[] = {1, 2, 3}; + using T = absl::Span<const int>; + EXPECT_TRUE(absl::VerifyTypeImplementsAbslHashCorrectly( + {// Empties + T(), T(nullptr, 0), T(array, 0), T(array2, 0), + // Different array with same value + T(array, 3), T(array2), T({1, 2, 3}), + // Same array, but different length + T(array, 1), T(array, 2), + // Same length, but different array + T(array + 1, 2), T(array + 2, 2)})); +} + } // namespace |