Export of internal Abseil changes.
-- 9fa04b5fb4b6aeb47226b9095b3bc36a53669c39 by Abseil Team <absl-team@google.com>: Release types/compare.h, which contains stand ins for three-way comparison result types from C++20. Use absl::weak_ordering for a three-way comparator in test-instance-tracker.h. PiperOrigin-RevId: 247290078 -- 70a762f4eb35ea1d5a5fcb3274a8086824a0b82c by Derek Mauro <dmauro@google.com>: Upgrade linux_clang-latest builds to LLVM r356814 and Bazel 0.25.0 PiperOrigin-RevId: 247250176 -- f305cd5c36561e4dbb69eb87568553ae5badcb15 by CJ Johnson <johnsoncj@google.com>: Remove argument deduction based on template template argument in InlinedVector/Storage PiperOrigin-RevId: 247232334 -- 2cab8e426838baceb7d08edb313416480d26aa5b by Eric Fiselier <ericwf@google.com>: Import of CCTZ from GitHub. PiperOrigin-RevId: 247140132 GitOrigin-RevId: 9fa04b5fb4b6aeb47226b9095b3bc36a53669c39 Change-Id: I373a7d9bc90befa2a9f06555cb8703610c0313b9
This commit is contained in:
parent
aa468ad755
commit
27c2f6e2f3
18 changed files with 982 additions and 14 deletions
|
|
@ -213,6 +213,7 @@ cc_library(
|
|||
visibility = [
|
||||
"//absl:__subpackages__",
|
||||
],
|
||||
deps = ["//absl/types:compare"],
|
||||
)
|
||||
|
||||
cc_test(
|
||||
|
|
|
|||
|
|
@ -204,6 +204,8 @@ absl_cc_library(
|
|||
"internal/test_instance_tracker.cc"
|
||||
COPTS
|
||||
${ABSL_DEFAULT_COPTS}
|
||||
DEPS
|
||||
absl::compare
|
||||
TESTONLY
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ class InlinedVector {
|
|||
static_assert(
|
||||
N > 0, "InlinedVector cannot be instantiated with `0` inlined elements.");
|
||||
|
||||
using Storage = inlined_vector_internal::Storage<InlinedVector>;
|
||||
using Storage = inlined_vector_internal::Storage<T, N, A>;
|
||||
using AllocatorTraits = typename Storage::AllocatorTraits;
|
||||
|
||||
template <typename Iterator>
|
||||
|
|
|
|||
|
|
@ -31,12 +31,8 @@ using IsAtLeastForwardIterator = std::is_convertible<
|
|||
typename std::iterator_traits<Iterator>::iterator_category,
|
||||
std::forward_iterator_tag>;
|
||||
|
||||
template <typename InlinedVector>
|
||||
class Storage;
|
||||
|
||||
template <template <typename, size_t, typename> class InlinedVector, typename T,
|
||||
size_t N, typename A>
|
||||
class Storage<InlinedVector<T, N, A>> {
|
||||
template <typename T, size_t N, typename A>
|
||||
class Storage {
|
||||
public:
|
||||
using allocator_type = A;
|
||||
using value_type = typename allocator_type::value_type;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@
|
|||
#include <cstdlib>
|
||||
#include <ostream>
|
||||
|
||||
#include "absl/types/compare.h"
|
||||
|
||||
namespace absl {
|
||||
namespace test_internal {
|
||||
|
||||
|
|
@ -96,6 +98,14 @@ class BaseCountedInstance {
|
|||
return value_ >= x.value_;
|
||||
}
|
||||
|
||||
absl::weak_ordering compare(const BaseCountedInstance& x) const {
|
||||
++num_comparisons_;
|
||||
return value_ < x.value_
|
||||
? absl::weak_ordering::less
|
||||
: value_ == x.value_ ? absl::weak_ordering::equivalent
|
||||
: absl::weak_ordering::greater;
|
||||
}
|
||||
|
||||
int value() const {
|
||||
if (!is_live_) std::abort();
|
||||
return value_;
|
||||
|
|
|
|||
|
|
@ -174,6 +174,8 @@ TEST(TestInstanceTracker, Comparisons) {
|
|||
EXPECT_EQ(5, tracker.comparisons());
|
||||
EXPECT_FALSE(one >= two);
|
||||
EXPECT_EQ(6, tracker.comparisons());
|
||||
EXPECT_TRUE(one.compare(two) < 0); // NOLINT
|
||||
EXPECT_EQ(7, tracker.comparisons());
|
||||
|
||||
tracker.ResetCopiesMovesSwaps();
|
||||
EXPECT_EQ(0, tracker.comparisons());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue