diff options
author | Marcin Kowalczyk <qrczak@google.com> | 2023-12-05 08:47:14 -0800 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-12-05 08:48:09 -0800 |
commit | f845e60acd880dbf07788a5a2c0dbad0f9c57231 (patch) | |
tree | 004d2977ebac75185dc68e0e675a5fc6ef118ea0 /absl/base/options.h | |
parent | 7b6c17e378224844d8663a410da2da5353b205b9 (diff) | |
download | abseil-f845e60acd880dbf07788a5a2c0dbad0f9c57231.tar.gz abseil-f845e60acd880dbf07788a5a2c0dbad0f9c57231.tar.bz2 abseil-f845e60acd880dbf07788a5a2c0dbad0f9c57231.zip |
Make `absl::{partial,weak,strong}_ordering` aliases for the `std::` ordering
types when they are available.
This makes them interchangeable in contexts known to be compiled as C++20.
This also makes `absl::` ordering types compatible with `<=>`, allowing to
unconditionally use `absl::` spelling for types but conditionally use `<=>`
when available.
PiperOrigin-RevId: 588085408
Change-Id: I1aa5247f0e31acbb838ee76829b7a13c74b0a94f
Diffstat (limited to 'absl/base/options.h')
-rw-r--r-- | absl/base/options.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/absl/base/options.h b/absl/base/options.h index 5c162a38..a169658f 100644 --- a/absl/base/options.h +++ b/absl/base/options.h @@ -176,6 +176,32 @@ #define ABSL_OPTION_USE_STD_VARIANT 2 +// ABSL_OPTION_USE_STD_ORDERING +// +// This option controls whether absl::{partial,weak,strong}_ordering are +// implemented as aliases to the std:: ordering types, or as an independent +// implementation. +// +// A value of 0 means to use Abseil's implementation. This requires only C++11 +// support, and is expected to work on every toolchain we support. +// +// A value of 1 means to use aliases. This requires that all code using Abseil +// is built in C++20 mode or later. +// +// A value of 2 means to detect the C++ version being used to compile Abseil, +// and use an alias only if working std:: ordering types are available. This +// option is useful when you are building your program from source. It should +// not be used otherwise -- for example, if you are distributing Abseil in a +// binary package manager -- since in mode 2, they will name different types, +// with different mangled names and binary layout, depending on the compiler +// flags passed by the end user. For more info, see +// https://abseil.io/about/design/dropin-types. +// +// User code should not inspect this macro. To check in the preprocessor if +// the ordering types are aliases of std:: ordering types, use the feature macro +// ABSL_USES_STD_ORDERING. + +#define ABSL_OPTION_USE_STD_ORDERING 2 // ABSL_OPTION_USE_INLINE_NAMESPACE // ABSL_OPTION_INLINE_NAMESPACE_NAME |