Export of internal Abseil changes
-- d857e6e1f9b09a3eb5abd890677a98b23346f07a by Abseil Team <absl-team@google.com>: Simplify internal TryAcquireWithSpinning. No point declaring the `result` variable: we can just return the results directly. PiperOrigin-RevId: 307045800 -- 421952252bc23be51f47f7d23f3422bad1ed382c by Derek Mauro <dmauro@google.com>: Add custom sink support for `absl::Format()` through an ADL extension mechanism. Users can now define `void AbslFormatFlush(MySink* dest, absl::string_view part)` to allow `absl::Format()` to append to a custom sink. PiperOrigin-RevId: 306929052 -- c73d5cdb62cd58ea421ed1aeeab78a0ffcfeeefb by Matt Calabrese <calabrese@google.com>: Internal-only conformance-testing macro ABSL_INTERNAL_ASSERT_CONFORMANCE_OF for compile-time and runtime checks of a specified type, expected properties of that type, and a logically-ordered series of equivalence classes of that type. PiperOrigin-RevId: 306885512 -- a8c2495a07f37d68907855e3f0535bd5c27a3b52 by Abseil Team <absl-team@google.com>: Internal change PiperOrigin-RevId: 306766753 GitOrigin-RevId: d857e6e1f9b09a3eb5abd890677a98b23346f07a Change-Id: Ic23c92ac74f9ffcbb2471ff8c6691f4b7b20354b
This commit is contained in:
		
							parent
							
								
									db5773a721
								
							
						
					
					
						commit
						b35973e3e3
					
				
					 16 changed files with 3096 additions and 44 deletions
				
			
		| 
						 | 
				
			
			@ -294,6 +294,8 @@ set(ABSL_INTERNAL_DLL_FILES
 | 
			
		|||
  "types/internal/conformance_aliases.h"
 | 
			
		||||
  "types/internal/conformance_archetype.h"
 | 
			
		||||
  "types/internal/conformance_profile.h"
 | 
			
		||||
  "types/internal/parentheses.h"
 | 
			
		||||
  "types/internal/transform_args.h"
 | 
			
		||||
  "types/internal/variant.h"
 | 
			
		||||
  "types/optional.h"
 | 
			
		||||
  "types/internal/optional.h"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -651,6 +651,7 @@ cc_test(
 | 
			
		|||
    copts = ABSL_TEST_COPTS,
 | 
			
		||||
    visibility = ["//visibility:private"],
 | 
			
		||||
    deps = [
 | 
			
		||||
        ":cord",
 | 
			
		||||
        ":str_format",
 | 
			
		||||
        ":strings",
 | 
			
		||||
        "//absl/base:core_headers",
 | 
			
		||||
| 
						 | 
				
			
			@ -666,8 +667,10 @@ cc_test(
 | 
			
		|||
    copts = ABSL_TEST_COPTS,
 | 
			
		||||
    visibility = ["//visibility:private"],
 | 
			
		||||
    deps = [
 | 
			
		||||
        ":cord",
 | 
			
		||||
        ":str_format",
 | 
			
		||||
        ":str_format_internal",
 | 
			
		||||
        ":strings",
 | 
			
		||||
        "@com_google_googletest//:gtest_main",
 | 
			
		||||
    ],
 | 
			
		||||
)
 | 
			
		||||
| 
						 | 
				
			
			@ -726,6 +729,7 @@ cc_test(
 | 
			
		|||
    copts = ABSL_TEST_COPTS,
 | 
			
		||||
    visibility = ["//visibility:private"],
 | 
			
		||||
    deps = [
 | 
			
		||||
        ":cord",
 | 
			
		||||
        ":str_format_internal",
 | 
			
		||||
        "@com_google_googletest//:gtest_main",
 | 
			
		||||
    ],
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -409,6 +409,7 @@ absl_cc_test(
 | 
			
		|||
    ${ABSL_TEST_COPTS}
 | 
			
		||||
  DEPS
 | 
			
		||||
    absl::str_format
 | 
			
		||||
    absl::cord
 | 
			
		||||
    absl::strings
 | 
			
		||||
    absl::core_headers
 | 
			
		||||
    gmock_main
 | 
			
		||||
| 
						 | 
				
			
			@ -424,6 +425,8 @@ absl_cc_test(
 | 
			
		|||
  DEPS
 | 
			
		||||
    absl::str_format
 | 
			
		||||
    absl::str_format_internal
 | 
			
		||||
    absl::cord
 | 
			
		||||
    absl::strings
 | 
			
		||||
    gmock_main
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -487,6 +490,7 @@ absl_cc_test(
 | 
			
		|||
    ${ABSL_TEST_COPTS}
 | 
			
		||||
  DEPS
 | 
			
		||||
    absl::str_format_internal
 | 
			
		||||
    absl::cord
 | 
			
		||||
    gmock_main
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,9 +19,27 @@
 | 
			
		|||
#include <random>
 | 
			
		||||
#include <string>
 | 
			
		||||
 | 
			
		||||
#include "absl/strings/str_format.h"
 | 
			
		||||
 | 
			
		||||
#include "absl/strings/cord.h"
 | 
			
		||||
#include "gtest/gtest.h"
 | 
			
		||||
#include "absl/strings/str_format.h"
 | 
			
		||||
#include "absl/strings/string_view.h"
 | 
			
		||||
 | 
			
		||||
namespace my_namespace {
 | 
			
		||||
class UserDefinedType {
 | 
			
		||||
 public:
 | 
			
		||||
  UserDefinedType() = default;
 | 
			
		||||
 | 
			
		||||
  void Append(absl::string_view str) { value_.append(str.data(), str.size()); }
 | 
			
		||||
  const std::string& Value() const { return value_; }
 | 
			
		||||
 | 
			
		||||
  friend void AbslFormatFlush(UserDefinedType* x, absl::string_view str) {
 | 
			
		||||
    x->Append(str);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 private:
 | 
			
		||||
  std::string value_;
 | 
			
		||||
};
 | 
			
		||||
}  // namespace my_namespace
 | 
			
		||||
 | 
			
		||||
namespace {
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -63,4 +81,21 @@ TEST(FormatExtensionTest, SinkAppendChars) {
 | 
			
		|||
    EXPECT_EQ(actual, expected);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST(FormatExtensionTest, CordSink) {
 | 
			
		||||
  absl::Cord c;
 | 
			
		||||
  absl::Format(&c, "There were %04d little %s.", 3, "pigs");
 | 
			
		||||
  EXPECT_EQ(c, "There were 0003 little pigs.");
 | 
			
		||||
  absl::Format(&c, "And %-3llx bad wolf!", 1);
 | 
			
		||||
  EXPECT_EQ(c, "There were 0003 little pigs.And 1   bad wolf!");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST(FormatExtensionTest, CustomSink) {
 | 
			
		||||
  my_namespace::UserDefinedType sink;
 | 
			
		||||
  absl::Format(&sink, "There were %04d little %s.", 3, "pigs");
 | 
			
		||||
  EXPECT_EQ("There were 0003 little pigs.", sink.Value());
 | 
			
		||||
  absl::Format(&sink, "And %-3llx bad wolf!", 1);
 | 
			
		||||
  EXPECT_EQ("There were 0003 little pigs.And 1   bad wolf!", sink.Value());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
}  // namespace
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -91,10 +91,11 @@ inline void AbslFormatFlush(BufferRawSink* sink, string_view v) {
 | 
			
		|||
  sink->Write(v);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// This is a SFINAE to get a better compiler error message when the type
 | 
			
		||||
// is not supported.
 | 
			
		||||
template <typename T>
 | 
			
		||||
auto InvokeFlush(T* out, string_view s)
 | 
			
		||||
    -> decltype(str_format_internal::AbslFormatFlush(out, s)) {
 | 
			
		||||
  str_format_internal::AbslFormatFlush(out, s);
 | 
			
		||||
auto InvokeFlush(T* out, string_view s) -> decltype(AbslFormatFlush(out, s)) {
 | 
			
		||||
  AbslFormatFlush(out, s);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
}  // namespace str_format_internal
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,6 +19,7 @@
 | 
			
		|||
 | 
			
		||||
#include "gmock/gmock.h"
 | 
			
		||||
#include "gtest/gtest.h"
 | 
			
		||||
#include "absl/strings/cord.h"
 | 
			
		||||
 | 
			
		||||
namespace absl {
 | 
			
		||||
ABSL_NAMESPACE_BEGIN
 | 
			
		||||
| 
						 | 
				
			
			@ -37,6 +38,12 @@ TEST(InvokeFlush, Stream) {
 | 
			
		|||
  EXPECT_EQ(str.str(), "ABCDEF");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST(InvokeFlush, Cord) {
 | 
			
		||||
  absl::Cord str("ABC");
 | 
			
		||||
  str_format_internal::InvokeFlush(&str, "DEF");
 | 
			
		||||
  EXPECT_EQ(str, "ABCDEF");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST(BufferRawSink, Limits) {
 | 
			
		||||
  char buf[16];
 | 
			
		||||
  {
 | 
			
		||||
| 
						 | 
				
			
			@ -70,4 +77,3 @@ TEST(BufferRawSink, Limits) {
 | 
			
		|||
}  // namespace
 | 
			
		||||
ABSL_NAMESPACE_END
 | 
			
		||||
}  // namespace absl
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -57,8 +57,7 @@
 | 
			
		|||
// arbitrary sink types:
 | 
			
		||||
//
 | 
			
		||||
//   * A generic `Format()` function to write outputs to arbitrary sink types,
 | 
			
		||||
//     which must implement a `RawSinkFormat` interface. (See
 | 
			
		||||
//     `str_format_sink.h` for more information.)
 | 
			
		||||
//     which must implement a `FormatRawSink` interface.
 | 
			
		||||
//
 | 
			
		||||
//   * A `FormatUntyped()` function that is similar to `Format()` except it is
 | 
			
		||||
//     loosely typed. `FormatUntyped()` is not a template and does not perform
 | 
			
		||||
| 
						 | 
				
			
			@ -432,6 +431,16 @@ int SNPrintF(char* output, std::size_t size, const FormatSpec<Args...>& format,
 | 
			
		|||
//
 | 
			
		||||
// FormatRawSink is a type erased wrapper around arbitrary sink objects
 | 
			
		||||
// specifically used as an argument to `Format()`.
 | 
			
		||||
//
 | 
			
		||||
// All the object has to do define an overload of `AbslFormatFlush()` for the
 | 
			
		||||
// sink, usually by adding a ADL-based free function in the same namespace as
 | 
			
		||||
// the sink:
 | 
			
		||||
//
 | 
			
		||||
//   void AbslFormatFlush(MySink* dest, absl::string_view part);
 | 
			
		||||
//
 | 
			
		||||
// where `dest` is the pointer passed to `absl::Format()`. The function should
 | 
			
		||||
// append `part` to `dest`.
 | 
			
		||||
//
 | 
			
		||||
// FormatRawSink does not own the passed sink object. The passed object must
 | 
			
		||||
// outlive the FormatRawSink.
 | 
			
		||||
class FormatRawSink {
 | 
			
		||||
| 
						 | 
				
			
			@ -455,12 +464,13 @@ class FormatRawSink {
 | 
			
		|||
// `absl::FormatRawSink` interface), using a format string and zero or more
 | 
			
		||||
// additional arguments.
 | 
			
		||||
//
 | 
			
		||||
// By default, `std::string` and `std::ostream` are supported as destination
 | 
			
		||||
// objects. If a `std::string` is used the formatted string is appended to it.
 | 
			
		||||
// By default, `std::string`, `std::ostream`, and `absl::Cord` are supported as
 | 
			
		||||
// destination objects. If a `std::string` is used the formatted string is
 | 
			
		||||
// appended to it.
 | 
			
		||||
//
 | 
			
		||||
// `absl::Format()` is a generic version of `absl::StrFormat(), for custom
 | 
			
		||||
// sinks. The format string, like format strings for `StrFormat()`, is checked
 | 
			
		||||
// at compile-time.
 | 
			
		||||
// `absl::Format()` is a generic version of `absl::StrAppendFormat()`, for
 | 
			
		||||
// custom sinks. The format string, like format strings for `StrFormat()`, is
 | 
			
		||||
// checked at compile-time.
 | 
			
		||||
//
 | 
			
		||||
// On failure, this function returns `false` and the state of the sink is
 | 
			
		||||
// unspecified.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1439,20 +1439,18 @@ void Mutex::AssertNotHeld() const {
 | 
			
		|||
// may spin for a short while if the lock cannot be acquired immediately.
 | 
			
		||||
static bool TryAcquireWithSpinning(std::atomic<intptr_t>* mu) {
 | 
			
		||||
  int c = mutex_globals.spinloop_iterations;
 | 
			
		||||
  int result = -1;  // result of operation:  0=false, 1=true, -1=unknown
 | 
			
		||||
 | 
			
		||||
  do {  // do/while somewhat faster on AMD
 | 
			
		||||
    intptr_t v = mu->load(std::memory_order_relaxed);
 | 
			
		||||
    if ((v & (kMuReader|kMuEvent)) != 0) {  // a reader or tracing -> give up
 | 
			
		||||
      result = 0;
 | 
			
		||||
    if ((v & (kMuReader|kMuEvent)) != 0) {
 | 
			
		||||
      return false;  // a reader or tracing -> give up
 | 
			
		||||
    } else if (((v & kMuWriter) == 0) &&  // no holder -> try to acquire
 | 
			
		||||
               mu->compare_exchange_strong(v, kMuWriter | v,
 | 
			
		||||
                                           std::memory_order_acquire,
 | 
			
		||||
                                           std::memory_order_relaxed)) {
 | 
			
		||||
      result = 1;
 | 
			
		||||
      return true;
 | 
			
		||||
    }
 | 
			
		||||
  } while (result == -1 && --c > 0);
 | 
			
		||||
  return result == 1;
 | 
			
		||||
  } while (--c > 0);
 | 
			
		||||
  return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ABSL_XRAY_LOG_ARGS(1) void Mutex::Lock() {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -216,11 +216,15 @@ cc_library(
 | 
			
		|||
        "internal/conformance_aliases.h",
 | 
			
		||||
        "internal/conformance_archetype.h",
 | 
			
		||||
        "internal/conformance_profile.h",
 | 
			
		||||
        "internal/conformance_testing.h",
 | 
			
		||||
        "internal/conformance_testing_helpers.h",
 | 
			
		||||
        "internal/parentheses.h",
 | 
			
		||||
        "internal/transform_args.h",
 | 
			
		||||
    ],
 | 
			
		||||
    copts = ABSL_TEST_COPTS,
 | 
			
		||||
    linkopts = ABSL_DEFAULT_LINKOPTS,
 | 
			
		||||
    deps = [
 | 
			
		||||
        "//absl/debugging:demangle_internal",
 | 
			
		||||
        "//absl/algorithm:container",
 | 
			
		||||
        "//absl/meta:type_traits",
 | 
			
		||||
        "//absl/strings",
 | 
			
		||||
        "//absl/utility",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -246,9 +246,14 @@ absl_cc_library(
 | 
			
		|||
    "internal/conformance_aliases.h"
 | 
			
		||||
    "internal/conformance_archetype.h"
 | 
			
		||||
    "internal/conformance_profile.h"
 | 
			
		||||
    "internal/conformance_testing.h",
 | 
			
		||||
    "internal/conformance_testing_helpers.h",
 | 
			
		||||
    "internal/parentheses.h",
 | 
			
		||||
    "internal/transform_args.h",
 | 
			
		||||
  COPTS
 | 
			
		||||
    ${ABSL_DEFAULT_COPTS}
 | 
			
		||||
  DEPS
 | 
			
		||||
    absl::algorithm
 | 
			
		||||
    absl::debugging
 | 
			
		||||
    absl::type_traits
 | 
			
		||||
    absl::strings
 | 
			
		||||
| 
						 | 
				
			
			@ -282,6 +287,7 @@ absl_cc_test(
 | 
			
		|||
    ${ABSL_TEST_COPTS}
 | 
			
		||||
  DEPS
 | 
			
		||||
    absl::conformance_testing
 | 
			
		||||
    absl::type_traits
 | 
			
		||||
    gmock_main
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -36,10 +36,19 @@
 | 
			
		|||
#ifndef ABSL_TYPES_INTERNAL_CONFORMANCE_PROFILE_H_
 | 
			
		||||
#define ABSL_TYPES_INTERNAL_CONFORMANCE_PROFILE_H_
 | 
			
		||||
 | 
			
		||||
#include <set>
 | 
			
		||||
#include <type_traits>
 | 
			
		||||
#include <utility>
 | 
			
		||||
#include <vector>
 | 
			
		||||
 | 
			
		||||
#include "gtest/gtest.h"
 | 
			
		||||
#include "absl/algorithm/container.h"
 | 
			
		||||
#include "absl/meta/type_traits.h"
 | 
			
		||||
#include "absl/strings/ascii.h"
 | 
			
		||||
#include "absl/strings/str_cat.h"
 | 
			
		||||
#include "absl/strings/string_view.h"
 | 
			
		||||
#include "absl/types/internal/conformance_testing_helpers.h"
 | 
			
		||||
#include "absl/utility/utility.h"
 | 
			
		||||
 | 
			
		||||
// TODO(calabrese) Add support for extending profiles.
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -47,6 +56,187 @@ namespace absl {
 | 
			
		|||
ABSL_NAMESPACE_BEGIN
 | 
			
		||||
namespace types_internal {
 | 
			
		||||
 | 
			
		||||
// Converts an enum to its underlying integral value.
 | 
			
		||||
template <typename Enum>
 | 
			
		||||
constexpr absl::underlying_type_t<Enum> UnderlyingValue(Enum value) {
 | 
			
		||||
  return static_cast<absl::underlying_type_t<Enum>>(value);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// A tag type used in place of a matcher when checking that an assertion result
 | 
			
		||||
// does not actually contain any errors.
 | 
			
		||||
struct NoError {};
 | 
			
		||||
 | 
			
		||||
// -----------------------------------------------------------------------------
 | 
			
		||||
// ConformanceErrors
 | 
			
		||||
// -----------------------------------------------------------------------------
 | 
			
		||||
class ConformanceErrors {
 | 
			
		||||
 public:
 | 
			
		||||
  // Setup the error reporting mechanism by seeding it with the name of the type
 | 
			
		||||
  // that is being tested.
 | 
			
		||||
  explicit ConformanceErrors(std::string type_name)
 | 
			
		||||
      : assertion_result_(false), type_name_(std::move(type_name)) {
 | 
			
		||||
    assertion_result_ << "\n\n"
 | 
			
		||||
                         "Assuming the following type alias:\n"
 | 
			
		||||
                         "\n"
 | 
			
		||||
                         "  using _T = "
 | 
			
		||||
                      << type_name_ << ";\n\n";
 | 
			
		||||
    outputDivider();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Adds the test name to the list of successfully run tests iff it was not
 | 
			
		||||
  // previously reported as failing. This behavior is useful for tests that
 | 
			
		||||
  // have multiple parts, where failures and successes are reported individually
 | 
			
		||||
  // with the same test name.
 | 
			
		||||
  void addTestSuccess(absl::string_view test_name) {
 | 
			
		||||
    auto normalized_test_name = absl::AsciiStrToLower(test_name);
 | 
			
		||||
 | 
			
		||||
    // If the test is already reported as failing, do not add it to the list of
 | 
			
		||||
    // successes.
 | 
			
		||||
    if (test_failures_.find(normalized_test_name) == test_failures_.end()) {
 | 
			
		||||
      test_successes_.insert(std::move(normalized_test_name));
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Streams a single error description into the internal buffer (a visual
 | 
			
		||||
  // divider is automatically inserted after the error so that multiple errors
 | 
			
		||||
  // are visibly distinct).
 | 
			
		||||
  //
 | 
			
		||||
  // This function increases the error count by 1.
 | 
			
		||||
  //
 | 
			
		||||
  // TODO(calabrese) Determine desired behavior when if this function throws.
 | 
			
		||||
  template <class... P>
 | 
			
		||||
  void addTestFailure(absl::string_view test_name, const P&... args) {
 | 
			
		||||
    // Output a message related to the test failure.
 | 
			
		||||
    assertion_result_ << "\n\n"
 | 
			
		||||
                         "Failed test: "
 | 
			
		||||
                      << test_name << "\n\n";
 | 
			
		||||
    addTestFailureImpl(args...);
 | 
			
		||||
    assertion_result_ << "\n\n";
 | 
			
		||||
    outputDivider();
 | 
			
		||||
 | 
			
		||||
    auto normalized_test_name = absl::AsciiStrToLower(test_name);
 | 
			
		||||
 | 
			
		||||
    // If previous parts of this test succeeded, remove it from that set.
 | 
			
		||||
    test_successes_.erase(normalized_test_name);
 | 
			
		||||
 | 
			
		||||
    // Add the test name to the list of failed tests.
 | 
			
		||||
    test_failures_.insert(std::move(normalized_test_name));
 | 
			
		||||
 | 
			
		||||
    has_error_ = true;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Convert this object into a testing::AssertionResult instance such that it
 | 
			
		||||
  // can be used with gtest.
 | 
			
		||||
  ::testing::AssertionResult assertionResult() const {
 | 
			
		||||
    return has_error_ ? assertion_result_ : ::testing::AssertionSuccess();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // Convert this object into a testing::AssertionResult instance such that it
 | 
			
		||||
  // can be used with gtest. This overload expects errors, using the specified
 | 
			
		||||
  // matcher.
 | 
			
		||||
  ::testing::AssertionResult expectFailedTests(
 | 
			
		||||
      const std::set<std::string>& test_names) const {
 | 
			
		||||
    // Since we are expecting nonconformance, output an error message when the
 | 
			
		||||
    // type actually conformed to the specified profile.
 | 
			
		||||
    if (!has_error_) {
 | 
			
		||||
      return ::testing::AssertionFailure()
 | 
			
		||||
             << "Unexpected conformance of type:\n"
 | 
			
		||||
                "    "
 | 
			
		||||
             << type_name_ << "\n\n";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Get a list of all expected failures that did not actually fail
 | 
			
		||||
    // (or that were not run).
 | 
			
		||||
    std::vector<std::string> nonfailing_tests;
 | 
			
		||||
    absl::c_set_difference(test_names, test_failures_,
 | 
			
		||||
                           std::back_inserter(nonfailing_tests));
 | 
			
		||||
 | 
			
		||||
    // Get a list of all "expected failures" that were never actually run.
 | 
			
		||||
    std::vector<std::string> unrun_tests;
 | 
			
		||||
    absl::c_set_difference(nonfailing_tests, test_successes_,
 | 
			
		||||
                           std::back_inserter(unrun_tests));
 | 
			
		||||
 | 
			
		||||
    // Report when the user specified tests that were not run.
 | 
			
		||||
    if (!unrun_tests.empty()) {
 | 
			
		||||
      const bool tests_were_run =
 | 
			
		||||
          !(test_failures_.empty() && test_successes_.empty());
 | 
			
		||||
 | 
			
		||||
      // Prepare an assertion result used in the case that tests pass that were
 | 
			
		||||
      // expected to fail.
 | 
			
		||||
      ::testing::AssertionResult result = ::testing::AssertionFailure();
 | 
			
		||||
      result << "When testing type:\n    " << type_name_
 | 
			
		||||
             << "\n\nThe following tests were expected to fail but were not "
 | 
			
		||||
                "run";
 | 
			
		||||
 | 
			
		||||
      if (tests_were_run) result << " (was the test name spelled correctly?)";
 | 
			
		||||
 | 
			
		||||
      result << ":\n\n";
 | 
			
		||||
 | 
			
		||||
      // List all of the tests that unexpectedly passed.
 | 
			
		||||
      for (const auto& test_name : unrun_tests) {
 | 
			
		||||
        result << "    " << test_name << "\n";
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (!tests_were_run) result << "\nNo tests were run.";
 | 
			
		||||
 | 
			
		||||
      if (!test_failures_.empty()) {
 | 
			
		||||
        // List test failures
 | 
			
		||||
        result << "\nThe tests that were run and failed are:\n\n";
 | 
			
		||||
        for (const auto& test_name : test_failures_) {
 | 
			
		||||
          result << "    " << test_name << "\n";
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (!test_successes_.empty()) {
 | 
			
		||||
        // List test successes
 | 
			
		||||
        result << "\nThe tests that were run and succeeded are:\n\n";
 | 
			
		||||
        for (const auto& test_name : test_successes_) {
 | 
			
		||||
          result << "    " << test_name << "\n";
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // If some tests passed when they were expected to fail, alert the caller.
 | 
			
		||||
    if (nonfailing_tests.empty()) return ::testing::AssertionSuccess();
 | 
			
		||||
 | 
			
		||||
    // Prepare an assertion result used in the case that tests pass that were
 | 
			
		||||
    // expected to fail.
 | 
			
		||||
    ::testing::AssertionResult unexpected_successes =
 | 
			
		||||
        ::testing::AssertionFailure();
 | 
			
		||||
    unexpected_successes << "When testing type:\n    " << type_name_
 | 
			
		||||
                         << "\n\nThe following tests passed when they were "
 | 
			
		||||
                            "expected to fail:\n\n";
 | 
			
		||||
 | 
			
		||||
    // List all of the tests that unexpectedly passed.
 | 
			
		||||
    for (const auto& test_name : nonfailing_tests) {
 | 
			
		||||
      unexpected_successes << "    " << test_name << "\n";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return unexpected_successes;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 private:
 | 
			
		||||
  void outputDivider() {
 | 
			
		||||
    assertion_result_ << "========================================";
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  void addTestFailureImpl() {}
 | 
			
		||||
 | 
			
		||||
  template <class H, class... T>
 | 
			
		||||
  void addTestFailureImpl(const H& head, const T&... tail) {
 | 
			
		||||
    assertion_result_ << head;
 | 
			
		||||
    addTestFailureImpl(tail...);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  ::testing::AssertionResult assertion_result_;
 | 
			
		||||
  std::set<std::string> test_failures_;
 | 
			
		||||
  std::set<std::string> test_successes_;
 | 
			
		||||
  std::string type_name_;
 | 
			
		||||
  bool has_error_ = false;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template <class T, class /*Enabler*/ = void>
 | 
			
		||||
struct PropertiesOfImpl {};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -70,31 +260,100 @@ using PropertiesOfT = typename PropertiesOf<T>::type;
 | 
			
		|||
// standard trait names, which is useful since it allows us to match up each
 | 
			
		||||
// enum name with a corresponding trait name in macro definitions.
 | 
			
		||||
 | 
			
		||||
enum class function_kind { maybe, yes, nothrow, trivial };
 | 
			
		||||
// An enum that describes the various expectations on an operations existence.
 | 
			
		||||
enum class function_support { maybe, yes, nothrow, trivial };
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_SPECIAL_MEMBER_FUNCTION_ENUM(name) \
 | 
			
		||||
  enum class name { maybe, yes, nothrow, trivial }
 | 
			
		||||
constexpr const char* PessimisticPropertyDescription(function_support v) {
 | 
			
		||||
  return v == function_support::maybe
 | 
			
		||||
             ? "no"
 | 
			
		||||
             : v == function_support::yes
 | 
			
		||||
                   ? "yes, potentially throwing"
 | 
			
		||||
                   : v == function_support::nothrow ? "yes, nothrow"
 | 
			
		||||
                                                    : "yes, trivial";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ABSL_INTERNAL_SPECIAL_MEMBER_FUNCTION_ENUM(default_constructible);
 | 
			
		||||
ABSL_INTERNAL_SPECIAL_MEMBER_FUNCTION_ENUM(move_constructible);
 | 
			
		||||
ABSL_INTERNAL_SPECIAL_MEMBER_FUNCTION_ENUM(copy_constructible);
 | 
			
		||||
ABSL_INTERNAL_SPECIAL_MEMBER_FUNCTION_ENUM(move_assignable);
 | 
			
		||||
ABSL_INTERNAL_SPECIAL_MEMBER_FUNCTION_ENUM(copy_assignable);
 | 
			
		||||
ABSL_INTERNAL_SPECIAL_MEMBER_FUNCTION_ENUM(destructible);
 | 
			
		||||
// Return a string that describes the kind of property support that was
 | 
			
		||||
// expected.
 | 
			
		||||
inline std::string ExpectedFunctionKindList(function_support min,
 | 
			
		||||
                                            function_support max) {
 | 
			
		||||
  if (min == max) {
 | 
			
		||||
    std::string result =
 | 
			
		||||
        absl::StrCat("Expected:\n  ",
 | 
			
		||||
                     PessimisticPropertyDescription(
 | 
			
		||||
                         static_cast<function_support>(UnderlyingValue(min))),
 | 
			
		||||
                     "\n");
 | 
			
		||||
    return result;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  std::string result = "Expected one of:\n";
 | 
			
		||||
  for (auto curr_support = UnderlyingValue(min);
 | 
			
		||||
       curr_support <= UnderlyingValue(max); ++curr_support) {
 | 
			
		||||
    absl::StrAppend(&result, "  ",
 | 
			
		||||
                    PessimisticPropertyDescription(
 | 
			
		||||
                        static_cast<function_support>(curr_support)),
 | 
			
		||||
                    "\n");
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <class Enum>
 | 
			
		||||
void ExpectModelOfImpl(ConformanceErrors* errors, Enum min_support,
 | 
			
		||||
                       Enum max_support, Enum kind) {
 | 
			
		||||
  const auto kind_value = UnderlyingValue(kind);
 | 
			
		||||
  const auto min_support_value = UnderlyingValue(min_support);
 | 
			
		||||
  const auto max_support_value = UnderlyingValue(max_support);
 | 
			
		||||
 | 
			
		||||
  if (!(kind_value >= min_support_value && kind_value <= max_support_value)) {
 | 
			
		||||
    errors->addTestFailure(
 | 
			
		||||
        PropertyName(kind), "**Failed property expectation**\n\n",
 | 
			
		||||
        ExpectedFunctionKindList(
 | 
			
		||||
            static_cast<function_support>(min_support_value),
 | 
			
		||||
            static_cast<function_support>(max_support_value)),
 | 
			
		||||
        '\n', "Actual:\n  ",
 | 
			
		||||
        PessimisticPropertyDescription(
 | 
			
		||||
            static_cast<function_support>(kind_value)));
 | 
			
		||||
  } else {
 | 
			
		||||
    errors->addTestSuccess(PropertyName(kind));
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_SPECIAL_MEMBER_FUNCTION_ENUM(description, name) \
 | 
			
		||||
  enum class name { maybe, yes, nothrow, trivial };                   \
 | 
			
		||||
                                                                      \
 | 
			
		||||
  constexpr const char* PropertyName(name v) { return description; }  \
 | 
			
		||||
  static_assert(true, "")  // Force a semicolon when using this macro.
 | 
			
		||||
 | 
			
		||||
ABSL_INTERNAL_SPECIAL_MEMBER_FUNCTION_ENUM("support for default construction",
 | 
			
		||||
                                           default_constructible);
 | 
			
		||||
ABSL_INTERNAL_SPECIAL_MEMBER_FUNCTION_ENUM("support for move construction",
 | 
			
		||||
                                           move_constructible);
 | 
			
		||||
ABSL_INTERNAL_SPECIAL_MEMBER_FUNCTION_ENUM("support for copy construction",
 | 
			
		||||
                                           copy_constructible);
 | 
			
		||||
ABSL_INTERNAL_SPECIAL_MEMBER_FUNCTION_ENUM("support for move assignment",
 | 
			
		||||
                                           move_assignable);
 | 
			
		||||
ABSL_INTERNAL_SPECIAL_MEMBER_FUNCTION_ENUM("support for copy assignment",
 | 
			
		||||
                                           copy_assignable);
 | 
			
		||||
ABSL_INTERNAL_SPECIAL_MEMBER_FUNCTION_ENUM("support for destruction",
 | 
			
		||||
                                           destructible);
 | 
			
		||||
 | 
			
		||||
#undef ABSL_INTERNAL_SPECIAL_MEMBER_FUNCTION_ENUM
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM(name) \
 | 
			
		||||
  enum class name { maybe, yes, nothrow }
 | 
			
		||||
#define ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM(description, name)     \
 | 
			
		||||
  enum class name { maybe, yes, nothrow };                           \
 | 
			
		||||
                                                                     \
 | 
			
		||||
  constexpr const char* PropertyName(name v) { return description; } \
 | 
			
		||||
  static_assert(true, "")  // Force a semicolon when using this macro.
 | 
			
		||||
 | 
			
		||||
ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM(equality_comparable);
 | 
			
		||||
ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM(inequality_comparable);
 | 
			
		||||
ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM(less_than_comparable);
 | 
			
		||||
ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM(less_equal_comparable);
 | 
			
		||||
ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM(greater_equal_comparable);
 | 
			
		||||
ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM(greater_than_comparable);
 | 
			
		||||
ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM("support for ==", equality_comparable);
 | 
			
		||||
ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM("support for !=", inequality_comparable);
 | 
			
		||||
ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM("support for <", less_than_comparable);
 | 
			
		||||
ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM("support for <=", less_equal_comparable);
 | 
			
		||||
ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM("support for >=",
 | 
			
		||||
                                      greater_equal_comparable);
 | 
			
		||||
ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM("support for >", greater_than_comparable);
 | 
			
		||||
 | 
			
		||||
ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM(swappable);
 | 
			
		||||
ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM("support for swap", swappable);
 | 
			
		||||
 | 
			
		||||
#undef ABSL_INTERNAL_INTRINSIC_FUNCTION_ENUM
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -104,6 +363,184 @@ constexpr const char* PropertyName(hashable v) {
 | 
			
		|||
  return "support for std::hash";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <class T>
 | 
			
		||||
using AlwaysFalse = std::false_type;
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_PESSIMISTIC_MODEL_OF_SPECIAL_MEMBER(name, property)   \
 | 
			
		||||
  template <class T>                                                        \
 | 
			
		||||
  constexpr property property##_support_of() {                              \
 | 
			
		||||
    return std::is_##property<T>::value                                     \
 | 
			
		||||
               ? std::is_nothrow_##property<T>::value                       \
 | 
			
		||||
                     ? absl::is_trivially_##property<T>::value              \
 | 
			
		||||
                           ? property::trivial                              \
 | 
			
		||||
                           : property::nothrow                              \
 | 
			
		||||
                     : property::yes                                        \
 | 
			
		||||
               : property::maybe;                                           \
 | 
			
		||||
  }                                                                         \
 | 
			
		||||
                                                                            \
 | 
			
		||||
  template <class T, class MinProf, class MaxProf>                          \
 | 
			
		||||
  void ExpectModelOf##name(ConformanceErrors* errors) {                     \
 | 
			
		||||
    (ExpectModelOfImpl)(errors, PropertiesOfT<MinProf>::property##_support, \
 | 
			
		||||
                        PropertiesOfT<MaxProf>::property##_support,         \
 | 
			
		||||
                        property##_support_of<T>());                        \
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
ABSL_INTERNAL_PESSIMISTIC_MODEL_OF_SPECIAL_MEMBER(DefaultConstructible,
 | 
			
		||||
                                                  default_constructible);
 | 
			
		||||
 | 
			
		||||
ABSL_INTERNAL_PESSIMISTIC_MODEL_OF_SPECIAL_MEMBER(MoveConstructible,
 | 
			
		||||
                                                  move_constructible);
 | 
			
		||||
 | 
			
		||||
ABSL_INTERNAL_PESSIMISTIC_MODEL_OF_SPECIAL_MEMBER(CopyConstructible,
 | 
			
		||||
                                                  copy_constructible);
 | 
			
		||||
 | 
			
		||||
ABSL_INTERNAL_PESSIMISTIC_MODEL_OF_SPECIAL_MEMBER(MoveAssignable,
 | 
			
		||||
                                                  move_assignable);
 | 
			
		||||
 | 
			
		||||
ABSL_INTERNAL_PESSIMISTIC_MODEL_OF_SPECIAL_MEMBER(CopyAssignable,
 | 
			
		||||
                                                  copy_assignable);
 | 
			
		||||
 | 
			
		||||
ABSL_INTERNAL_PESSIMISTIC_MODEL_OF_SPECIAL_MEMBER(Destructible, destructible);
 | 
			
		||||
 | 
			
		||||
#undef ABSL_INTERNAL_PESSIMISTIC_MODEL_OF_SPECIAL_MEMBER
 | 
			
		||||
 | 
			
		||||
void BoolFunction(bool) noexcept;
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//
 | 
			
		||||
// A metafunction for checking if an operation exists through SFINAE.
 | 
			
		||||
//
 | 
			
		||||
// `T` is the type to test and Op is an alias containing the expression to test.
 | 
			
		||||
template <class T, template <class...> class Op, class = void>
 | 
			
		||||
struct IsOpableImpl : std::false_type {};
 | 
			
		||||
 | 
			
		||||
template <class T, template <class...> class Op>
 | 
			
		||||
struct IsOpableImpl<T, Op, absl::void_t<Op<T>>> : std::true_type {};
 | 
			
		||||
 | 
			
		||||
template <template <class...> class Op>
 | 
			
		||||
struct IsOpable {
 | 
			
		||||
  template <class T>
 | 
			
		||||
  using apply = typename IsOpableImpl<T, Op>::type;
 | 
			
		||||
};
 | 
			
		||||
//
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//
 | 
			
		||||
// A metafunction for checking if an operation exists and is also noexcept
 | 
			
		||||
// through SFINAE and the noexcept operator.
 | 
			
		||||
///
 | 
			
		||||
// `T` is the type to test and Op is an alias containing the expression to test.
 | 
			
		||||
template <class T, template <class...> class Op, class = void>
 | 
			
		||||
struct IsNothrowOpableImpl : std::false_type {};
 | 
			
		||||
 | 
			
		||||
template <class T, template <class...> class Op>
 | 
			
		||||
struct IsNothrowOpableImpl<T, Op, absl::enable_if_t<Op<T>::value>>
 | 
			
		||||
    : std::true_type {};
 | 
			
		||||
 | 
			
		||||
template <template <class...> class Op>
 | 
			
		||||
struct IsNothrowOpable {
 | 
			
		||||
  template <class T>
 | 
			
		||||
  using apply = typename IsNothrowOpableImpl<T, Op>::type;
 | 
			
		||||
};
 | 
			
		||||
//
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//
 | 
			
		||||
// A macro that produces the necessary function for reporting what kind of
 | 
			
		||||
// support a specific comparison operation has and a function for reporting an
 | 
			
		||||
// error if a given type's support for that operation does not meet the expected
 | 
			
		||||
// requirements.
 | 
			
		||||
#define ABSL_INTERNAL_PESSIMISTIC_MODEL_OF_COMPARISON(name, property, op)      \
 | 
			
		||||
  template <class T,                                                           \
 | 
			
		||||
            class Result = std::integral_constant<                             \
 | 
			
		||||
                bool, noexcept((BoolFunction)(std::declval<const T&>() op      \
 | 
			
		||||
                                                  std::declval<const T&>()))>> \
 | 
			
		||||
  using name = Result;                                                         \
 | 
			
		||||
                                                                               \
 | 
			
		||||
  template <class T>                                                           \
 | 
			
		||||
  constexpr property property##_support_of() {                                 \
 | 
			
		||||
    return IsOpable<name>::apply<T>::value                                     \
 | 
			
		||||
               ? IsNothrowOpable<name>::apply<T>::value ? property::nothrow    \
 | 
			
		||||
                                                        : property::yes        \
 | 
			
		||||
               : property::maybe;                                              \
 | 
			
		||||
  }                                                                            \
 | 
			
		||||
                                                                               \
 | 
			
		||||
  template <class T, class MinProf, class MaxProf>                             \
 | 
			
		||||
  void ExpectModelOf##name(ConformanceErrors* errors) {                        \
 | 
			
		||||
    (ExpectModelOfImpl)(errors, PropertiesOfT<MinProf>::property##_support,    \
 | 
			
		||||
                        PropertiesOfT<MaxProf>::property##_support,            \
 | 
			
		||||
                        property##_support_of<T>());                           \
 | 
			
		||||
  }
 | 
			
		||||
//
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//
 | 
			
		||||
// Generate the necessary support-checking and error reporting functions for
 | 
			
		||||
// each of the comparison operators.
 | 
			
		||||
ABSL_INTERNAL_PESSIMISTIC_MODEL_OF_COMPARISON(EqualityComparable,
 | 
			
		||||
                                              equality_comparable, ==);
 | 
			
		||||
 | 
			
		||||
ABSL_INTERNAL_PESSIMISTIC_MODEL_OF_COMPARISON(InequalityComparable,
 | 
			
		||||
                                              inequality_comparable, !=);
 | 
			
		||||
 | 
			
		||||
ABSL_INTERNAL_PESSIMISTIC_MODEL_OF_COMPARISON(LessThanComparable,
 | 
			
		||||
                                              less_than_comparable, <);
 | 
			
		||||
 | 
			
		||||
ABSL_INTERNAL_PESSIMISTIC_MODEL_OF_COMPARISON(LessEqualComparable,
 | 
			
		||||
                                              less_equal_comparable, <=);
 | 
			
		||||
 | 
			
		||||
ABSL_INTERNAL_PESSIMISTIC_MODEL_OF_COMPARISON(GreaterEqualComparable,
 | 
			
		||||
                                              greater_equal_comparable, >=);
 | 
			
		||||
 | 
			
		||||
ABSL_INTERNAL_PESSIMISTIC_MODEL_OF_COMPARISON(GreaterThanComparable,
 | 
			
		||||
                                              greater_than_comparable, >);
 | 
			
		||||
 | 
			
		||||
#undef ABSL_INTERNAL_PESSIMISTIC_MODEL_OF_COMPARISON
 | 
			
		||||
//
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//
 | 
			
		||||
// The necessary support-checking and error-reporting functions for swap.
 | 
			
		||||
template <class T>
 | 
			
		||||
constexpr swappable swappable_support_of() {
 | 
			
		||||
  return type_traits_internal::IsSwappable<T>::value
 | 
			
		||||
             ? type_traits_internal::IsNothrowSwappable<T>::value
 | 
			
		||||
                   ? swappable::nothrow
 | 
			
		||||
                   : swappable::yes
 | 
			
		||||
             : swappable::maybe;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <class T, class MinProf, class MaxProf>
 | 
			
		||||
void ExpectModelOfSwappable(ConformanceErrors* errors) {
 | 
			
		||||
  (ExpectModelOfImpl)(errors, PropertiesOfT<MinProf>::swappable_support,
 | 
			
		||||
                      PropertiesOfT<MaxProf>::swappable_support,
 | 
			
		||||
                      swappable_support_of<T>());
 | 
			
		||||
}
 | 
			
		||||
//
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//
 | 
			
		||||
// The necessary support-checking and error-reporting functions for std::hash.
 | 
			
		||||
template <class T>
 | 
			
		||||
constexpr hashable hashable_support_of() {
 | 
			
		||||
  return type_traits_internal::IsHashable<T>::value ? hashable::yes
 | 
			
		||||
                                                    : hashable::maybe;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <class T, class MinProf, class MaxProf>
 | 
			
		||||
void ExpectModelOfHashable(ConformanceErrors* errors) {
 | 
			
		||||
  (ExpectModelOfImpl)(errors, PropertiesOfT<MinProf>::hashable_support,
 | 
			
		||||
                      PropertiesOfT<MaxProf>::hashable_support,
 | 
			
		||||
                      hashable_support_of<T>());
 | 
			
		||||
}
 | 
			
		||||
//
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
template <
 | 
			
		||||
    default_constructible DefaultConstructibleValue =
 | 
			
		||||
        default_constructible::maybe,
 | 
			
		||||
| 
						 | 
				
			
			@ -216,6 +653,45 @@ struct ConformanceProfile {
 | 
			
		|||
      HashableValue != hashable::maybe;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//
 | 
			
		||||
// Compliant SFINAE-friendliness is not always present on the standard library
 | 
			
		||||
// implementations that we support. This helper-struct (and associated enum) is
 | 
			
		||||
// used as a means to conditionally check the hashability support of a type.
 | 
			
		||||
enum class CheckHashability { no, yes };
 | 
			
		||||
 | 
			
		||||
template <class T, CheckHashability ShouldCheckHashability>
 | 
			
		||||
struct conservative_hashable_support_of;
 | 
			
		||||
 | 
			
		||||
template <class T>
 | 
			
		||||
struct conservative_hashable_support_of<T, CheckHashability::no> {
 | 
			
		||||
  static constexpr hashable Invoke() { return hashable::maybe; }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template <class T>
 | 
			
		||||
struct conservative_hashable_support_of<T, CheckHashability::yes> {
 | 
			
		||||
  static constexpr hashable Invoke() { return hashable_support_of<T>(); }
 | 
			
		||||
};
 | 
			
		||||
//
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
// The ConformanceProfile that is expected based on introspection into the type
 | 
			
		||||
// by way of trait checks.
 | 
			
		||||
template <class T, CheckHashability ShouldCheckHashability>
 | 
			
		||||
struct SyntacticConformanceProfileOf {
 | 
			
		||||
  using properties = ConformanceProfile<
 | 
			
		||||
      default_constructible_support_of<T>(), move_constructible_support_of<T>(),
 | 
			
		||||
      copy_constructible_support_of<T>(), move_assignable_support_of<T>(),
 | 
			
		||||
      copy_assignable_support_of<T>(), destructible_support_of<T>(),
 | 
			
		||||
      equality_comparable_support_of<T>(),
 | 
			
		||||
      inequality_comparable_support_of<T>(),
 | 
			
		||||
      less_than_comparable_support_of<T>(),
 | 
			
		||||
      less_equal_comparable_support_of<T>(),
 | 
			
		||||
      greater_equal_comparable_support_of<T>(),
 | 
			
		||||
      greater_than_comparable_support_of<T>(), swappable_support_of<T>(),
 | 
			
		||||
      conservative_hashable_support_of<T, ShouldCheckHashability>::Invoke()>;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF_IMPL(type, name)     \
 | 
			
		||||
  template <default_constructible DefaultConstructibleValue,                   \
 | 
			
		||||
            move_constructible MoveConstructibleValue,                         \
 | 
			
		||||
| 
						 | 
				
			
			@ -261,12 +737,80 @@ ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF(hashable);
 | 
			
		|||
#undef ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF
 | 
			
		||||
#undef ABSL_INTERNAL_CONFORMANCE_TESTING_DATA_MEMBER_DEF_IMPL
 | 
			
		||||
 | 
			
		||||
// Converts an enum to its underlying integral value.
 | 
			
		||||
template <class Enum>
 | 
			
		||||
constexpr absl::underlying_type_t<Enum> UnderlyingValue(Enum value) {
 | 
			
		||||
  return static_cast<absl::underlying_type_t<Enum>>(value);
 | 
			
		||||
// Retrieve the enum with the minimum underlying value.
 | 
			
		||||
// Note: std::min is not constexpr in C++11, which is why this is necessary.
 | 
			
		||||
template <class H>
 | 
			
		||||
constexpr H MinEnum(H head) {
 | 
			
		||||
  return head;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <class H, class N, class... T>
 | 
			
		||||
constexpr H MinEnum(H head, N next, T... tail) {
 | 
			
		||||
  return (UnderlyingValue)(head) < (UnderlyingValue)(next)
 | 
			
		||||
             ? (MinEnum)(head, tail...)
 | 
			
		||||
             : (MinEnum)(next, tail...);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <class... Profs>
 | 
			
		||||
struct MinimalProfiles {
 | 
			
		||||
  static constexpr default_constructible
 | 
			
		||||
      default_constructible_support =  // NOLINT
 | 
			
		||||
      (MinEnum)(PropertiesOfT<Profs>::default_constructible_support...);
 | 
			
		||||
 | 
			
		||||
  static constexpr move_constructible move_constructible_support =  // NOLINT
 | 
			
		||||
      (MinEnum)(PropertiesOfT<Profs>::move_constructible_support...);
 | 
			
		||||
 | 
			
		||||
  static constexpr copy_constructible copy_constructible_support =  // NOLINT
 | 
			
		||||
      (MinEnum)(PropertiesOfT<Profs>::copy_constructible_support...);
 | 
			
		||||
 | 
			
		||||
  static constexpr move_assignable move_assignable_support =  // NOLINT
 | 
			
		||||
      (MinEnum)(PropertiesOfT<Profs>::move_assignable_support...);
 | 
			
		||||
 | 
			
		||||
  static constexpr copy_assignable copy_assignable_support =  // NOLINT
 | 
			
		||||
      (MinEnum)(PropertiesOfT<Profs>::copy_assignable_support...);
 | 
			
		||||
 | 
			
		||||
  static constexpr destructible destructible_support =  // NOLINT
 | 
			
		||||
      (MinEnum)(PropertiesOfT<Profs>::destructible_support...);
 | 
			
		||||
 | 
			
		||||
  static constexpr equality_comparable equality_comparable_support =  // NOLINT
 | 
			
		||||
      (MinEnum)(PropertiesOfT<Profs>::equality_comparable_support...);
 | 
			
		||||
 | 
			
		||||
  static constexpr inequality_comparable
 | 
			
		||||
      inequality_comparable_support =  // NOLINT
 | 
			
		||||
      (MinEnum)(PropertiesOfT<Profs>::inequality_comparable_support...);
 | 
			
		||||
 | 
			
		||||
  static constexpr less_than_comparable
 | 
			
		||||
      less_than_comparable_support =  // NOLINT
 | 
			
		||||
      (MinEnum)(PropertiesOfT<Profs>::less_than_comparable_support...);
 | 
			
		||||
 | 
			
		||||
  static constexpr less_equal_comparable
 | 
			
		||||
      less_equal_comparable_support =  // NOLINT
 | 
			
		||||
      (MinEnum)(PropertiesOfT<Profs>::less_equal_comparable_support...);
 | 
			
		||||
 | 
			
		||||
  static constexpr greater_equal_comparable
 | 
			
		||||
      greater_equal_comparable_support =  // NOLINT
 | 
			
		||||
      (MinEnum)(PropertiesOfT<Profs>::greater_equal_comparable_support...);
 | 
			
		||||
 | 
			
		||||
  static constexpr greater_than_comparable
 | 
			
		||||
      greater_than_comparable_support =  // NOLINT
 | 
			
		||||
      (MinEnum)(PropertiesOfT<Profs>::greater_than_comparable_support...);
 | 
			
		||||
 | 
			
		||||
  static constexpr swappable swappable_support =  // NOLINT
 | 
			
		||||
      (MinEnum)(PropertiesOfT<Profs>::swappable_support...);
 | 
			
		||||
 | 
			
		||||
  static constexpr hashable hashable_support =  // NOLINT
 | 
			
		||||
      (MinEnum)(PropertiesOfT<Profs>::hashable_support...);
 | 
			
		||||
 | 
			
		||||
  using properties = ConformanceProfile<
 | 
			
		||||
      default_constructible_support, move_constructible_support,
 | 
			
		||||
      copy_constructible_support, move_assignable_support,
 | 
			
		||||
      copy_assignable_support, destructible_support,
 | 
			
		||||
      equality_comparable_support, inequality_comparable_support,
 | 
			
		||||
      less_than_comparable_support, less_equal_comparable_support,
 | 
			
		||||
      greater_equal_comparable_support, greater_than_comparable_support,
 | 
			
		||||
      swappable_support, hashable_support>;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// Retrieve the enum with the greatest underlying value.
 | 
			
		||||
// Note: std::max is not constexpr in C++11, which is why this is necessary.
 | 
			
		||||
template <class H>
 | 
			
		||||
| 
						 | 
				
			
			@ -369,6 +913,17 @@ struct IsProfileImpl<T, absl::void_t<PropertiesOfT<T>>> : std::true_type {};
 | 
			
		|||
template <class T>
 | 
			
		||||
struct IsProfile : IsProfileImpl<T>::type {};
 | 
			
		||||
 | 
			
		||||
// A tag that describes which set of properties we will check when the user
 | 
			
		||||
// requires a strict match in conformance (as opposed to a loose match which
 | 
			
		||||
// allows more-refined support of any given operation).
 | 
			
		||||
//
 | 
			
		||||
// Currently only the RegularityDomain exists and it includes all operations
 | 
			
		||||
// that the conformance testing suite knows about. The intent is that if the
 | 
			
		||||
// suite is expanded to support extension, such as for checking conformance of
 | 
			
		||||
// concepts like Iterators or Containers, additional corresponding domains can
 | 
			
		||||
// be created.
 | 
			
		||||
struct RegularityDomain {};
 | 
			
		||||
 | 
			
		||||
}  // namespace types_internal
 | 
			
		||||
ABSL_NAMESPACE_END
 | 
			
		||||
}  // namespace absl
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										1386
									
								
								absl/types/internal/conformance_testing.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1386
									
								
								absl/types/internal/conformance_testing.h
									
										
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										391
									
								
								absl/types/internal/conformance_testing_helpers.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										391
									
								
								absl/types/internal/conformance_testing_helpers.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,391 @@
 | 
			
		|||
// Copyright 2019 The Abseil Authors.
 | 
			
		||||
//
 | 
			
		||||
// Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
// you may not use this file except in compliance with the License.
 | 
			
		||||
// You may obtain a copy of the License at
 | 
			
		||||
//
 | 
			
		||||
//      https://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
//
 | 
			
		||||
// Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
// distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
// See the License for the specific language governing permissions and
 | 
			
		||||
// limitations under the License.
 | 
			
		||||
 | 
			
		||||
#ifndef ABSL_TYPES_INTERNAL_CONFORMANCE_TESTING_HELPERS_H_
 | 
			
		||||
#define ABSL_TYPES_INTERNAL_CONFORMANCE_TESTING_HELPERS_H_
 | 
			
		||||
 | 
			
		||||
// Checks to determine whether or not we can use abi::__cxa_demangle
 | 
			
		||||
#if (defined(__ANDROID__) || defined(ANDROID)) && !defined(OS_ANDROID)
 | 
			
		||||
#define ABSL_INTERNAL_OS_ANDROID
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
// We support certain compilers only.  See demangle.h for details.
 | 
			
		||||
#if defined(OS_ANDROID) && (defined(__i386__) || defined(__x86_64__))
 | 
			
		||||
#define ABSL_TYPES_INTERNAL_HAS_CXA_DEMANGLE 0
 | 
			
		||||
#elif (__GNUC__ >= 4 || (__GNUC__ >= 3 && __GNUC_MINOR__ >= 4)) && \
 | 
			
		||||
    !defined(__mips__)
 | 
			
		||||
#define ABSL_TYPES_INTERNAL_HAS_CXA_DEMANGLE 1
 | 
			
		||||
#elif defined(__clang__) && !defined(_MSC_VER)
 | 
			
		||||
#define ABSL_TYPES_INTERNAL_HAS_CXA_DEMANGLE 1
 | 
			
		||||
#else
 | 
			
		||||
#define ABSL_TYPES_INTERNAL_HAS_CXA_DEMANGLE 0
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include <tuple>
 | 
			
		||||
#include <type_traits>
 | 
			
		||||
#include <utility>
 | 
			
		||||
 | 
			
		||||
#include "absl/meta/type_traits.h"
 | 
			
		||||
#include "absl/strings/string_view.h"
 | 
			
		||||
#include "absl/utility/utility.h"
 | 
			
		||||
 | 
			
		||||
#if ABSL_TYPES_INTERNAL_HAS_CXA_DEMANGLE
 | 
			
		||||
#include <cxxabi.h>
 | 
			
		||||
 | 
			
		||||
#include <cstdlib>
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
namespace absl {
 | 
			
		||||
ABSL_NAMESPACE_BEGIN
 | 
			
		||||
namespace types_internal {
 | 
			
		||||
 | 
			
		||||
// Return a readable name for type T.
 | 
			
		||||
template <class T>
 | 
			
		||||
absl::string_view NameOfImpl() {
 | 
			
		||||
// TODO(calabrese) Investigate using debugging:internal_demangle as a fallback.
 | 
			
		||||
#if ABSL_TYPES_INTERNAL_HAS_CXA_DEMANGLE
 | 
			
		||||
  int status = 0;
 | 
			
		||||
  char* demangled_name = nullptr;
 | 
			
		||||
 | 
			
		||||
  demangled_name =
 | 
			
		||||
      abi::__cxa_demangle(typeid(T).name(), nullptr, nullptr, &status);
 | 
			
		||||
 | 
			
		||||
  if (status == 0 && demangled_name != nullptr) {
 | 
			
		||||
    return demangled_name;
 | 
			
		||||
  } else {
 | 
			
		||||
    return typeid(T).name();
 | 
			
		||||
  }
 | 
			
		||||
#else
 | 
			
		||||
  return typeid(T).name();
 | 
			
		||||
#endif
 | 
			
		||||
  // NOTE: We intentionally leak demangled_name so that it remains valid
 | 
			
		||||
  // throughout the remainder of the program.
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Given a type, returns as nice of a type name as we can produce (demangled).
 | 
			
		||||
//
 | 
			
		||||
// Note: This currently strips cv-qualifiers and references, but that is okay
 | 
			
		||||
// because we only use this internally with unqualified object types.
 | 
			
		||||
template <class T>
 | 
			
		||||
std::string NameOf() {
 | 
			
		||||
  static const absl::string_view result = NameOfImpl<T>();
 | 
			
		||||
  return std::string(result);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//
 | 
			
		||||
// Metafunction to check if a type is callable with no explicit arguments
 | 
			
		||||
template <class Fun, class /*Enabler*/ = void>
 | 
			
		||||
struct IsNullaryCallableImpl : std::false_type {};
 | 
			
		||||
 | 
			
		||||
template <class Fun>
 | 
			
		||||
struct IsNullaryCallableImpl<
 | 
			
		||||
    Fun, absl::void_t<decltype(std::declval<const Fun&>()())>>
 | 
			
		||||
    : std::true_type {
 | 
			
		||||
  using result_type = decltype(std::declval<const Fun&>()());
 | 
			
		||||
 | 
			
		||||
  template <class ValueType>
 | 
			
		||||
  using for_type = std::is_same<ValueType, result_type>;
 | 
			
		||||
 | 
			
		||||
  using void_if_true = void;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template <class Fun>
 | 
			
		||||
struct IsNullaryCallable : IsNullaryCallableImpl<Fun> {};
 | 
			
		||||
//
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
// A type that contains a function object that returns an instance of a type
 | 
			
		||||
// that is undergoing conformance testing. This function is required to always
 | 
			
		||||
// return the same value upon invocation.
 | 
			
		||||
template <class Fun>
 | 
			
		||||
struct GeneratorType;
 | 
			
		||||
 | 
			
		||||
// A type that contains a tuple of GeneratorType<Fun> where each Fun has the
 | 
			
		||||
// same return type. The result of each of the different generators should all
 | 
			
		||||
// be equal values, though the underlying object representation may differ (such
 | 
			
		||||
// as if one returns 0.0 and another return -0.0, or if one returns an empty
 | 
			
		||||
// vector and another returns an empty vector with a different capacity.
 | 
			
		||||
template <class... Funs>
 | 
			
		||||
struct EquivalenceClassType;
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//
 | 
			
		||||
// A metafunction to check if a type is a specialization of EquivalenceClassType
 | 
			
		||||
template <class T>
 | 
			
		||||
struct IsEquivalenceClass : std::false_type {};
 | 
			
		||||
 | 
			
		||||
template <>
 | 
			
		||||
struct IsEquivalenceClass<EquivalenceClassType<>> : std::true_type {
 | 
			
		||||
  using self = IsEquivalenceClass;
 | 
			
		||||
 | 
			
		||||
  // A metafunction to check if this EquivalenceClassType is a valid
 | 
			
		||||
  // EquivalenceClassType for a type `ValueType` that is undergoing testing
 | 
			
		||||
  template <class ValueType>
 | 
			
		||||
  using for_type = std::true_type;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template <class Head, class... Tail>
 | 
			
		||||
struct IsEquivalenceClass<EquivalenceClassType<Head, Tail...>>
 | 
			
		||||
    : std::true_type {
 | 
			
		||||
  using self = IsEquivalenceClass;
 | 
			
		||||
 | 
			
		||||
  // The type undergoing conformance testing that this EquivalenceClass
 | 
			
		||||
  // corresponds to
 | 
			
		||||
  using result_type = typename IsNullaryCallable<Head>::result_type;
 | 
			
		||||
 | 
			
		||||
  // A metafunction to check if this EquivalenceClassType is a valid
 | 
			
		||||
  // EquivalenceClassType for a type `ValueType` that is undergoing testing
 | 
			
		||||
  template <class ValueType>
 | 
			
		||||
  using for_type = std::is_same<ValueType, result_type>;
 | 
			
		||||
};
 | 
			
		||||
//
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
// A type that contains an ordered series of EquivalenceClassTypes, where the
 | 
			
		||||
// the function object of each underlying GeneratorType has the same return type
 | 
			
		||||
//
 | 
			
		||||
// These equivalence classes are required to be in a logical ascending order
 | 
			
		||||
// that is consistent with comparison operators that are defined for the return
 | 
			
		||||
// type of each GeneratorType, if any.
 | 
			
		||||
template <class... EqClasses>
 | 
			
		||||
struct OrderedEquivalenceClasses;
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//
 | 
			
		||||
// A metafunction to determine the return type of the function object contained
 | 
			
		||||
// in a GeneratorType specialization.
 | 
			
		||||
template <class T>
 | 
			
		||||
struct ResultOfGenerator {};
 | 
			
		||||
 | 
			
		||||
template <class Fun>
 | 
			
		||||
struct ResultOfGenerator<GeneratorType<Fun>> {
 | 
			
		||||
  using type = decltype(std::declval<const Fun&>()());
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template <class Fun>
 | 
			
		||||
using ResultOfGeneratorT = typename ResultOfGenerator<GeneratorType<Fun>>::type;
 | 
			
		||||
//
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//
 | 
			
		||||
// A metafunction that yields true iff each of Funs is a GeneratorType
 | 
			
		||||
// specialization and they all contain functions with the same return type
 | 
			
		||||
template <class /*Enabler*/, class... Funs>
 | 
			
		||||
struct AreGeneratorsWithTheSameReturnTypeImpl : std::false_type {};
 | 
			
		||||
 | 
			
		||||
template <>
 | 
			
		||||
struct AreGeneratorsWithTheSameReturnTypeImpl<void> : std::true_type {};
 | 
			
		||||
 | 
			
		||||
template <class Head, class... Tail>
 | 
			
		||||
struct AreGeneratorsWithTheSameReturnTypeImpl<
 | 
			
		||||
    typename std::enable_if<absl::conjunction<std::is_same<
 | 
			
		||||
        ResultOfGeneratorT<Head>, ResultOfGeneratorT<Tail>>...>::value>::type,
 | 
			
		||||
    Head, Tail...> : std::true_type {};
 | 
			
		||||
 | 
			
		||||
template <class... Funs>
 | 
			
		||||
struct AreGeneratorsWithTheSameReturnType
 | 
			
		||||
    : AreGeneratorsWithTheSameReturnTypeImpl<void, Funs...>::type {};
 | 
			
		||||
//
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//
 | 
			
		||||
// A metafunction that yields true iff each of Funs is an EquivalenceClassType
 | 
			
		||||
// specialization and they all contain GeneratorType specializations that have
 | 
			
		||||
// the same return type
 | 
			
		||||
template <class... EqClasses>
 | 
			
		||||
struct AreEquivalenceClassesOfTheSameType {
 | 
			
		||||
  static_assert(sizeof...(EqClasses) != sizeof...(EqClasses), "");
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template <>
 | 
			
		||||
struct AreEquivalenceClassesOfTheSameType<> : std::true_type {
 | 
			
		||||
  using self = AreEquivalenceClassesOfTheSameType;
 | 
			
		||||
 | 
			
		||||
  // Metafunction to check that a type is the same as all of the equivalence
 | 
			
		||||
  // classes, if any.
 | 
			
		||||
  // Note: In this specialization there are no equivalence classes, so the
 | 
			
		||||
  // value type is always compatible.
 | 
			
		||||
  template <class /*ValueType*/>
 | 
			
		||||
  using for_type = std::true_type;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template <class... Funs>
 | 
			
		||||
struct AreEquivalenceClassesOfTheSameType<EquivalenceClassType<Funs...>>
 | 
			
		||||
    : std::true_type {
 | 
			
		||||
  using self = AreEquivalenceClassesOfTheSameType;
 | 
			
		||||
 | 
			
		||||
  // Metafunction to check that a type is the same as all of the equivalence
 | 
			
		||||
  // classes, if any.
 | 
			
		||||
  template <class ValueType>
 | 
			
		||||
  using for_type = typename IsEquivalenceClass<
 | 
			
		||||
      EquivalenceClassType<Funs...>>::template for_type<ValueType>;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template <class... TailEqClasses>
 | 
			
		||||
struct AreEquivalenceClassesOfTheSameType<
 | 
			
		||||
    EquivalenceClassType<>, EquivalenceClassType<>, TailEqClasses...>
 | 
			
		||||
    : AreEquivalenceClassesOfTheSameType<TailEqClasses...>::self {};
 | 
			
		||||
 | 
			
		||||
template <class HeadNextFun, class... TailNextFuns, class... TailEqClasses>
 | 
			
		||||
struct AreEquivalenceClassesOfTheSameType<
 | 
			
		||||
    EquivalenceClassType<>, EquivalenceClassType<HeadNextFun, TailNextFuns...>,
 | 
			
		||||
    TailEqClasses...>
 | 
			
		||||
    : AreEquivalenceClassesOfTheSameType<
 | 
			
		||||
          EquivalenceClassType<HeadNextFun, TailNextFuns...>,
 | 
			
		||||
          TailEqClasses...>::self {};
 | 
			
		||||
 | 
			
		||||
template <class HeadHeadFun, class... TailHeadFuns, class... TailEqClasses>
 | 
			
		||||
struct AreEquivalenceClassesOfTheSameType<
 | 
			
		||||
    EquivalenceClassType<HeadHeadFun, TailHeadFuns...>, EquivalenceClassType<>,
 | 
			
		||||
    TailEqClasses...>
 | 
			
		||||
    : AreEquivalenceClassesOfTheSameType<
 | 
			
		||||
          EquivalenceClassType<HeadHeadFun, TailHeadFuns...>,
 | 
			
		||||
          TailEqClasses...>::self {};
 | 
			
		||||
 | 
			
		||||
template <class HeadHeadFun, class... TailHeadFuns, class HeadNextFun,
 | 
			
		||||
          class... TailNextFuns, class... TailEqClasses>
 | 
			
		||||
struct AreEquivalenceClassesOfTheSameType<
 | 
			
		||||
    EquivalenceClassType<HeadHeadFun, TailHeadFuns...>,
 | 
			
		||||
    EquivalenceClassType<HeadNextFun, TailNextFuns...>, TailEqClasses...>
 | 
			
		||||
    : absl::conditional_t<
 | 
			
		||||
          IsNullaryCallable<HeadNextFun>::template for_type<
 | 
			
		||||
              typename IsNullaryCallable<HeadHeadFun>::result_type>::value,
 | 
			
		||||
          AreEquivalenceClassesOfTheSameType<
 | 
			
		||||
              EquivalenceClassType<HeadHeadFun, TailHeadFuns...>,
 | 
			
		||||
              TailEqClasses...>,
 | 
			
		||||
          std::false_type> {};
 | 
			
		||||
//
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
// Execute a function for each passed-in parameter.
 | 
			
		||||
template <class Fun, class... Cases>
 | 
			
		||||
void ForEachParameter(const Fun& fun, const Cases&... cases) {
 | 
			
		||||
  const std::initializer_list<bool> results = {
 | 
			
		||||
      (static_cast<void>(fun(cases)), true)...};
 | 
			
		||||
 | 
			
		||||
  (void)results;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Execute a function on each passed-in parameter (using a bound function).
 | 
			
		||||
template <class Fun>
 | 
			
		||||
struct ForEachParameterFun {
 | 
			
		||||
  template <class... T>
 | 
			
		||||
  void operator()(const T&... cases) const {
 | 
			
		||||
    (ForEachParameter)(fun, cases...);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  Fun fun;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// Execute a function on each element of a tuple.
 | 
			
		||||
template <class Fun, class Tup>
 | 
			
		||||
void ForEachTupleElement(const Fun& fun, const Tup& tup) {
 | 
			
		||||
  absl::apply(ForEachParameterFun<Fun>{fun}, tup);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//
 | 
			
		||||
// Execute a function for each combination of two elements of a tuple, including
 | 
			
		||||
// combinations of an element with itself.
 | 
			
		||||
template <class Fun, class... T>
 | 
			
		||||
struct ForEveryTwoImpl {
 | 
			
		||||
  template <class Lhs>
 | 
			
		||||
  struct WithBoundLhs {
 | 
			
		||||
    template <class Rhs>
 | 
			
		||||
    void operator()(const Rhs& rhs) const {
 | 
			
		||||
      fun(lhs, rhs);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Fun fun;
 | 
			
		||||
    Lhs lhs;
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  template <class Lhs>
 | 
			
		||||
  void operator()(const Lhs& lhs) const {
 | 
			
		||||
    (ForEachTupleElement)(WithBoundLhs<Lhs>{fun, lhs}, args);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  Fun fun;
 | 
			
		||||
  std::tuple<T...> args;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template <class Fun, class... T>
 | 
			
		||||
void ForEveryTwo(const Fun& fun, std::tuple<T...> args) {
 | 
			
		||||
  (ForEachTupleElement)(ForEveryTwoImpl<Fun, T...>{fun, args}, args);
 | 
			
		||||
}
 | 
			
		||||
//
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
//
 | 
			
		||||
// Insert all values into an associative container
 | 
			
		||||
template<class Container>
 | 
			
		||||
void InsertEach(Container* cont) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template<class Container, class H, class... T>
 | 
			
		||||
void InsertEach(Container* cont, H&& head, T&&... tail) {
 | 
			
		||||
  cont->insert(head);
 | 
			
		||||
  (InsertEach)(cont, tail...);
 | 
			
		||||
}
 | 
			
		||||
//
 | 
			
		||||
////////////////////////////////////////////////////////////////////////////////
 | 
			
		||||
// A template with a nested "Invoke" static-member-function that executes a
 | 
			
		||||
// passed-in Callable when `Condition` is true, otherwise it ignores the
 | 
			
		||||
// Callable. This is useful for executing a function object with a condition
 | 
			
		||||
// that corresponds to whether or not the Callable can be safely instantiated.
 | 
			
		||||
// It has some overlapping uses with C++17 `if constexpr`.
 | 
			
		||||
template <bool Condition>
 | 
			
		||||
struct If;
 | 
			
		||||
 | 
			
		||||
template <>
 | 
			
		||||
struct If</*Condition =*/false> {
 | 
			
		||||
  template <class Fun, class... P>
 | 
			
		||||
  static void Invoke(const Fun& /*fun*/, P&&... /*args*/) {}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
template <>
 | 
			
		||||
struct If</*Condition =*/true> {
 | 
			
		||||
  template <class Fun, class... P>
 | 
			
		||||
  static void Invoke(const Fun& fun, P&&... args) {
 | 
			
		||||
    // TODO(calabrese) Use std::invoke equivalent instead of function-call.
 | 
			
		||||
    fun(absl::forward<P>(args)...);
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
// ABSL_INTERNAL_STRINGIZE(...)
 | 
			
		||||
//
 | 
			
		||||
// This variadic macro transforms its arguments into a c-string literal after
 | 
			
		||||
// expansion.
 | 
			
		||||
//
 | 
			
		||||
// Example:
 | 
			
		||||
//
 | 
			
		||||
//   ABSL_INTERNAL_STRINGIZE(std::array<int, 10>)
 | 
			
		||||
//
 | 
			
		||||
// Results in:
 | 
			
		||||
//
 | 
			
		||||
//   "std::array<int, 10>"
 | 
			
		||||
#define ABSL_INTERNAL_STRINGIZE(...) ABSL_INTERNAL_STRINGIZE_IMPL((__VA_ARGS__))
 | 
			
		||||
#define ABSL_INTERNAL_STRINGIZE_IMPL(arg) ABSL_INTERNAL_STRINGIZE_IMPL2 arg
 | 
			
		||||
#define ABSL_INTERNAL_STRINGIZE_IMPL2(...) #__VA_ARGS__
 | 
			
		||||
 | 
			
		||||
}  // namespace types_internal
 | 
			
		||||
ABSL_NAMESPACE_END
 | 
			
		||||
}  // namespace absl
 | 
			
		||||
 | 
			
		||||
#endif  // ABSL_TYPES_INTERNAL_CONFORMANCE_TESTING_HELPERS_H_
 | 
			
		||||
| 
						 | 
				
			
			@ -12,6 +12,8 @@
 | 
			
		|||
// See the License for the specific language governing permissions and
 | 
			
		||||
// limitations under the License.
 | 
			
		||||
 | 
			
		||||
#include "absl/types/internal/conformance_testing.h"
 | 
			
		||||
 | 
			
		||||
#include <new>
 | 
			
		||||
#include <type_traits>
 | 
			
		||||
#include <utility>
 | 
			
		||||
| 
						 | 
				
			
			@ -19,6 +21,7 @@
 | 
			
		|||
#include "gtest/gtest.h"
 | 
			
		||||
#include "absl/meta/type_traits.h"
 | 
			
		||||
#include "absl/types/internal/conformance_aliases.h"
 | 
			
		||||
#include "absl/types/internal/conformance_profile.h"
 | 
			
		||||
 | 
			
		||||
namespace {
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1181,6 +1184,373 @@ INSTANTIATE_TYPED_TEST_SUITE_P(CommonComparable, ProfileTest,
 | 
			
		|||
                               CommonComparableProfilesToTest);
 | 
			
		||||
INSTANTIATE_TYPED_TEST_SUITE_P(Trivial, ProfileTest, TrivialProfilesToTest);
 | 
			
		||||
 | 
			
		||||
// TODO(calabrese) Test runtime results
 | 
			
		||||
TEST(ConformanceTestingTest, Basic) {
 | 
			
		||||
  using profile = ti::CombineProfiles<ti::TriviallyCompleteProfile,
 | 
			
		||||
                                      ti::NothrowComparableProfile>;
 | 
			
		||||
 | 
			
		||||
  using lim = std::numeric_limits<float>;
 | 
			
		||||
 | 
			
		||||
  ABSL_INTERNAL_ASSERT_CONFORMANCE_OF(float)
 | 
			
		||||
      .INITIALIZER(-lim::infinity())
 | 
			
		||||
      .INITIALIZER(lim::lowest())
 | 
			
		||||
      .INITIALIZER(-1.f)
 | 
			
		||||
      .INITIALIZER(-lim::min())
 | 
			
		||||
      .EQUIVALENCE_CLASS(INITIALIZER(-0.f), INITIALIZER(0.f))
 | 
			
		||||
      .INITIALIZER(lim::min())
 | 
			
		||||
      .INITIALIZER(1.f)
 | 
			
		||||
      .INITIALIZER(lim::max())
 | 
			
		||||
      .INITIALIZER(lim::infinity())
 | 
			
		||||
      .WITH_STRICT_PROFILE(absl::types_internal::RegularityDomain, profile);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct BadMoveConstruct {
 | 
			
		||||
  BadMoveConstruct() = default;
 | 
			
		||||
  BadMoveConstruct(BadMoveConstruct&& other) noexcept
 | 
			
		||||
      : value(other.value + 1) {}
 | 
			
		||||
  BadMoveConstruct& operator=(BadMoveConstruct&& other) noexcept = default;
 | 
			
		||||
  int value = 0;
 | 
			
		||||
 | 
			
		||||
  friend bool operator==(BadMoveConstruct const& lhs,
 | 
			
		||||
                         BadMoveConstruct const& rhs) {
 | 
			
		||||
    return lhs.value == rhs.value;
 | 
			
		||||
  }
 | 
			
		||||
  friend bool operator!=(BadMoveConstruct const& lhs,
 | 
			
		||||
                         BadMoveConstruct const& rhs) {
 | 
			
		||||
    return lhs.value != rhs.value;
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct BadMoveAssign {
 | 
			
		||||
  BadMoveAssign() = default;
 | 
			
		||||
  BadMoveAssign(BadMoveAssign&& other) noexcept = default;
 | 
			
		||||
  BadMoveAssign& operator=(BadMoveAssign&& other) noexcept {
 | 
			
		||||
    int new_value = other.value + 1;
 | 
			
		||||
    value = new_value;
 | 
			
		||||
    return *this;
 | 
			
		||||
  }
 | 
			
		||||
  int value = 0;
 | 
			
		||||
 | 
			
		||||
  friend bool operator==(BadMoveAssign const& lhs, BadMoveAssign const& rhs) {
 | 
			
		||||
    return lhs.value == rhs.value;
 | 
			
		||||
  }
 | 
			
		||||
  friend bool operator!=(BadMoveAssign const& lhs, BadMoveAssign const& rhs) {
 | 
			
		||||
    return lhs.value != rhs.value;
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
enum class WhichCompIsBad { eq, ne, lt, le, ge, gt };
 | 
			
		||||
 | 
			
		||||
template <WhichCompIsBad Which>
 | 
			
		||||
struct BadCompare {
 | 
			
		||||
  int value;
 | 
			
		||||
 | 
			
		||||
  friend bool operator==(BadCompare const& lhs, BadCompare const& rhs) {
 | 
			
		||||
    return Which == WhichCompIsBad::eq ? lhs.value != rhs.value
 | 
			
		||||
                                       : lhs.value == rhs.value;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  friend bool operator!=(BadCompare const& lhs, BadCompare const& rhs) {
 | 
			
		||||
    return Which == WhichCompIsBad::ne ? lhs.value == rhs.value
 | 
			
		||||
                                       : lhs.value != rhs.value;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  friend bool operator<(BadCompare const& lhs, BadCompare const& rhs) {
 | 
			
		||||
    return Which == WhichCompIsBad::lt ? lhs.value >= rhs.value
 | 
			
		||||
                                       : lhs.value < rhs.value;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  friend bool operator<=(BadCompare const& lhs, BadCompare const& rhs) {
 | 
			
		||||
    return Which == WhichCompIsBad::le ? lhs.value > rhs.value
 | 
			
		||||
                                       : lhs.value <= rhs.value;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  friend bool operator>=(BadCompare const& lhs, BadCompare const& rhs) {
 | 
			
		||||
    return Which == WhichCompIsBad::ge ? lhs.value < rhs.value
 | 
			
		||||
                                       : lhs.value >= rhs.value;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  friend bool operator>(BadCompare const& lhs, BadCompare const& rhs) {
 | 
			
		||||
    return Which == WhichCompIsBad::gt ? lhs.value <= rhs.value
 | 
			
		||||
                                       : lhs.value > rhs.value;
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
TEST(ConformanceTestingDeathTest, Failures) {
 | 
			
		||||
  {
 | 
			
		||||
    using profile = ti::CombineProfiles<ti::TriviallyCompleteProfile,
 | 
			
		||||
                                        ti::NothrowComparableProfile>;
 | 
			
		||||
 | 
			
		||||
    // Note: The initializers are intentionally in the wrong order.
 | 
			
		||||
    ABSL_INTERNAL_ASSERT_NONCONFORMANCE_OF(float)
 | 
			
		||||
        .INITIALIZER(1.f)
 | 
			
		||||
        .INITIALIZER(0.f)
 | 
			
		||||
        .WITH_LOOSE_PROFILE(profile);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  {
 | 
			
		||||
    using profile =
 | 
			
		||||
        ti::CombineProfiles<ti::NothrowMovableProfile, ti::EquatableProfile>;
 | 
			
		||||
 | 
			
		||||
    ABSL_INTERNAL_ASSERT_NONCONFORMANCE_OF(BadMoveConstruct)
 | 
			
		||||
        .DUE_TO("Move construction")
 | 
			
		||||
        .INITIALIZER(BadMoveConstruct())
 | 
			
		||||
        .WITH_LOOSE_PROFILE(profile);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  {
 | 
			
		||||
    using profile =
 | 
			
		||||
        ti::CombineProfiles<ti::NothrowMovableProfile, ti::EquatableProfile>;
 | 
			
		||||
 | 
			
		||||
    ABSL_INTERNAL_ASSERT_NONCONFORMANCE_OF(BadMoveAssign)
 | 
			
		||||
        .DUE_TO("Move assignment")
 | 
			
		||||
        .INITIALIZER(BadMoveAssign())
 | 
			
		||||
        .WITH_LOOSE_PROFILE(profile);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST(ConformanceTestingDeathTest, CompFailures) {
 | 
			
		||||
  using profile = ti::ComparableProfile;
 | 
			
		||||
 | 
			
		||||
  {
 | 
			
		||||
    using BadComp = BadCompare<WhichCompIsBad::eq>;
 | 
			
		||||
 | 
			
		||||
    ABSL_INTERNAL_ASSERT_NONCONFORMANCE_OF(BadComp)
 | 
			
		||||
        .DUE_TO("Comparison")
 | 
			
		||||
        .INITIALIZER(BadComp{0})
 | 
			
		||||
        .INITIALIZER(BadComp{1})
 | 
			
		||||
        .WITH_LOOSE_PROFILE(profile);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  {
 | 
			
		||||
    using BadComp = BadCompare<WhichCompIsBad::ne>;
 | 
			
		||||
 | 
			
		||||
    ABSL_INTERNAL_ASSERT_NONCONFORMANCE_OF(BadComp)
 | 
			
		||||
        .DUE_TO("Comparison")
 | 
			
		||||
        .INITIALIZER(BadComp{0})
 | 
			
		||||
        .INITIALIZER(BadComp{1})
 | 
			
		||||
        .WITH_LOOSE_PROFILE(profile);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  {
 | 
			
		||||
    using BadComp = BadCompare<WhichCompIsBad::lt>;
 | 
			
		||||
 | 
			
		||||
    ABSL_INTERNAL_ASSERT_NONCONFORMANCE_OF(BadComp)
 | 
			
		||||
        .DUE_TO("Comparison")
 | 
			
		||||
        .INITIALIZER(BadComp{0})
 | 
			
		||||
        .INITIALIZER(BadComp{1})
 | 
			
		||||
        .WITH_LOOSE_PROFILE(profile);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  {
 | 
			
		||||
    using BadComp = BadCompare<WhichCompIsBad::le>;
 | 
			
		||||
 | 
			
		||||
    ABSL_INTERNAL_ASSERT_NONCONFORMANCE_OF(BadComp)
 | 
			
		||||
        .DUE_TO("Comparison")
 | 
			
		||||
        .INITIALIZER(BadComp{0})
 | 
			
		||||
        .INITIALIZER(BadComp{1})
 | 
			
		||||
        .WITH_LOOSE_PROFILE(profile);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  {
 | 
			
		||||
    using BadComp = BadCompare<WhichCompIsBad::ge>;
 | 
			
		||||
 | 
			
		||||
    ABSL_INTERNAL_ASSERT_NONCONFORMANCE_OF(BadComp)
 | 
			
		||||
        .DUE_TO("Comparison")
 | 
			
		||||
        .INITIALIZER(BadComp{0})
 | 
			
		||||
        .INITIALIZER(BadComp{1})
 | 
			
		||||
        .WITH_LOOSE_PROFILE(profile);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  {
 | 
			
		||||
    using BadComp = BadCompare<WhichCompIsBad::gt>;
 | 
			
		||||
 | 
			
		||||
    ABSL_INTERNAL_ASSERT_NONCONFORMANCE_OF(BadComp)
 | 
			
		||||
        .DUE_TO("Comparison")
 | 
			
		||||
        .INITIALIZER(BadComp{0})
 | 
			
		||||
        .INITIALIZER(BadComp{1})
 | 
			
		||||
        .WITH_LOOSE_PROFILE(profile);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct BadSelfMove {
 | 
			
		||||
  BadSelfMove() = default;
 | 
			
		||||
  BadSelfMove(BadSelfMove&&) = default;
 | 
			
		||||
  BadSelfMove& operator=(BadSelfMove&& other) noexcept {
 | 
			
		||||
    if (this == &other) {
 | 
			
		||||
      broken_state = true;
 | 
			
		||||
    }
 | 
			
		||||
    return *this;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  friend bool operator==(const BadSelfMove& lhs, const BadSelfMove& rhs) {
 | 
			
		||||
    return !(lhs.broken_state || rhs.broken_state);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  friend bool operator!=(const BadSelfMove& lhs, const BadSelfMove& rhs) {
 | 
			
		||||
    return lhs.broken_state || rhs.broken_state;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  bool broken_state = false;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
TEST(ConformanceTestingDeathTest, SelfMoveFailure) {
 | 
			
		||||
  using profile = ti::EquatableNothrowMovableProfile;
 | 
			
		||||
 | 
			
		||||
  {
 | 
			
		||||
    ABSL_INTERNAL_ASSERT_NONCONFORMANCE_OF(BadSelfMove)
 | 
			
		||||
        .DUE_TO("Move assignment")
 | 
			
		||||
        .INITIALIZER(BadSelfMove())
 | 
			
		||||
        .WITH_LOOSE_PROFILE(profile);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct BadSelfCopy {
 | 
			
		||||
  BadSelfCopy() = default;
 | 
			
		||||
  BadSelfCopy(BadSelfCopy&&) = default;
 | 
			
		||||
  BadSelfCopy(const BadSelfCopy&) = default;
 | 
			
		||||
  BadSelfCopy& operator=(BadSelfCopy&&) = default;
 | 
			
		||||
  BadSelfCopy& operator=(BadSelfCopy const& other) {
 | 
			
		||||
    if (this == &other) {
 | 
			
		||||
      broken_state = true;
 | 
			
		||||
    }
 | 
			
		||||
    return *this;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  friend bool operator==(const BadSelfCopy& lhs, const BadSelfCopy& rhs) {
 | 
			
		||||
    return !(lhs.broken_state || rhs.broken_state);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  friend bool operator!=(const BadSelfCopy& lhs, const BadSelfCopy& rhs) {
 | 
			
		||||
    return lhs.broken_state || rhs.broken_state;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  bool broken_state = false;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
TEST(ConformanceTestingDeathTest, SelfCopyFailure) {
 | 
			
		||||
  using profile = ti::EquatableValueProfile;
 | 
			
		||||
 | 
			
		||||
  {
 | 
			
		||||
    ABSL_INTERNAL_ASSERT_NONCONFORMANCE_OF(BadSelfCopy)
 | 
			
		||||
        .DUE_TO("Copy assignment")
 | 
			
		||||
        .INITIALIZER(BadSelfCopy())
 | 
			
		||||
        .WITH_LOOSE_PROFILE(profile);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct BadSelfSwap {
 | 
			
		||||
  friend void swap(BadSelfSwap& lhs, BadSelfSwap& rhs) noexcept {
 | 
			
		||||
    if (&lhs == &rhs) lhs.broken_state = true;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  friend bool operator==(const BadSelfSwap& lhs, const BadSelfSwap& rhs) {
 | 
			
		||||
    return !(lhs.broken_state || rhs.broken_state);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  friend bool operator!=(const BadSelfSwap& lhs, const BadSelfSwap& rhs) {
 | 
			
		||||
    return lhs.broken_state || rhs.broken_state;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  bool broken_state = false;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
TEST(ConformanceTestingDeathTest, SelfSwapFailure) {
 | 
			
		||||
  using profile = ti::EquatableNothrowMovableProfile;
 | 
			
		||||
 | 
			
		||||
  {
 | 
			
		||||
    ABSL_INTERNAL_ASSERT_NONCONFORMANCE_OF(BadSelfSwap)
 | 
			
		||||
        .DUE_TO("Swap")
 | 
			
		||||
        .INITIALIZER(BadSelfSwap())
 | 
			
		||||
        .WITH_LOOSE_PROFILE(profile);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct BadDefaultInitializedMoveAssign {
 | 
			
		||||
  BadDefaultInitializedMoveAssign() : default_initialized(true) {}
 | 
			
		||||
  explicit BadDefaultInitializedMoveAssign(int v) : value(v) {}
 | 
			
		||||
  BadDefaultInitializedMoveAssign(
 | 
			
		||||
      BadDefaultInitializedMoveAssign&& other) noexcept
 | 
			
		||||
      : value(other.value) {}
 | 
			
		||||
  BadDefaultInitializedMoveAssign& operator=(
 | 
			
		||||
      BadDefaultInitializedMoveAssign&& other) noexcept {
 | 
			
		||||
    value = other.value;
 | 
			
		||||
    if (default_initialized) ++value;  // Bad move if lhs is default initialized
 | 
			
		||||
    return *this;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  friend bool operator==(const BadDefaultInitializedMoveAssign& lhs,
 | 
			
		||||
                         const BadDefaultInitializedMoveAssign& rhs) {
 | 
			
		||||
    return lhs.value == rhs.value;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  friend bool operator!=(const BadDefaultInitializedMoveAssign& lhs,
 | 
			
		||||
                         const BadDefaultInitializedMoveAssign& rhs) {
 | 
			
		||||
    return lhs.value != rhs.value;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  bool default_initialized = false;
 | 
			
		||||
  int value = 0;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
TEST(ConformanceTestingDeathTest, DefaultInitializedMoveAssignFailure) {
 | 
			
		||||
  using profile =
 | 
			
		||||
      ti::CombineProfiles<ti::DefaultConstructibleNothrowMovableProfile,
 | 
			
		||||
                          ti::EquatableProfile>;
 | 
			
		||||
 | 
			
		||||
  {
 | 
			
		||||
    ABSL_INTERNAL_ASSERT_NONCONFORMANCE_OF(BadDefaultInitializedMoveAssign)
 | 
			
		||||
        .DUE_TO("move assignment")
 | 
			
		||||
        .INITIALIZER(BadDefaultInitializedMoveAssign(0))
 | 
			
		||||
        .WITH_LOOSE_PROFILE(profile);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct BadDefaultInitializedCopyAssign {
 | 
			
		||||
  BadDefaultInitializedCopyAssign() : default_initialized(true) {}
 | 
			
		||||
  explicit BadDefaultInitializedCopyAssign(int v) : value(v) {}
 | 
			
		||||
  BadDefaultInitializedCopyAssign(
 | 
			
		||||
      BadDefaultInitializedCopyAssign&& other) noexcept
 | 
			
		||||
      : value(other.value) {}
 | 
			
		||||
  BadDefaultInitializedCopyAssign(const BadDefaultInitializedCopyAssign& other)
 | 
			
		||||
      : value(other.value) {}
 | 
			
		||||
 | 
			
		||||
  BadDefaultInitializedCopyAssign& operator=(
 | 
			
		||||
      BadDefaultInitializedCopyAssign&& other) noexcept {
 | 
			
		||||
    value = other.value;
 | 
			
		||||
    return *this;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  BadDefaultInitializedCopyAssign& operator=(
 | 
			
		||||
      const BadDefaultInitializedCopyAssign& other) {
 | 
			
		||||
    value = other.value;
 | 
			
		||||
    if (default_initialized) ++value;  // Bad move if lhs is default initialized
 | 
			
		||||
    return *this;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  friend bool operator==(const BadDefaultInitializedCopyAssign& lhs,
 | 
			
		||||
                         const BadDefaultInitializedCopyAssign& rhs) {
 | 
			
		||||
    return lhs.value == rhs.value;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  friend bool operator!=(const BadDefaultInitializedCopyAssign& lhs,
 | 
			
		||||
                         const BadDefaultInitializedCopyAssign& rhs) {
 | 
			
		||||
    return lhs.value != rhs.value;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  bool default_initialized = false;
 | 
			
		||||
  int value = 0;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
TEST(ConformanceTestingDeathTest, DefaultInitializedAssignFailure) {
 | 
			
		||||
  using profile = ti::CombineProfiles<ti::DefaultConstructibleValueProfile,
 | 
			
		||||
                                      ti::EquatableProfile>;
 | 
			
		||||
 | 
			
		||||
  {
 | 
			
		||||
    ABSL_INTERNAL_ASSERT_NONCONFORMANCE_OF(BadDefaultInitializedCopyAssign)
 | 
			
		||||
        .DUE_TO("copy assignment")
 | 
			
		||||
        .INITIALIZER(BadDefaultInitializedCopyAssign(0))
 | 
			
		||||
        .WITH_LOOSE_PROFILE(profile);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
}  // namespace
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										34
									
								
								absl/types/internal/parentheses.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								absl/types/internal/parentheses.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,34 @@
 | 
			
		|||
// Copyright 2019 The Abseil Authors.
 | 
			
		||||
//
 | 
			
		||||
// Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
// you may not use this file except in compliance with the License.
 | 
			
		||||
// You may obtain a copy of the License at
 | 
			
		||||
//
 | 
			
		||||
//      https://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
//
 | 
			
		||||
// Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
// distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
// See the License for the specific language governing permissions and
 | 
			
		||||
// limitations under the License.
 | 
			
		||||
//
 | 
			
		||||
// -----------------------------------------------------------------------------
 | 
			
		||||
// parentheses.h
 | 
			
		||||
// -----------------------------------------------------------------------------
 | 
			
		||||
//
 | 
			
		||||
// This file contains macros that expand to a left parenthesis and a right
 | 
			
		||||
// parenthesis. These are in their own file and are generated from macros
 | 
			
		||||
// because otherwise clang-format gets confused and clang-format off directives
 | 
			
		||||
// do not help.
 | 
			
		||||
//
 | 
			
		||||
// The parentheses macros are used when wanting to require a rescan before
 | 
			
		||||
// expansion of parenthesized text appearing after a function-style macro name.
 | 
			
		||||
 | 
			
		||||
#ifndef ABSL_TYPES_INTERNAL_PARENTHESES_H_
 | 
			
		||||
#define ABSL_TYPES_INTERNAL_PARENTHESES_H_
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_LPAREN (
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_RPAREN )
 | 
			
		||||
 | 
			
		||||
#endif  // ABSL_TYPES_INTERNAL_PARENTHESES_H_
 | 
			
		||||
							
								
								
									
										246
									
								
								absl/types/internal/transform_args.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										246
									
								
								absl/types/internal/transform_args.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,246 @@
 | 
			
		|||
// Copyright 2019 The Abseil Authors.
 | 
			
		||||
//
 | 
			
		||||
// Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
// you may not use this file except in compliance with the License.
 | 
			
		||||
// You may obtain a copy of the License at
 | 
			
		||||
//
 | 
			
		||||
//      https://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
//
 | 
			
		||||
// Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
// distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
// See the License for the specific language governing permissions and
 | 
			
		||||
// limitations under the License.
 | 
			
		||||
//
 | 
			
		||||
// -----------------------------------------------------------------------------
 | 
			
		||||
// transform_args.h
 | 
			
		||||
// -----------------------------------------------------------------------------
 | 
			
		||||
//
 | 
			
		||||
// This file contains a higher-order macro that "transforms" each element of a
 | 
			
		||||
// a variadic argument by a provided secondary macro.
 | 
			
		||||
 | 
			
		||||
#ifndef ABSL_TYPES_INTERNAL_TRANSFORM_ARGS_H_
 | 
			
		||||
#define ABSL_TYPES_INTERNAL_TRANSFORM_ARGS_H_
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
// ABSL_INTERNAL_CAT(a, b)
 | 
			
		||||
//
 | 
			
		||||
// This macro takes two arguments and concatenates them together via ## after
 | 
			
		||||
// expansion.
 | 
			
		||||
//
 | 
			
		||||
// Example:
 | 
			
		||||
//
 | 
			
		||||
//   ABSL_INTERNAL_CAT(foo_, bar)
 | 
			
		||||
//
 | 
			
		||||
// Results in:
 | 
			
		||||
//
 | 
			
		||||
//   foo_bar
 | 
			
		||||
#define ABSL_INTERNAL_CAT(a, b) ABSL_INTERNAL_CAT_IMPL(a, b)
 | 
			
		||||
#define ABSL_INTERNAL_CAT_IMPL(a, b) a##b
 | 
			
		||||
 | 
			
		||||
//
 | 
			
		||||
// ABSL_INTERNAL_TRANSFORM_ARGS(m, ...)
 | 
			
		||||
//
 | 
			
		||||
// This macro takes another macro as an argument followed by a trailing series
 | 
			
		||||
// of additional parameters (up to 32 additional arguments). It invokes the
 | 
			
		||||
// passed-in macro once for each of the additional arguments, with the
 | 
			
		||||
// expansions separated by commas.
 | 
			
		||||
//
 | 
			
		||||
// Example:
 | 
			
		||||
//
 | 
			
		||||
//   ABSL_INTERNAL_TRANSFORM_ARGS(MY_MACRO, a, b, c)
 | 
			
		||||
//
 | 
			
		||||
// Results in:
 | 
			
		||||
//
 | 
			
		||||
//   MY_MACRO(a), MY_MACRO(b), MY_MACRO(c)
 | 
			
		||||
//
 | 
			
		||||
// TODO(calabrese) Handle no arguments as a special case.
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS(m, ...)             \
 | 
			
		||||
  ABSL_INTERNAL_CAT(ABSL_INTERNAL_TRANSFORM_ARGS,        \
 | 
			
		||||
                    ABSL_INTERNAL_NUM_ARGS(__VA_ARGS__)) \
 | 
			
		||||
  (m, __VA_ARGS__)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS1(m, a0) m(a0)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS2(m, a0, a1) m(a0), m(a1)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS3(m, a0, a1, a2) m(a0), m(a1), m(a2)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS4(m, a0, a1, a2, a3) \
 | 
			
		||||
  m(a0), m(a1), m(a2), m(a3)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS5(m, a0, a1, a2, a3, a4) \
 | 
			
		||||
  m(a0), m(a1), m(a2), m(a3), m(a4)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS6(m, a0, a1, a2, a3, a4, a5) \
 | 
			
		||||
  m(a0), m(a1), m(a2), m(a3), m(a4), m(a5)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS7(m, a0, a1, a2, a3, a4, a5, a6) \
 | 
			
		||||
  m(a0), m(a1), m(a2), m(a3), m(a4), m(a5), m(a6)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS8(m, a0, a1, a2, a3, a4, a5, a6, a7) \
 | 
			
		||||
  m(a0), m(a1), m(a2), m(a3), m(a4), m(a5), m(a6), m(a7)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS9(m, a0, a1, a2, a3, a4, a5, a6, a7, a8) \
 | 
			
		||||
  m(a0), m(a1), m(a2), m(a3), m(a4), m(a5), m(a6), m(a7), m(a8)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS10(m, a0, a1, a2, a3, a4, a5, a6, a7, a8, \
 | 
			
		||||
                                       a9)                                    \
 | 
			
		||||
  m(a0), m(a1), m(a2), m(a3), m(a4), m(a5), m(a6), m(a7), m(a8), m(a9)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS11(m, a0, a1, a2, a3, a4, a5, a6, a7, a8, \
 | 
			
		||||
                                       a9, a10)                               \
 | 
			
		||||
  m(a0), m(a1), m(a2), m(a3), m(a4), m(a5), m(a6), m(a7), m(a8), m(a9), m(a10)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS12(m, a0, a1, a2, a3, a4, a5, a6, a7, a8, \
 | 
			
		||||
                                       a9, a10, a11)                          \
 | 
			
		||||
  m(a0), m(a1), m(a2), m(a3), m(a4), m(a5), m(a6), m(a7), m(a8), m(a9),       \
 | 
			
		||||
      m(a10), m(a11)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS13(m, a0, a1, a2, a3, a4, a5, a6, a7, a8, \
 | 
			
		||||
                                       a9, a10, a11, a12)                     \
 | 
			
		||||
  m(a0), m(a1), m(a2), m(a3), m(a4), m(a5), m(a6), m(a7), m(a8), m(a9),       \
 | 
			
		||||
      m(a10), m(a11), m(a12)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS14(m, a0, a1, a2, a3, a4, a5, a6, a7, a8, \
 | 
			
		||||
                                       a9, a10, a11, a12, a13)                \
 | 
			
		||||
  m(a0), m(a1), m(a2), m(a3), m(a4), m(a5), m(a6), m(a7), m(a8), m(a9),       \
 | 
			
		||||
      m(a10), m(a11), m(a12), m(a13)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS15(m, a0, a1, a2, a3, a4, a5, a6, a7, a8, \
 | 
			
		||||
                                       a9, a10, a11, a12, a13, a14)           \
 | 
			
		||||
  m(a0), m(a1), m(a2), m(a3), m(a4), m(a5), m(a6), m(a7), m(a8), m(a9),       \
 | 
			
		||||
      m(a10), m(a11), m(a12), m(a13), m(a14)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS16(m, a0, a1, a2, a3, a4, a5, a6, a7, a8, \
 | 
			
		||||
                                       a9, a10, a11, a12, a13, a14, a15)      \
 | 
			
		||||
  m(a0), m(a1), m(a2), m(a3), m(a4), m(a5), m(a6), m(a7), m(a8), m(a9),       \
 | 
			
		||||
      m(a10), m(a11), m(a12), m(a13), m(a14), m(a15)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS17(m, a0, a1, a2, a3, a4, a5, a6, a7, a8, \
 | 
			
		||||
                                       a9, a10, a11, a12, a13, a14, a15, a16) \
 | 
			
		||||
  m(a0), m(a1), m(a2), m(a3), m(a4), m(a5), m(a6), m(a7), m(a8), m(a9),       \
 | 
			
		||||
      m(a10), m(a11), m(a12), m(a13), m(a14), m(a15), m(a16)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS18(m, a0, a1, a2, a3, a4, a5, a6, a7, a8, \
 | 
			
		||||
                                       a9, a10, a11, a12, a13, a14, a15, a16, \
 | 
			
		||||
                                       a17)                                   \
 | 
			
		||||
  m(a0), m(a1), m(a2), m(a3), m(a4), m(a5), m(a6), m(a7), m(a8), m(a9),       \
 | 
			
		||||
      m(a10), m(a11), m(a12), m(a13), m(a14), m(a15), m(a16), m(a17)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS19(m, a0, a1, a2, a3, a4, a5, a6, a7, a8, \
 | 
			
		||||
                                       a9, a10, a11, a12, a13, a14, a15, a16, \
 | 
			
		||||
                                       a17, a18)                              \
 | 
			
		||||
  m(a0), m(a1), m(a2), m(a3), m(a4), m(a5), m(a6), m(a7), m(a8), m(a9),       \
 | 
			
		||||
      m(a10), m(a11), m(a12), m(a13), m(a14), m(a15), m(a16), m(a17), m(a18)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS20(m, a0, a1, a2, a3, a4, a5, a6, a7, a8, \
 | 
			
		||||
                                       a9, a10, a11, a12, a13, a14, a15, a16, \
 | 
			
		||||
                                       a17, a18, a19)                         \
 | 
			
		||||
  m(a0), m(a1), m(a2), m(a3), m(a4), m(a5), m(a6), m(a7), m(a8), m(a9),       \
 | 
			
		||||
      m(a10), m(a11), m(a12), m(a13), m(a14), m(a15), m(a16), m(a17), m(a18), \
 | 
			
		||||
      m(a19)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS21(m, a0, a1, a2, a3, a4, a5, a6, a7, a8, \
 | 
			
		||||
                                       a9, a10, a11, a12, a13, a14, a15, a16, \
 | 
			
		||||
                                       a17, a18, a19, a20)                    \
 | 
			
		||||
  m(a0), m(a1), m(a2), m(a3), m(a4), m(a5), m(a6), m(a7), m(a8), m(a9),       \
 | 
			
		||||
      m(a10), m(a11), m(a12), m(a13), m(a14), m(a15), m(a16), m(a17), m(a18), \
 | 
			
		||||
      m(a19), m(a20)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS22(m, a0, a1, a2, a3, a4, a5, a6, a7, a8, \
 | 
			
		||||
                                       a9, a10, a11, a12, a13, a14, a15, a16, \
 | 
			
		||||
                                       a17, a18, a19, a20, a21)               \
 | 
			
		||||
  m(a0), m(a1), m(a2), m(a3), m(a4), m(a5), m(a6), m(a7), m(a8), m(a9),       \
 | 
			
		||||
      m(a10), m(a11), m(a12), m(a13), m(a14), m(a15), m(a16), m(a17), m(a18), \
 | 
			
		||||
      m(a19), m(a20), m(a21)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS23(m, a0, a1, a2, a3, a4, a5, a6, a7, a8, \
 | 
			
		||||
                                       a9, a10, a11, a12, a13, a14, a15, a16, \
 | 
			
		||||
                                       a17, a18, a19, a20, a21, a22)          \
 | 
			
		||||
  m(a0), m(a1), m(a2), m(a3), m(a4), m(a5), m(a6), m(a7), m(a8), m(a9),       \
 | 
			
		||||
      m(a10), m(a11), m(a12), m(a13), m(a14), m(a15), m(a16), m(a17), m(a18), \
 | 
			
		||||
      m(a19), m(a20), m(a21), m(a22)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS24(m, a0, a1, a2, a3, a4, a5, a6, a7, a8, \
 | 
			
		||||
                                       a9, a10, a11, a12, a13, a14, a15, a16, \
 | 
			
		||||
                                       a17, a18, a19, a20, a21, a22, a23)     \
 | 
			
		||||
  m(a0), m(a1), m(a2), m(a3), m(a4), m(a5), m(a6), m(a7), m(a8), m(a9),       \
 | 
			
		||||
      m(a10), m(a11), m(a12), m(a13), m(a14), m(a15), m(a16), m(a17), m(a18), \
 | 
			
		||||
      m(a19), m(a20), m(a21), m(a22), m(a23)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS25(m, a0, a1, a2, a3, a4, a5, a6, a7, a8,  \
 | 
			
		||||
                                       a9, a10, a11, a12, a13, a14, a15, a16,  \
 | 
			
		||||
                                       a17, a18, a19, a20, a21, a22, a23, a24) \
 | 
			
		||||
  m(a0), m(a1), m(a2), m(a3), m(a4), m(a5), m(a6), m(a7), m(a8), m(a9),        \
 | 
			
		||||
      m(a10), m(a11), m(a12), m(a13), m(a14), m(a15), m(a16), m(a17), m(a18),  \
 | 
			
		||||
      m(a19), m(a20), m(a21), m(a22), m(a23), m(a24)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS26(                                       \
 | 
			
		||||
    m, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15,  \
 | 
			
		||||
    a16, a17, a18, a19, a20, a21, a22, a23, a24, a25)                         \
 | 
			
		||||
  m(a0), m(a1), m(a2), m(a3), m(a4), m(a5), m(a6), m(a7), m(a8), m(a9),       \
 | 
			
		||||
      m(a10), m(a11), m(a12), m(a13), m(a14), m(a15), m(a16), m(a17), m(a18), \
 | 
			
		||||
      m(a19), m(a20), m(a21), m(a22), m(a23), m(a24), m(a25)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS27(                                       \
 | 
			
		||||
    m, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15,  \
 | 
			
		||||
    a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26)                    \
 | 
			
		||||
  m(a0), m(a1), m(a2), m(a3), m(a4), m(a5), m(a6), m(a7), m(a8), m(a9),       \
 | 
			
		||||
      m(a10), m(a11), m(a12), m(a13), m(a14), m(a15), m(a16), m(a17), m(a18), \
 | 
			
		||||
      m(a19), m(a20), m(a21), m(a22), m(a23), m(a24), m(a25), m(a26)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS28(                                       \
 | 
			
		||||
    m, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15,  \
 | 
			
		||||
    a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27)               \
 | 
			
		||||
  m(a0), m(a1), m(a2), m(a3), m(a4), m(a5), m(a6), m(a7), m(a8), m(a9),       \
 | 
			
		||||
      m(a10), m(a11), m(a12), m(a13), m(a14), m(a15), m(a16), m(a17), m(a18), \
 | 
			
		||||
      m(a19), m(a20), m(a21), m(a22), m(a23), m(a24), m(a25), m(a26), m(a27)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS29(                                       \
 | 
			
		||||
    m, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15,  \
 | 
			
		||||
    a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28)          \
 | 
			
		||||
  m(a0), m(a1), m(a2), m(a3), m(a4), m(a5), m(a6), m(a7), m(a8), m(a9),       \
 | 
			
		||||
      m(a10), m(a11), m(a12), m(a13), m(a14), m(a15), m(a16), m(a17), m(a18), \
 | 
			
		||||
      m(a19), m(a20), m(a21), m(a22), m(a23), m(a24), m(a25), m(a26), m(a27), \
 | 
			
		||||
      m(a28)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS30(                                       \
 | 
			
		||||
    m, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15,  \
 | 
			
		||||
    a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29)     \
 | 
			
		||||
  m(a0), m(a1), m(a2), m(a3), m(a4), m(a5), m(a6), m(a7), m(a8), m(a9),       \
 | 
			
		||||
      m(a10), m(a11), m(a12), m(a13), m(a14), m(a15), m(a16), m(a17), m(a18), \
 | 
			
		||||
      m(a19), m(a20), m(a21), m(a22), m(a23), m(a24), m(a25), m(a26), m(a27), \
 | 
			
		||||
      m(a28), m(a29)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS31(                                        \
 | 
			
		||||
    m, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15,   \
 | 
			
		||||
    a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30) \
 | 
			
		||||
  m(a0), m(a1), m(a2), m(a3), m(a4), m(a5), m(a6), m(a7), m(a8), m(a9),        \
 | 
			
		||||
      m(a10), m(a11), m(a12), m(a13), m(a14), m(a15), m(a16), m(a17), m(a18),  \
 | 
			
		||||
      m(a19), m(a20), m(a21), m(a22), m(a23), m(a24), m(a25), m(a26), m(a27),  \
 | 
			
		||||
      m(a28), m(a29), m(a30)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_TRANSFORM_ARGS32(m, a0, a1, a2, a3, a4, a5, a6, a7, a8,  \
 | 
			
		||||
                                       a9, a10, a11, a12, a13, a14, a15, a16,  \
 | 
			
		||||
                                       a17, a18, a19, a20, a21, a22, a23, a24, \
 | 
			
		||||
                                       a25, a26, a27, a28, a29, a30, a31)      \
 | 
			
		||||
  m(a0), m(a1), m(a2), m(a3), m(a4), m(a5), m(a6), m(a7), m(a8), m(a9),        \
 | 
			
		||||
      m(a10), m(a11), m(a12), m(a13), m(a14), m(a15), m(a16), m(a17), m(a18),  \
 | 
			
		||||
      m(a19), m(a20), m(a21), m(a22), m(a23), m(a24), m(a25), m(a26), m(a27),  \
 | 
			
		||||
      m(a28), m(a29), m(a30), m(a31)
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_NUM_ARGS_IMPL(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9,    \
 | 
			
		||||
                                    a10, a11, a12, a13, a14, a15, a16, a17,    \
 | 
			
		||||
                                    a18, a19, a20, a21, a22, a23, a24, a25,    \
 | 
			
		||||
                                    a26, a27, a28, a29, a30, a31, result, ...) \
 | 
			
		||||
  result
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_FORCE_EXPANSION(...) __VA_ARGS__
 | 
			
		||||
 | 
			
		||||
#define ABSL_INTERNAL_NUM_ARGS(...)                                            \
 | 
			
		||||
  ABSL_INTERNAL_FORCE_EXPANSION(ABSL_INTERNAL_NUM_ARGS_IMPL(                   \
 | 
			
		||||
      __VA_ARGS__, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, \
 | 
			
		||||
      17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, ))
 | 
			
		||||
 | 
			
		||||
#endif  // ABSL_TYPES_INTERNAL_TRANSFORM_ARGS_H_
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue