2019-09-05 01:57:56 +03:00
|
|
|
// compare standard header (core)
|
|
|
|
|
|
|
|
// Copyright (c) Microsoft Corporation.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#ifndef _COMPARE_
|
|
|
|
#define _COMPARE_
|
|
|
|
#include <yvals_core.h>
|
|
|
|
#if _STL_COMPILER_PREPROCESSOR
|
|
|
|
|
2019-11-06 00:12:34 +03:00
|
|
|
#if !_HAS_CXX20
|
|
|
|
#pragma message("The contents of <compare> are available only with C++20 or later.")
|
|
|
|
#else // ^^^ !_HAS_CXX20 / _HAS_CXX20 vvv
|
<compare>,<functional> Concept-constrained comparisons (#385)
Includes:
* concepts `three_way_comparable` and `three_way_comparable_with`,
* type trait `std::compare_three_way_result` (with `_t` alias), and
* function object `compare_three_way`.
in `<compare>`, and:
* function objects `ranges::equal_to` and `ranges::less` (in `<xutility>` for
easy algorithm access), `ranges::not_equal_to`, `ranges::less_equal`,
`ranges::greater`, and `ranges::greater_equal` (in `<functional>`),
* slight refactoring of concept definitions in `<concepts>` to avoid redundant
requirements for the single-type comparison concepts `equality_comparable`,
`totally_ordered`, and `three_way_comparable`,
* heavy refactoring of the trait `common_comparison_category` (and `_t` alias)
in `<compare>` to requires only `n + c` template instantiations instead of `cn`
template instantiations,
* ======== ABI BREAK =========== remove the `_Is_unordered` member from
`std::partial_ordering` in `<compare>` since (a) it's true if and only if the
stored value has a particular value, and (b) Clang expects all of the
comparison category types to have size 1,
* reorder all `is_transparent` alias declarations in the STL to be after the
corresponding `operator()` to agree with synopsis order.
Also adds a new test `P0896R4_P1614R2_comparisons` that exercises the above.
The ABI BREAK sounds scary - as it should - but note that:
* this is a `/std:c++latest` feature, which is subject to change,
* objects of comparison category type aren't typically stored,
* only MSVC has released `<compare>` so far, so it's not widely used.
Altogether, it's extremely unlikely that anyone has encoded this in ABI.
2020-02-19 04:38:40 +03:00
|
|
|
#ifdef __cpp_lib_concepts
|
|
|
|
#include <concepts>
|
|
|
|
#else // ^^^ __cpp_lib_concepts / !__cpp_lib_concepts vvv
|
2019-09-05 01:57:56 +03:00
|
|
|
#include <xtr1common>
|
<compare>,<functional> Concept-constrained comparisons (#385)
Includes:
* concepts `three_way_comparable` and `three_way_comparable_with`,
* type trait `std::compare_three_way_result` (with `_t` alias), and
* function object `compare_three_way`.
in `<compare>`, and:
* function objects `ranges::equal_to` and `ranges::less` (in `<xutility>` for
easy algorithm access), `ranges::not_equal_to`, `ranges::less_equal`,
`ranges::greater`, and `ranges::greater_equal` (in `<functional>`),
* slight refactoring of concept definitions in `<concepts>` to avoid redundant
requirements for the single-type comparison concepts `equality_comparable`,
`totally_ordered`, and `three_way_comparable`,
* heavy refactoring of the trait `common_comparison_category` (and `_t` alias)
in `<compare>` to requires only `n + c` template instantiations instead of `cn`
template instantiations,
* ======== ABI BREAK =========== remove the `_Is_unordered` member from
`std::partial_ordering` in `<compare>` since (a) it's true if and only if the
stored value has a particular value, and (b) Clang expects all of the
comparison category types to have size 1,
* reorder all `is_transparent` alias declarations in the STL to be after the
corresponding `operator()` to agree with synopsis order.
Also adds a new test `P0896R4_P1614R2_comparisons` that exercises the above.
The ABI BREAK sounds scary - as it should - but note that:
* this is a `/std:c++latest` feature, which is subject to change,
* objects of comparison category type aren't typically stored,
* only MSVC has released `<compare>` so far, so it's not widely used.
Altogether, it's extremely unlikely that anyone has encoded this in ABI.
2020-02-19 04:38:40 +03:00
|
|
|
#endif // !__cpp_lib_concepts
|
2019-09-05 01:57:56 +03:00
|
|
|
|
|
|
|
#pragma pack(push, _CRT_PACKING)
|
|
|
|
#pragma warning(push, _STL_WARNING_LEVEL)
|
|
|
|
#pragma warning(disable : _STL_DISABLED_WARNINGS)
|
|
|
|
_STL_DISABLE_CLANG_WARNINGS
|
|
|
|
#pragma push_macro("new")
|
|
|
|
#undef new
|
|
|
|
|
|
|
|
_STD_BEGIN
|
|
|
|
using _Literal_zero = decltype(nullptr);
|
|
|
|
using _Compare_t = signed char;
|
|
|
|
|
|
|
|
// These "pretty" enumerator names are safe since they reuse names of user-facing entities.
|
2020-01-24 23:10:13 +03:00
|
|
|
enum class _Compare_eq : _Compare_t { equal = 0, equivalent = equal };
|
2019-09-05 01:57:56 +03:00
|
|
|
enum class _Compare_ord : _Compare_t { less = -1, greater = 1 };
|
|
|
|
enum class _Compare_ncmp : _Compare_t { unordered = -127 };
|
|
|
|
|
|
|
|
// CLASS partial_ordering
|
|
|
|
class partial_ordering {
|
|
|
|
public:
|
2019-11-01 03:37:56 +03:00
|
|
|
_NODISCARD constexpr explicit partial_ordering(const _Compare_eq _Value_) noexcept
|
<compare>,<functional> Concept-constrained comparisons (#385)
Includes:
* concepts `three_way_comparable` and `three_way_comparable_with`,
* type trait `std::compare_three_way_result` (with `_t` alias), and
* function object `compare_three_way`.
in `<compare>`, and:
* function objects `ranges::equal_to` and `ranges::less` (in `<xutility>` for
easy algorithm access), `ranges::not_equal_to`, `ranges::less_equal`,
`ranges::greater`, and `ranges::greater_equal` (in `<functional>`),
* slight refactoring of concept definitions in `<concepts>` to avoid redundant
requirements for the single-type comparison concepts `equality_comparable`,
`totally_ordered`, and `three_way_comparable`,
* heavy refactoring of the trait `common_comparison_category` (and `_t` alias)
in `<compare>` to requires only `n + c` template instantiations instead of `cn`
template instantiations,
* ======== ABI BREAK =========== remove the `_Is_unordered` member from
`std::partial_ordering` in `<compare>` since (a) it's true if and only if the
stored value has a particular value, and (b) Clang expects all of the
comparison category types to have size 1,
* reorder all `is_transparent` alias declarations in the STL to be after the
corresponding `operator()` to agree with synopsis order.
Also adds a new test `P0896R4_P1614R2_comparisons` that exercises the above.
The ABI BREAK sounds scary - as it should - but note that:
* this is a `/std:c++latest` feature, which is subject to change,
* objects of comparison category type aren't typically stored,
* only MSVC has released `<compare>` so far, so it's not widely used.
Altogether, it's extremely unlikely that anyone has encoded this in ABI.
2020-02-19 04:38:40 +03:00
|
|
|
: _Value(static_cast<_Compare_t>(_Value_)) {}
|
2019-11-01 03:37:56 +03:00
|
|
|
_NODISCARD constexpr explicit partial_ordering(const _Compare_ord _Value_) noexcept
|
<compare>,<functional> Concept-constrained comparisons (#385)
Includes:
* concepts `three_way_comparable` and `three_way_comparable_with`,
* type trait `std::compare_three_way_result` (with `_t` alias), and
* function object `compare_three_way`.
in `<compare>`, and:
* function objects `ranges::equal_to` and `ranges::less` (in `<xutility>` for
easy algorithm access), `ranges::not_equal_to`, `ranges::less_equal`,
`ranges::greater`, and `ranges::greater_equal` (in `<functional>`),
* slight refactoring of concept definitions in `<concepts>` to avoid redundant
requirements for the single-type comparison concepts `equality_comparable`,
`totally_ordered`, and `three_way_comparable`,
* heavy refactoring of the trait `common_comparison_category` (and `_t` alias)
in `<compare>` to requires only `n + c` template instantiations instead of `cn`
template instantiations,
* ======== ABI BREAK =========== remove the `_Is_unordered` member from
`std::partial_ordering` in `<compare>` since (a) it's true if and only if the
stored value has a particular value, and (b) Clang expects all of the
comparison category types to have size 1,
* reorder all `is_transparent` alias declarations in the STL to be after the
corresponding `operator()` to agree with synopsis order.
Also adds a new test `P0896R4_P1614R2_comparisons` that exercises the above.
The ABI BREAK sounds scary - as it should - but note that:
* this is a `/std:c++latest` feature, which is subject to change,
* objects of comparison category type aren't typically stored,
* only MSVC has released `<compare>` so far, so it's not widely used.
Altogether, it's extremely unlikely that anyone has encoded this in ABI.
2020-02-19 04:38:40 +03:00
|
|
|
: _Value(static_cast<_Compare_t>(_Value_)) {}
|
2019-11-01 03:37:56 +03:00
|
|
|
_NODISCARD constexpr explicit partial_ordering(const _Compare_ncmp _Value_) noexcept
|
<compare>,<functional> Concept-constrained comparisons (#385)
Includes:
* concepts `three_way_comparable` and `three_way_comparable_with`,
* type trait `std::compare_three_way_result` (with `_t` alias), and
* function object `compare_three_way`.
in `<compare>`, and:
* function objects `ranges::equal_to` and `ranges::less` (in `<xutility>` for
easy algorithm access), `ranges::not_equal_to`, `ranges::less_equal`,
`ranges::greater`, and `ranges::greater_equal` (in `<functional>`),
* slight refactoring of concept definitions in `<concepts>` to avoid redundant
requirements for the single-type comparison concepts `equality_comparable`,
`totally_ordered`, and `three_way_comparable`,
* heavy refactoring of the trait `common_comparison_category` (and `_t` alias)
in `<compare>` to requires only `n + c` template instantiations instead of `cn`
template instantiations,
* ======== ABI BREAK =========== remove the `_Is_unordered` member from
`std::partial_ordering` in `<compare>` since (a) it's true if and only if the
stored value has a particular value, and (b) Clang expects all of the
comparison category types to have size 1,
* reorder all `is_transparent` alias declarations in the STL to be after the
corresponding `operator()` to agree with synopsis order.
Also adds a new test `P0896R4_P1614R2_comparisons` that exercises the above.
The ABI BREAK sounds scary - as it should - but note that:
* this is a `/std:c++latest` feature, which is subject to change,
* objects of comparison category type aren't typically stored,
* only MSVC has released `<compare>` so far, so it's not widely used.
Altogether, it's extremely unlikely that anyone has encoded this in ABI.
2020-02-19 04:38:40 +03:00
|
|
|
: _Value(static_cast<_Compare_t>(_Value_)) {}
|
2019-09-05 01:57:56 +03:00
|
|
|
|
|
|
|
static const partial_ordering less;
|
|
|
|
static const partial_ordering equivalent;
|
|
|
|
static const partial_ordering greater;
|
|
|
|
static const partial_ordering unordered;
|
|
|
|
|
2019-11-01 03:37:56 +03:00
|
|
|
_NODISCARD friend constexpr bool operator==(const partial_ordering _Val, _Literal_zero) noexcept {
|
<compare>,<functional> Concept-constrained comparisons (#385)
Includes:
* concepts `three_way_comparable` and `three_way_comparable_with`,
* type trait `std::compare_three_way_result` (with `_t` alias), and
* function object `compare_three_way`.
in `<compare>`, and:
* function objects `ranges::equal_to` and `ranges::less` (in `<xutility>` for
easy algorithm access), `ranges::not_equal_to`, `ranges::less_equal`,
`ranges::greater`, and `ranges::greater_equal` (in `<functional>`),
* slight refactoring of concept definitions in `<concepts>` to avoid redundant
requirements for the single-type comparison concepts `equality_comparable`,
`totally_ordered`, and `three_way_comparable`,
* heavy refactoring of the trait `common_comparison_category` (and `_t` alias)
in `<compare>` to requires only `n + c` template instantiations instead of `cn`
template instantiations,
* ======== ABI BREAK =========== remove the `_Is_unordered` member from
`std::partial_ordering` in `<compare>` since (a) it's true if and only if the
stored value has a particular value, and (b) Clang expects all of the
comparison category types to have size 1,
* reorder all `is_transparent` alias declarations in the STL to be after the
corresponding `operator()` to agree with synopsis order.
Also adds a new test `P0896R4_P1614R2_comparisons` that exercises the above.
The ABI BREAK sounds scary - as it should - but note that:
* this is a `/std:c++latest` feature, which is subject to change,
* objects of comparison category type aren't typically stored,
* only MSVC has released `<compare>` so far, so it's not widely used.
Altogether, it's extremely unlikely that anyone has encoded this in ABI.
2020-02-19 04:38:40 +03:00
|
|
|
return _Val._Value == 0;
|
2019-09-05 01:57:56 +03:00
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
2019-12-14 02:00:50 +03:00
|
|
|
#if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201902L
|
Allow Clang10 in the STL (#622)
* Allow Clang10 in the STL
This PR includes changes necessary to allow (but not require) clang 10 in the STL. It also includes test changes to allow the tests to pass given new clang warnings for deprecated behaviors, and an update to the LLVM reference to get similar changes that have been applied upstream to libc++ tests.
Details:
* In `<compare>`, remove workarounds for LLVM-41991 in Clang 10 RC1 fixed in RC2.
* In `<concepts>`, remove `_SILENCE_CLANG_CONCEPTS_MESSAGE`.
* In `<queue>` and `<stack>`, befriend only corresponding specializations of operator templates.
* In `<system_error>`, fix the `__cpp_constexpr_dynamic_alloc` implementation of `_Immortalize_memcpy_image` (which we apparently didn't review at all).
* In `<experimental/filesystem>`, apply a fix equivalent to the resolution of LWG-3244.
* Update `P0220R1_optional` from upstream.
* In `P0595R2_is_constant_evaluated`, silence Clang's warning for using `is_constant_evaluated` in a manifestly constant-evaluated context.
* In `P0896R4_ranges_iterator_machinery`, fix bogus test cases that were expecting VSO-1008447, silence "unused variable" warnings, and avoid taking advantage of too-lenient MSVC comparison rewrite behavior.
* In `P0896R4_ranges_range_machinery`, silence "unused variable" warning.
* In `P0898R3_concepts`, Remove workaround for LLVM-44627 in Clang 10 RC1 fixed in RC2.
* In `VSO_0000000_type_traits` and `tr1/type_traits5`, silence volatile function parameter deprecation warnings.
* In `tr1/condition_variable`, `tr1/regex1`, and `tr1/regex3`, remove unnecessary copy assignment operators that were prompting Clang warnings about the implicitly definition of a copy constructor for such a class being deprecated.
* In `tr1/csetjmp`, silence volatile increment deprecation warnings.
Skip new libc++ tests:
* Various `span` tests that expect `const_iterator` (libc++ doesn't yet implement LWG-3320)
* tests for the implementation of P1135R6 "The C++ Synchronization Library" which we do not yet implement
2020-03-20 02:42:55 +03:00
|
|
|
_NODISCARD friend constexpr bool operator==(const partial_ordering&, const partial_ordering&) noexcept = default;
|
2019-11-01 03:37:56 +03:00
|
|
|
#else // ^^^ supports <=> and P1185 / supports neither vvv
|
|
|
|
_NODISCARD friend constexpr bool operator!=(const partial_ordering _Val, _Literal_zero) noexcept {
|
<compare>,<functional> Concept-constrained comparisons (#385)
Includes:
* concepts `three_way_comparable` and `three_way_comparable_with`,
* type trait `std::compare_three_way_result` (with `_t` alias), and
* function object `compare_three_way`.
in `<compare>`, and:
* function objects `ranges::equal_to` and `ranges::less` (in `<xutility>` for
easy algorithm access), `ranges::not_equal_to`, `ranges::less_equal`,
`ranges::greater`, and `ranges::greater_equal` (in `<functional>`),
* slight refactoring of concept definitions in `<concepts>` to avoid redundant
requirements for the single-type comparison concepts `equality_comparable`,
`totally_ordered`, and `three_way_comparable`,
* heavy refactoring of the trait `common_comparison_category` (and `_t` alias)
in `<compare>` to requires only `n + c` template instantiations instead of `cn`
template instantiations,
* ======== ABI BREAK =========== remove the `_Is_unordered` member from
`std::partial_ordering` in `<compare>` since (a) it's true if and only if the
stored value has a particular value, and (b) Clang expects all of the
comparison category types to have size 1,
* reorder all `is_transparent` alias declarations in the STL to be after the
corresponding `operator()` to agree with synopsis order.
Also adds a new test `P0896R4_P1614R2_comparisons` that exercises the above.
The ABI BREAK sounds scary - as it should - but note that:
* this is a `/std:c++latest` feature, which is subject to change,
* objects of comparison category type aren't typically stored,
* only MSVC has released `<compare>` so far, so it's not widely used.
Altogether, it's extremely unlikely that anyone has encoded this in ABI.
2020-02-19 04:38:40 +03:00
|
|
|
return _Val._Value != 0;
|
2019-09-05 01:57:56 +03:00
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
_NODISCARD friend constexpr bool operator==(_Literal_zero, const partial_ordering _Val) noexcept {
|
<compare>,<functional> Concept-constrained comparisons (#385)
Includes:
* concepts `three_way_comparable` and `three_way_comparable_with`,
* type trait `std::compare_three_way_result` (with `_t` alias), and
* function object `compare_three_way`.
in `<compare>`, and:
* function objects `ranges::equal_to` and `ranges::less` (in `<xutility>` for
easy algorithm access), `ranges::not_equal_to`, `ranges::less_equal`,
`ranges::greater`, and `ranges::greater_equal` (in `<functional>`),
* slight refactoring of concept definitions in `<concepts>` to avoid redundant
requirements for the single-type comparison concepts `equality_comparable`,
`totally_ordered`, and `three_way_comparable`,
* heavy refactoring of the trait `common_comparison_category` (and `_t` alias)
in `<compare>` to requires only `n + c` template instantiations instead of `cn`
template instantiations,
* ======== ABI BREAK =========== remove the `_Is_unordered` member from
`std::partial_ordering` in `<compare>` since (a) it's true if and only if the
stored value has a particular value, and (b) Clang expects all of the
comparison category types to have size 1,
* reorder all `is_transparent` alias declarations in the STL to be after the
corresponding `operator()` to agree with synopsis order.
Also adds a new test `P0896R4_P1614R2_comparisons` that exercises the above.
The ABI BREAK sounds scary - as it should - but note that:
* this is a `/std:c++latest` feature, which is subject to change,
* objects of comparison category type aren't typically stored,
* only MSVC has released `<compare>` so far, so it's not widely used.
Altogether, it's extremely unlikely that anyone has encoded this in ABI.
2020-02-19 04:38:40 +03:00
|
|
|
return 0 == _Val._Value;
|
2019-11-01 03:37:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
_NODISCARD friend constexpr bool operator!=(_Literal_zero, const partial_ordering _Val) noexcept {
|
<compare>,<functional> Concept-constrained comparisons (#385)
Includes:
* concepts `three_way_comparable` and `three_way_comparable_with`,
* type trait `std::compare_three_way_result` (with `_t` alias), and
* function object `compare_three_way`.
in `<compare>`, and:
* function objects `ranges::equal_to` and `ranges::less` (in `<xutility>` for
easy algorithm access), `ranges::not_equal_to`, `ranges::less_equal`,
`ranges::greater`, and `ranges::greater_equal` (in `<functional>`),
* slight refactoring of concept definitions in `<concepts>` to avoid redundant
requirements for the single-type comparison concepts `equality_comparable`,
`totally_ordered`, and `three_way_comparable`,
* heavy refactoring of the trait `common_comparison_category` (and `_t` alias)
in `<compare>` to requires only `n + c` template instantiations instead of `cn`
template instantiations,
* ======== ABI BREAK =========== remove the `_Is_unordered` member from
`std::partial_ordering` in `<compare>` since (a) it's true if and only if the
stored value has a particular value, and (b) Clang expects all of the
comparison category types to have size 1,
* reorder all `is_transparent` alias declarations in the STL to be after the
corresponding `operator()` to agree with synopsis order.
Also adds a new test `P0896R4_P1614R2_comparisons` that exercises the above.
The ABI BREAK sounds scary - as it should - but note that:
* this is a `/std:c++latest` feature, which is subject to change,
* objects of comparison category type aren't typically stored,
* only MSVC has released `<compare>` so far, so it's not widely used.
Altogether, it's extremely unlikely that anyone has encoded this in ABI.
2020-02-19 04:38:40 +03:00
|
|
|
return 0 != _Val._Value;
|
2019-11-01 03:37:56 +03:00
|
|
|
}
|
2019-12-14 02:00:50 +03:00
|
|
|
#endif // defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201902L
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
_NODISCARD friend constexpr bool operator<(const partial_ordering _Val, _Literal_zero) noexcept {
|
<compare>,<functional> Concept-constrained comparisons (#385)
Includes:
* concepts `three_way_comparable` and `three_way_comparable_with`,
* type trait `std::compare_three_way_result` (with `_t` alias), and
* function object `compare_three_way`.
in `<compare>`, and:
* function objects `ranges::equal_to` and `ranges::less` (in `<xutility>` for
easy algorithm access), `ranges::not_equal_to`, `ranges::less_equal`,
`ranges::greater`, and `ranges::greater_equal` (in `<functional>`),
* slight refactoring of concept definitions in `<concepts>` to avoid redundant
requirements for the single-type comparison concepts `equality_comparable`,
`totally_ordered`, and `three_way_comparable`,
* heavy refactoring of the trait `common_comparison_category` (and `_t` alias)
in `<compare>` to requires only `n + c` template instantiations instead of `cn`
template instantiations,
* ======== ABI BREAK =========== remove the `_Is_unordered` member from
`std::partial_ordering` in `<compare>` since (a) it's true if and only if the
stored value has a particular value, and (b) Clang expects all of the
comparison category types to have size 1,
* reorder all `is_transparent` alias declarations in the STL to be after the
corresponding `operator()` to agree with synopsis order.
Also adds a new test `P0896R4_P1614R2_comparisons` that exercises the above.
The ABI BREAK sounds scary - as it should - but note that:
* this is a `/std:c++latest` feature, which is subject to change,
* objects of comparison category type aren't typically stored,
* only MSVC has released `<compare>` so far, so it's not widely used.
Altogether, it's extremely unlikely that anyone has encoded this in ABI.
2020-02-19 04:38:40 +03:00
|
|
|
return _Val._Value == static_cast<_Compare_t>(_Compare_ord::less);
|
2019-09-05 01:57:56 +03:00
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
_NODISCARD friend constexpr bool operator>(const partial_ordering _Val, _Literal_zero) noexcept {
|
<compare>,<functional> Concept-constrained comparisons (#385)
Includes:
* concepts `three_way_comparable` and `three_way_comparable_with`,
* type trait `std::compare_three_way_result` (with `_t` alias), and
* function object `compare_three_way`.
in `<compare>`, and:
* function objects `ranges::equal_to` and `ranges::less` (in `<xutility>` for
easy algorithm access), `ranges::not_equal_to`, `ranges::less_equal`,
`ranges::greater`, and `ranges::greater_equal` (in `<functional>`),
* slight refactoring of concept definitions in `<concepts>` to avoid redundant
requirements for the single-type comparison concepts `equality_comparable`,
`totally_ordered`, and `three_way_comparable`,
* heavy refactoring of the trait `common_comparison_category` (and `_t` alias)
in `<compare>` to requires only `n + c` template instantiations instead of `cn`
template instantiations,
* ======== ABI BREAK =========== remove the `_Is_unordered` member from
`std::partial_ordering` in `<compare>` since (a) it's true if and only if the
stored value has a particular value, and (b) Clang expects all of the
comparison category types to have size 1,
* reorder all `is_transparent` alias declarations in the STL to be after the
corresponding `operator()` to agree with synopsis order.
Also adds a new test `P0896R4_P1614R2_comparisons` that exercises the above.
The ABI BREAK sounds scary - as it should - but note that:
* this is a `/std:c++latest` feature, which is subject to change,
* objects of comparison category type aren't typically stored,
* only MSVC has released `<compare>` so far, so it's not widely used.
Altogether, it's extremely unlikely that anyone has encoded this in ABI.
2020-02-19 04:38:40 +03:00
|
|
|
return _Val._Value > 0;
|
2019-09-05 01:57:56 +03:00
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
_NODISCARD friend constexpr bool operator<=(const partial_ordering _Val, _Literal_zero) noexcept {
|
<compare>,<functional> Concept-constrained comparisons (#385)
Includes:
* concepts `three_way_comparable` and `three_way_comparable_with`,
* type trait `std::compare_three_way_result` (with `_t` alias), and
* function object `compare_three_way`.
in `<compare>`, and:
* function objects `ranges::equal_to` and `ranges::less` (in `<xutility>` for
easy algorithm access), `ranges::not_equal_to`, `ranges::less_equal`,
`ranges::greater`, and `ranges::greater_equal` (in `<functional>`),
* slight refactoring of concept definitions in `<concepts>` to avoid redundant
requirements for the single-type comparison concepts `equality_comparable`,
`totally_ordered`, and `three_way_comparable`,
* heavy refactoring of the trait `common_comparison_category` (and `_t` alias)
in `<compare>` to requires only `n + c` template instantiations instead of `cn`
template instantiations,
* ======== ABI BREAK =========== remove the `_Is_unordered` member from
`std::partial_ordering` in `<compare>` since (a) it's true if and only if the
stored value has a particular value, and (b) Clang expects all of the
comparison category types to have size 1,
* reorder all `is_transparent` alias declarations in the STL to be after the
corresponding `operator()` to agree with synopsis order.
Also adds a new test `P0896R4_P1614R2_comparisons` that exercises the above.
The ABI BREAK sounds scary - as it should - but note that:
* this is a `/std:c++latest` feature, which is subject to change,
* objects of comparison category type aren't typically stored,
* only MSVC has released `<compare>` so far, so it's not widely used.
Altogether, it's extremely unlikely that anyone has encoded this in ABI.
2020-02-19 04:38:40 +03:00
|
|
|
return _Val._Value <= 0 && _Val._Is_ordered();
|
2019-09-05 01:57:56 +03:00
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
_NODISCARD friend constexpr bool operator>=(const partial_ordering _Val, _Literal_zero) noexcept {
|
<compare>,<functional> Concept-constrained comparisons (#385)
Includes:
* concepts `three_way_comparable` and `three_way_comparable_with`,
* type trait `std::compare_three_way_result` (with `_t` alias), and
* function object `compare_three_way`.
in `<compare>`, and:
* function objects `ranges::equal_to` and `ranges::less` (in `<xutility>` for
easy algorithm access), `ranges::not_equal_to`, `ranges::less_equal`,
`ranges::greater`, and `ranges::greater_equal` (in `<functional>`),
* slight refactoring of concept definitions in `<concepts>` to avoid redundant
requirements for the single-type comparison concepts `equality_comparable`,
`totally_ordered`, and `three_way_comparable`,
* heavy refactoring of the trait `common_comparison_category` (and `_t` alias)
in `<compare>` to requires only `n + c` template instantiations instead of `cn`
template instantiations,
* ======== ABI BREAK =========== remove the `_Is_unordered` member from
`std::partial_ordering` in `<compare>` since (a) it's true if and only if the
stored value has a particular value, and (b) Clang expects all of the
comparison category types to have size 1,
* reorder all `is_transparent` alias declarations in the STL to be after the
corresponding `operator()` to agree with synopsis order.
Also adds a new test `P0896R4_P1614R2_comparisons` that exercises the above.
The ABI BREAK sounds scary - as it should - but note that:
* this is a `/std:c++latest` feature, which is subject to change,
* objects of comparison category type aren't typically stored,
* only MSVC has released `<compare>` so far, so it's not widely used.
Altogether, it's extremely unlikely that anyone has encoded this in ABI.
2020-02-19 04:38:40 +03:00
|
|
|
return _Val._Value >= 0;
|
2019-09-05 01:57:56 +03:00
|
|
|
}
|
|
|
|
|
2019-11-01 03:37:56 +03:00
|
|
|
_NODISCARD friend constexpr bool operator<(_Literal_zero, const partial_ordering _Val) noexcept {
|
<compare>,<functional> Concept-constrained comparisons (#385)
Includes:
* concepts `three_way_comparable` and `three_way_comparable_with`,
* type trait `std::compare_three_way_result` (with `_t` alias), and
* function object `compare_three_way`.
in `<compare>`, and:
* function objects `ranges::equal_to` and `ranges::less` (in `<xutility>` for
easy algorithm access), `ranges::not_equal_to`, `ranges::less_equal`,
`ranges::greater`, and `ranges::greater_equal` (in `<functional>`),
* slight refactoring of concept definitions in `<concepts>` to avoid redundant
requirements for the single-type comparison concepts `equality_comparable`,
`totally_ordered`, and `three_way_comparable`,
* heavy refactoring of the trait `common_comparison_category` (and `_t` alias)
in `<compare>` to requires only `n + c` template instantiations instead of `cn`
template instantiations,
* ======== ABI BREAK =========== remove the `_Is_unordered` member from
`std::partial_ordering` in `<compare>` since (a) it's true if and only if the
stored value has a particular value, and (b) Clang expects all of the
comparison category types to have size 1,
* reorder all `is_transparent` alias declarations in the STL to be after the
corresponding `operator()` to agree with synopsis order.
Also adds a new test `P0896R4_P1614R2_comparisons` that exercises the above.
The ABI BREAK sounds scary - as it should - but note that:
* this is a `/std:c++latest` feature, which is subject to change,
* objects of comparison category type aren't typically stored,
* only MSVC has released `<compare>` so far, so it's not widely used.
Altogether, it's extremely unlikely that anyone has encoded this in ABI.
2020-02-19 04:38:40 +03:00
|
|
|
return 0 < _Val._Value;
|
2019-09-05 01:57:56 +03:00
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
_NODISCARD friend constexpr bool operator>(_Literal_zero, const partial_ordering _Val) noexcept {
|
<compare>,<functional> Concept-constrained comparisons (#385)
Includes:
* concepts `three_way_comparable` and `three_way_comparable_with`,
* type trait `std::compare_three_way_result` (with `_t` alias), and
* function object `compare_three_way`.
in `<compare>`, and:
* function objects `ranges::equal_to` and `ranges::less` (in `<xutility>` for
easy algorithm access), `ranges::not_equal_to`, `ranges::less_equal`,
`ranges::greater`, and `ranges::greater_equal` (in `<functional>`),
* slight refactoring of concept definitions in `<concepts>` to avoid redundant
requirements for the single-type comparison concepts `equality_comparable`,
`totally_ordered`, and `three_way_comparable`,
* heavy refactoring of the trait `common_comparison_category` (and `_t` alias)
in `<compare>` to requires only `n + c` template instantiations instead of `cn`
template instantiations,
* ======== ABI BREAK =========== remove the `_Is_unordered` member from
`std::partial_ordering` in `<compare>` since (a) it's true if and only if the
stored value has a particular value, and (b) Clang expects all of the
comparison category types to have size 1,
* reorder all `is_transparent` alias declarations in the STL to be after the
corresponding `operator()` to agree with synopsis order.
Also adds a new test `P0896R4_P1614R2_comparisons` that exercises the above.
The ABI BREAK sounds scary - as it should - but note that:
* this is a `/std:c++latest` feature, which is subject to change,
* objects of comparison category type aren't typically stored,
* only MSVC has released `<compare>` so far, so it's not widely used.
Altogether, it's extremely unlikely that anyone has encoded this in ABI.
2020-02-19 04:38:40 +03:00
|
|
|
return 0 > _Val._Value && _Val._Is_ordered();
|
2019-09-05 01:57:56 +03:00
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
_NODISCARD friend constexpr bool operator<=(_Literal_zero, const partial_ordering _Val) noexcept {
|
<compare>,<functional> Concept-constrained comparisons (#385)
Includes:
* concepts `three_way_comparable` and `three_way_comparable_with`,
* type trait `std::compare_three_way_result` (with `_t` alias), and
* function object `compare_three_way`.
in `<compare>`, and:
* function objects `ranges::equal_to` and `ranges::less` (in `<xutility>` for
easy algorithm access), `ranges::not_equal_to`, `ranges::less_equal`,
`ranges::greater`, and `ranges::greater_equal` (in `<functional>`),
* slight refactoring of concept definitions in `<concepts>` to avoid redundant
requirements for the single-type comparison concepts `equality_comparable`,
`totally_ordered`, and `three_way_comparable`,
* heavy refactoring of the trait `common_comparison_category` (and `_t` alias)
in `<compare>` to requires only `n + c` template instantiations instead of `cn`
template instantiations,
* ======== ABI BREAK =========== remove the `_Is_unordered` member from
`std::partial_ordering` in `<compare>` since (a) it's true if and only if the
stored value has a particular value, and (b) Clang expects all of the
comparison category types to have size 1,
* reorder all `is_transparent` alias declarations in the STL to be after the
corresponding `operator()` to agree with synopsis order.
Also adds a new test `P0896R4_P1614R2_comparisons` that exercises the above.
The ABI BREAK sounds scary - as it should - but note that:
* this is a `/std:c++latest` feature, which is subject to change,
* objects of comparison category type aren't typically stored,
* only MSVC has released `<compare>` so far, so it's not widely used.
Altogether, it's extremely unlikely that anyone has encoded this in ABI.
2020-02-19 04:38:40 +03:00
|
|
|
return 0 <= _Val._Value;
|
2019-09-05 01:57:56 +03:00
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
_NODISCARD friend constexpr bool operator>=(_Literal_zero, const partial_ordering _Val) noexcept {
|
<compare>,<functional> Concept-constrained comparisons (#385)
Includes:
* concepts `three_way_comparable` and `three_way_comparable_with`,
* type trait `std::compare_three_way_result` (with `_t` alias), and
* function object `compare_three_way`.
in `<compare>`, and:
* function objects `ranges::equal_to` and `ranges::less` (in `<xutility>` for
easy algorithm access), `ranges::not_equal_to`, `ranges::less_equal`,
`ranges::greater`, and `ranges::greater_equal` (in `<functional>`),
* slight refactoring of concept definitions in `<concepts>` to avoid redundant
requirements for the single-type comparison concepts `equality_comparable`,
`totally_ordered`, and `three_way_comparable`,
* heavy refactoring of the trait `common_comparison_category` (and `_t` alias)
in `<compare>` to requires only `n + c` template instantiations instead of `cn`
template instantiations,
* ======== ABI BREAK =========== remove the `_Is_unordered` member from
`std::partial_ordering` in `<compare>` since (a) it's true if and only if the
stored value has a particular value, and (b) Clang expects all of the
comparison category types to have size 1,
* reorder all `is_transparent` alias declarations in the STL to be after the
corresponding `operator()` to agree with synopsis order.
Also adds a new test `P0896R4_P1614R2_comparisons` that exercises the above.
The ABI BREAK sounds scary - as it should - but note that:
* this is a `/std:c++latest` feature, which is subject to change,
* objects of comparison category type aren't typically stored,
* only MSVC has released `<compare>` so far, so it's not widely used.
Altogether, it's extremely unlikely that anyone has encoded this in ABI.
2020-02-19 04:38:40 +03:00
|
|
|
return 0 >= _Val._Value && _Val._Is_ordered();
|
2019-09-05 01:57:56 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef __cpp_impl_three_way_comparison
|
2019-11-01 03:37:56 +03:00
|
|
|
_NODISCARD friend constexpr partial_ordering operator<=>(const partial_ordering _Val, _Literal_zero) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return _Val;
|
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
_NODISCARD friend constexpr partial_ordering operator<=>(_Literal_zero, const partial_ordering _Val) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return partial_ordering{static_cast<_Compare_ord>(-_Val._Value)};
|
|
|
|
}
|
|
|
|
#endif // __cpp_impl_three_way_comparison
|
|
|
|
|
|
|
|
private:
|
<compare>,<functional> Concept-constrained comparisons (#385)
Includes:
* concepts `three_way_comparable` and `three_way_comparable_with`,
* type trait `std::compare_three_way_result` (with `_t` alias), and
* function object `compare_three_way`.
in `<compare>`, and:
* function objects `ranges::equal_to` and `ranges::less` (in `<xutility>` for
easy algorithm access), `ranges::not_equal_to`, `ranges::less_equal`,
`ranges::greater`, and `ranges::greater_equal` (in `<functional>`),
* slight refactoring of concept definitions in `<concepts>` to avoid redundant
requirements for the single-type comparison concepts `equality_comparable`,
`totally_ordered`, and `three_way_comparable`,
* heavy refactoring of the trait `common_comparison_category` (and `_t` alias)
in `<compare>` to requires only `n + c` template instantiations instead of `cn`
template instantiations,
* ======== ABI BREAK =========== remove the `_Is_unordered` member from
`std::partial_ordering` in `<compare>` since (a) it's true if and only if the
stored value has a particular value, and (b) Clang expects all of the
comparison category types to have size 1,
* reorder all `is_transparent` alias declarations in the STL to be after the
corresponding `operator()` to agree with synopsis order.
Also adds a new test `P0896R4_P1614R2_comparisons` that exercises the above.
The ABI BREAK sounds scary - as it should - but note that:
* this is a `/std:c++latest` feature, which is subject to change,
* objects of comparison category type aren't typically stored,
* only MSVC has released `<compare>` so far, so it's not widely used.
Altogether, it's extremely unlikely that anyone has encoded this in ABI.
2020-02-19 04:38:40 +03:00
|
|
|
_NODISCARD constexpr bool _Is_ordered() const noexcept {
|
|
|
|
return _Value != static_cast<_Compare_t>(_Compare_ncmp::unordered);
|
|
|
|
}
|
|
|
|
|
2019-09-05 01:57:56 +03:00
|
|
|
_Compare_t _Value;
|
|
|
|
};
|
|
|
|
|
|
|
|
inline constexpr partial_ordering partial_ordering::less(_Compare_ord::less);
|
|
|
|
inline constexpr partial_ordering partial_ordering::equivalent(_Compare_eq::equivalent);
|
|
|
|
inline constexpr partial_ordering partial_ordering::greater(_Compare_ord::greater);
|
|
|
|
inline constexpr partial_ordering partial_ordering::unordered(_Compare_ncmp::unordered);
|
|
|
|
|
|
|
|
// CLASS weak_ordering
|
|
|
|
class weak_ordering {
|
|
|
|
public:
|
2019-11-01 03:37:56 +03:00
|
|
|
_NODISCARD constexpr explicit weak_ordering(const _Compare_eq _Value_) noexcept
|
|
|
|
: _Value(static_cast<_Compare_t>(_Value_)) {}
|
|
|
|
_NODISCARD constexpr explicit weak_ordering(const _Compare_ord _Value_) noexcept
|
|
|
|
: _Value(static_cast<_Compare_t>(_Value_)) {}
|
2019-09-05 01:57:56 +03:00
|
|
|
|
|
|
|
static const weak_ordering less;
|
|
|
|
static const weak_ordering equivalent;
|
|
|
|
static const weak_ordering greater;
|
|
|
|
|
|
|
|
constexpr operator partial_ordering() const noexcept {
|
|
|
|
return partial_ordering{static_cast<_Compare_ord>(_Value)};
|
|
|
|
}
|
|
|
|
|
2019-11-01 03:37:56 +03:00
|
|
|
_NODISCARD friend constexpr bool operator==(const weak_ordering _Val, _Literal_zero) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return _Val._Value == 0;
|
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
2019-12-14 02:00:50 +03:00
|
|
|
#if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201902L
|
Allow Clang10 in the STL (#622)
* Allow Clang10 in the STL
This PR includes changes necessary to allow (but not require) clang 10 in the STL. It also includes test changes to allow the tests to pass given new clang warnings for deprecated behaviors, and an update to the LLVM reference to get similar changes that have been applied upstream to libc++ tests.
Details:
* In `<compare>`, remove workarounds for LLVM-41991 in Clang 10 RC1 fixed in RC2.
* In `<concepts>`, remove `_SILENCE_CLANG_CONCEPTS_MESSAGE`.
* In `<queue>` and `<stack>`, befriend only corresponding specializations of operator templates.
* In `<system_error>`, fix the `__cpp_constexpr_dynamic_alloc` implementation of `_Immortalize_memcpy_image` (which we apparently didn't review at all).
* In `<experimental/filesystem>`, apply a fix equivalent to the resolution of LWG-3244.
* Update `P0220R1_optional` from upstream.
* In `P0595R2_is_constant_evaluated`, silence Clang's warning for using `is_constant_evaluated` in a manifestly constant-evaluated context.
* In `P0896R4_ranges_iterator_machinery`, fix bogus test cases that were expecting VSO-1008447, silence "unused variable" warnings, and avoid taking advantage of too-lenient MSVC comparison rewrite behavior.
* In `P0896R4_ranges_range_machinery`, silence "unused variable" warning.
* In `P0898R3_concepts`, Remove workaround for LLVM-44627 in Clang 10 RC1 fixed in RC2.
* In `VSO_0000000_type_traits` and `tr1/type_traits5`, silence volatile function parameter deprecation warnings.
* In `tr1/condition_variable`, `tr1/regex1`, and `tr1/regex3`, remove unnecessary copy assignment operators that were prompting Clang warnings about the implicitly definition of a copy constructor for such a class being deprecated.
* In `tr1/csetjmp`, silence volatile increment deprecation warnings.
Skip new libc++ tests:
* Various `span` tests that expect `const_iterator` (libc++ doesn't yet implement LWG-3320)
* tests for the implementation of P1135R6 "The C++ Synchronization Library" which we do not yet implement
2020-03-20 02:42:55 +03:00
|
|
|
_NODISCARD friend constexpr bool operator==(const weak_ordering&, const weak_ordering&) noexcept = default;
|
2019-11-01 03:37:56 +03:00
|
|
|
#else // ^^^ supports <=> and P1185 / supports neither vvv
|
|
|
|
_NODISCARD friend constexpr bool operator!=(const weak_ordering _Val, _Literal_zero) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return _Val._Value != 0;
|
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
_NODISCARD friend constexpr bool operator==(_Literal_zero, const weak_ordering _Val) noexcept {
|
|
|
|
return 0 == _Val._Value;
|
|
|
|
}
|
|
|
|
|
|
|
|
_NODISCARD friend constexpr bool operator!=(_Literal_zero, const weak_ordering _Val) noexcept {
|
|
|
|
return 0 != _Val._Value;
|
|
|
|
}
|
2019-12-14 02:00:50 +03:00
|
|
|
#endif // defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201902L
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
_NODISCARD friend constexpr bool operator<(const weak_ordering _Val, _Literal_zero) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return _Val._Value < 0;
|
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
_NODISCARD friend constexpr bool operator>(const weak_ordering _Val, _Literal_zero) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return _Val._Value > 0;
|
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
_NODISCARD friend constexpr bool operator<=(const weak_ordering _Val, _Literal_zero) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return _Val._Value <= 0;
|
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
_NODISCARD friend constexpr bool operator>=(const weak_ordering _Val, _Literal_zero) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return _Val._Value >= 0;
|
|
|
|
}
|
|
|
|
|
2019-11-01 03:37:56 +03:00
|
|
|
_NODISCARD friend constexpr bool operator<(_Literal_zero, const weak_ordering _Val) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return 0 < _Val._Value;
|
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
_NODISCARD friend constexpr bool operator>(_Literal_zero, const weak_ordering _Val) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return 0 > _Val._Value;
|
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
_NODISCARD friend constexpr bool operator<=(_Literal_zero, const weak_ordering _Val) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return 0 <= _Val._Value;
|
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
_NODISCARD friend constexpr bool operator>=(_Literal_zero, const weak_ordering _Val) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return 0 >= _Val._Value;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef __cpp_impl_three_way_comparison
|
2019-11-01 03:37:56 +03:00
|
|
|
_NODISCARD friend constexpr weak_ordering operator<=>(const weak_ordering _Val, _Literal_zero) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return _Val;
|
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
_NODISCARD friend constexpr weak_ordering operator<=>(_Literal_zero, const weak_ordering _Val) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return weak_ordering{static_cast<_Compare_ord>(-_Val._Value)};
|
|
|
|
}
|
|
|
|
#endif // __cpp_impl_three_way_comparison
|
|
|
|
|
|
|
|
private:
|
|
|
|
_Compare_t _Value;
|
|
|
|
};
|
|
|
|
|
|
|
|
inline constexpr weak_ordering weak_ordering::less(_Compare_ord::less);
|
|
|
|
inline constexpr weak_ordering weak_ordering::equivalent(_Compare_eq::equivalent);
|
|
|
|
inline constexpr weak_ordering weak_ordering::greater(_Compare_ord::greater);
|
|
|
|
|
|
|
|
// CLASS strong_ordering
|
|
|
|
class strong_ordering {
|
|
|
|
public:
|
2019-11-01 03:37:56 +03:00
|
|
|
_NODISCARD constexpr explicit strong_ordering(const _Compare_eq _Value_) noexcept
|
|
|
|
: _Value(static_cast<_Compare_t>(_Value_)) {}
|
|
|
|
_NODISCARD constexpr explicit strong_ordering(const _Compare_ord _Value_) noexcept
|
2019-09-05 01:57:56 +03:00
|
|
|
: _Value(static_cast<_Compare_t>(_Value_)) {}
|
|
|
|
|
|
|
|
static const strong_ordering less;
|
|
|
|
static const strong_ordering equal;
|
|
|
|
static const strong_ordering equivalent;
|
|
|
|
static const strong_ordering greater;
|
|
|
|
|
|
|
|
constexpr operator partial_ordering() const noexcept {
|
|
|
|
return partial_ordering{static_cast<_Compare_ord>(_Value)};
|
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
2019-09-05 01:57:56 +03:00
|
|
|
constexpr operator weak_ordering() const noexcept {
|
|
|
|
return weak_ordering{static_cast<_Compare_ord>(_Value)};
|
|
|
|
}
|
|
|
|
|
2019-11-01 03:37:56 +03:00
|
|
|
_NODISCARD friend constexpr bool operator==(const strong_ordering _Val, _Literal_zero) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return _Val._Value == 0;
|
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
2019-12-14 02:00:50 +03:00
|
|
|
#if defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201902L
|
Allow Clang10 in the STL (#622)
* Allow Clang10 in the STL
This PR includes changes necessary to allow (but not require) clang 10 in the STL. It also includes test changes to allow the tests to pass given new clang warnings for deprecated behaviors, and an update to the LLVM reference to get similar changes that have been applied upstream to libc++ tests.
Details:
* In `<compare>`, remove workarounds for LLVM-41991 in Clang 10 RC1 fixed in RC2.
* In `<concepts>`, remove `_SILENCE_CLANG_CONCEPTS_MESSAGE`.
* In `<queue>` and `<stack>`, befriend only corresponding specializations of operator templates.
* In `<system_error>`, fix the `__cpp_constexpr_dynamic_alloc` implementation of `_Immortalize_memcpy_image` (which we apparently didn't review at all).
* In `<experimental/filesystem>`, apply a fix equivalent to the resolution of LWG-3244.
* Update `P0220R1_optional` from upstream.
* In `P0595R2_is_constant_evaluated`, silence Clang's warning for using `is_constant_evaluated` in a manifestly constant-evaluated context.
* In `P0896R4_ranges_iterator_machinery`, fix bogus test cases that were expecting VSO-1008447, silence "unused variable" warnings, and avoid taking advantage of too-lenient MSVC comparison rewrite behavior.
* In `P0896R4_ranges_range_machinery`, silence "unused variable" warning.
* In `P0898R3_concepts`, Remove workaround for LLVM-44627 in Clang 10 RC1 fixed in RC2.
* In `VSO_0000000_type_traits` and `tr1/type_traits5`, silence volatile function parameter deprecation warnings.
* In `tr1/condition_variable`, `tr1/regex1`, and `tr1/regex3`, remove unnecessary copy assignment operators that were prompting Clang warnings about the implicitly definition of a copy constructor for such a class being deprecated.
* In `tr1/csetjmp`, silence volatile increment deprecation warnings.
Skip new libc++ tests:
* Various `span` tests that expect `const_iterator` (libc++ doesn't yet implement LWG-3320)
* tests for the implementation of P1135R6 "The C++ Synchronization Library" which we do not yet implement
2020-03-20 02:42:55 +03:00
|
|
|
_NODISCARD friend constexpr bool operator==(const strong_ordering&, const strong_ordering&) noexcept = default;
|
2019-11-01 03:37:56 +03:00
|
|
|
#else // ^^^ supports <=> and P1185 / supports neither vvv
|
|
|
|
_NODISCARD friend constexpr bool operator!=(const strong_ordering _Val, _Literal_zero) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return _Val._Value != 0;
|
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
_NODISCARD friend constexpr bool operator==(_Literal_zero, const strong_ordering _Val) noexcept {
|
|
|
|
return 0 == _Val._Value;
|
|
|
|
}
|
|
|
|
|
|
|
|
_NODISCARD friend constexpr bool operator!=(_Literal_zero, const strong_ordering _Val) noexcept {
|
|
|
|
return 0 != _Val._Value;
|
|
|
|
}
|
2019-12-14 02:00:50 +03:00
|
|
|
#endif // defined(__cpp_impl_three_way_comparison) && __cpp_impl_three_way_comparison >= 201902L
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
_NODISCARD friend constexpr bool operator<(const strong_ordering _Val, _Literal_zero) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return _Val._Value < 0;
|
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
_NODISCARD friend constexpr bool operator>(const strong_ordering _Val, _Literal_zero) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return _Val._Value > 0;
|
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
_NODISCARD friend constexpr bool operator<=(const strong_ordering _Val, _Literal_zero) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return _Val._Value <= 0;
|
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
_NODISCARD friend constexpr bool operator>=(const strong_ordering _Val, _Literal_zero) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return _Val._Value >= 0;
|
|
|
|
}
|
|
|
|
|
2019-11-01 03:37:56 +03:00
|
|
|
_NODISCARD friend constexpr bool operator<(_Literal_zero, const strong_ordering _Val) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return 0 < _Val._Value;
|
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
_NODISCARD friend constexpr bool operator>(_Literal_zero, const strong_ordering _Val) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return 0 > _Val._Value;
|
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
_NODISCARD friend constexpr bool operator<=(_Literal_zero, const strong_ordering _Val) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return 0 <= _Val._Value;
|
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
_NODISCARD friend constexpr bool operator>=(_Literal_zero, const strong_ordering _Val) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return 0 >= _Val._Value;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef __cpp_impl_three_way_comparison
|
2019-11-01 03:37:56 +03:00
|
|
|
_NODISCARD friend constexpr strong_ordering operator<=>(const strong_ordering _Val, _Literal_zero) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return _Val;
|
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
_NODISCARD friend constexpr strong_ordering operator<=>(_Literal_zero, const strong_ordering _Val) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return strong_ordering{static_cast<_Compare_ord>(-_Val._Value)};
|
|
|
|
}
|
|
|
|
#endif // __cpp_impl_three_way_comparison
|
|
|
|
|
|
|
|
private:
|
|
|
|
_Compare_t _Value;
|
|
|
|
};
|
|
|
|
|
|
|
|
inline constexpr strong_ordering strong_ordering::less(_Compare_ord::less);
|
|
|
|
inline constexpr strong_ordering strong_ordering::equal(_Compare_eq::equal);
|
|
|
|
inline constexpr strong_ordering strong_ordering::equivalent(_Compare_eq::equivalent);
|
|
|
|
inline constexpr strong_ordering strong_ordering::greater(_Compare_ord::greater);
|
|
|
|
|
2019-11-01 03:37:56 +03:00
|
|
|
// FUNCTION is_eq
|
2019-12-14 02:00:50 +03:00
|
|
|
_NODISCARD constexpr bool is_eq(const partial_ordering _Comp) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return _Comp == 0;
|
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
// FUNCTION is_neq
|
2019-12-14 02:00:50 +03:00
|
|
|
_NODISCARD constexpr bool is_neq(const partial_ordering _Comp) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return _Comp != 0;
|
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
// FUNCTION is_lt
|
|
|
|
_NODISCARD constexpr bool is_lt(const partial_ordering _Comp) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return _Comp < 0;
|
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
// FUNCTION is_lteq
|
|
|
|
_NODISCARD constexpr bool is_lteq(const partial_ordering _Comp) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return _Comp <= 0;
|
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
// FUNCTION is_gt
|
|
|
|
_NODISCARD constexpr bool is_gt(const partial_ordering _Comp) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return _Comp > 0;
|
|
|
|
}
|
2019-11-01 03:37:56 +03:00
|
|
|
|
|
|
|
// FUNCTION is_gteq
|
|
|
|
_NODISCARD constexpr bool is_gteq(const partial_ordering _Comp) noexcept {
|
2019-09-05 01:57:56 +03:00
|
|
|
return _Comp >= 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ALIAS TEMPLATE common_comparison_category_t
|
<compare>,<functional> Concept-constrained comparisons (#385)
Includes:
* concepts `three_way_comparable` and `three_way_comparable_with`,
* type trait `std::compare_three_way_result` (with `_t` alias), and
* function object `compare_three_way`.
in `<compare>`, and:
* function objects `ranges::equal_to` and `ranges::less` (in `<xutility>` for
easy algorithm access), `ranges::not_equal_to`, `ranges::less_equal`,
`ranges::greater`, and `ranges::greater_equal` (in `<functional>`),
* slight refactoring of concept definitions in `<concepts>` to avoid redundant
requirements for the single-type comparison concepts `equality_comparable`,
`totally_ordered`, and `three_way_comparable`,
* heavy refactoring of the trait `common_comparison_category` (and `_t` alias)
in `<compare>` to requires only `n + c` template instantiations instead of `cn`
template instantiations,
* ======== ABI BREAK =========== remove the `_Is_unordered` member from
`std::partial_ordering` in `<compare>` since (a) it's true if and only if the
stored value has a particular value, and (b) Clang expects all of the
comparison category types to have size 1,
* reorder all `is_transparent` alias declarations in the STL to be after the
corresponding `operator()` to agree with synopsis order.
Also adds a new test `P0896R4_P1614R2_comparisons` that exercises the above.
The ABI BREAK sounds scary - as it should - but note that:
* this is a `/std:c++latest` feature, which is subject to change,
* objects of comparison category type aren't typically stored,
* only MSVC has released `<compare>` so far, so it's not widely used.
Altogether, it's extremely unlikely that anyone has encoded this in ABI.
2020-02-19 04:38:40 +03:00
|
|
|
enum _Comparison_category : unsigned char {
|
|
|
|
_Comparison_category_none = 1,
|
|
|
|
_Comparison_category_partial = 2,
|
|
|
|
_Comparison_category_weak = 4,
|
|
|
|
_Comparison_category_strong = 0,
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class... _Types>
|
|
|
|
inline constexpr unsigned char _Classify_category =
|
|
|
|
_Comparison_category{(_Classify_category<_Types> | ... | _Comparison_category_strong)};
|
2019-09-05 01:57:56 +03:00
|
|
|
template <class _Ty>
|
<compare>,<functional> Concept-constrained comparisons (#385)
Includes:
* concepts `three_way_comparable` and `three_way_comparable_with`,
* type trait `std::compare_three_way_result` (with `_t` alias), and
* function object `compare_three_way`.
in `<compare>`, and:
* function objects `ranges::equal_to` and `ranges::less` (in `<xutility>` for
easy algorithm access), `ranges::not_equal_to`, `ranges::less_equal`,
`ranges::greater`, and `ranges::greater_equal` (in `<functional>`),
* slight refactoring of concept definitions in `<concepts>` to avoid redundant
requirements for the single-type comparison concepts `equality_comparable`,
`totally_ordered`, and `three_way_comparable`,
* heavy refactoring of the trait `common_comparison_category` (and `_t` alias)
in `<compare>` to requires only `n + c` template instantiations instead of `cn`
template instantiations,
* ======== ABI BREAK =========== remove the `_Is_unordered` member from
`std::partial_ordering` in `<compare>` since (a) it's true if and only if the
stored value has a particular value, and (b) Clang expects all of the
comparison category types to have size 1,
* reorder all `is_transparent` alias declarations in the STL to be after the
corresponding `operator()` to agree with synopsis order.
Also adds a new test `P0896R4_P1614R2_comparisons` that exercises the above.
The ABI BREAK sounds scary - as it should - but note that:
* this is a `/std:c++latest` feature, which is subject to change,
* objects of comparison category type aren't typically stored,
* only MSVC has released `<compare>` so far, so it's not widely used.
Altogether, it's extremely unlikely that anyone has encoded this in ABI.
2020-02-19 04:38:40 +03:00
|
|
|
inline constexpr unsigned char _Classify_category<_Ty> = _Comparison_category_none;
|
|
|
|
template <>
|
|
|
|
inline constexpr unsigned char _Classify_category<partial_ordering> = _Comparison_category_partial;
|
|
|
|
template <>
|
|
|
|
inline constexpr unsigned char _Classify_category<weak_ordering> = _Comparison_category_weak;
|
|
|
|
template <>
|
|
|
|
inline constexpr unsigned char _Classify_category<strong_ordering> = _Comparison_category_strong;
|
|
|
|
|
|
|
|
template <class... _Types>
|
|
|
|
using common_comparison_category_t =
|
|
|
|
conditional_t<(_Classify_category<_Types...> & _Comparison_category_none) != 0, void,
|
|
|
|
conditional_t<(_Classify_category<_Types...> & _Comparison_category_partial) != 0, partial_ordering,
|
|
|
|
conditional_t<(_Classify_category<_Types...> & _Comparison_category_weak) != 0, weak_ordering,
|
|
|
|
strong_ordering>>>;
|
2019-09-05 01:57:56 +03:00
|
|
|
|
|
|
|
template <class... _Types>
|
|
|
|
struct common_comparison_category {
|
<compare>,<functional> Concept-constrained comparisons (#385)
Includes:
* concepts `three_way_comparable` and `three_way_comparable_with`,
* type trait `std::compare_three_way_result` (with `_t` alias), and
* function object `compare_three_way`.
in `<compare>`, and:
* function objects `ranges::equal_to` and `ranges::less` (in `<xutility>` for
easy algorithm access), `ranges::not_equal_to`, `ranges::less_equal`,
`ranges::greater`, and `ranges::greater_equal` (in `<functional>`),
* slight refactoring of concept definitions in `<concepts>` to avoid redundant
requirements for the single-type comparison concepts `equality_comparable`,
`totally_ordered`, and `three_way_comparable`,
* heavy refactoring of the trait `common_comparison_category` (and `_t` alias)
in `<compare>` to requires only `n + c` template instantiations instead of `cn`
template instantiations,
* ======== ABI BREAK =========== remove the `_Is_unordered` member from
`std::partial_ordering` in `<compare>` since (a) it's true if and only if the
stored value has a particular value, and (b) Clang expects all of the
comparison category types to have size 1,
* reorder all `is_transparent` alias declarations in the STL to be after the
corresponding `operator()` to agree with synopsis order.
Also adds a new test `P0896R4_P1614R2_comparisons` that exercises the above.
The ABI BREAK sounds scary - as it should - but note that:
* this is a `/std:c++latest` feature, which is subject to change,
* objects of comparison category type aren't typically stored,
* only MSVC has released `<compare>` so far, so it's not widely used.
Altogether, it's extremely unlikely that anyone has encoded this in ABI.
2020-02-19 04:38:40 +03:00
|
|
|
using type = common_comparison_category_t<_Types...>;
|
2019-09-05 01:57:56 +03:00
|
|
|
};
|
|
|
|
|
<compare>,<functional> Concept-constrained comparisons (#385)
Includes:
* concepts `three_way_comparable` and `three_way_comparable_with`,
* type trait `std::compare_three_way_result` (with `_t` alias), and
* function object `compare_three_way`.
in `<compare>`, and:
* function objects `ranges::equal_to` and `ranges::less` (in `<xutility>` for
easy algorithm access), `ranges::not_equal_to`, `ranges::less_equal`,
`ranges::greater`, and `ranges::greater_equal` (in `<functional>`),
* slight refactoring of concept definitions in `<concepts>` to avoid redundant
requirements for the single-type comparison concepts `equality_comparable`,
`totally_ordered`, and `three_way_comparable`,
* heavy refactoring of the trait `common_comparison_category` (and `_t` alias)
in `<compare>` to requires only `n + c` template instantiations instead of `cn`
template instantiations,
* ======== ABI BREAK =========== remove the `_Is_unordered` member from
`std::partial_ordering` in `<compare>` since (a) it's true if and only if the
stored value has a particular value, and (b) Clang expects all of the
comparison category types to have size 1,
* reorder all `is_transparent` alias declarations in the STL to be after the
corresponding `operator()` to agree with synopsis order.
Also adds a new test `P0896R4_P1614R2_comparisons` that exercises the above.
The ABI BREAK sounds scary - as it should - but note that:
* this is a `/std:c++latest` feature, which is subject to change,
* objects of comparison category type aren't typically stored,
* only MSVC has released `<compare>` so far, so it's not widely used.
Altogether, it's extremely unlikely that anyone has encoded this in ABI.
2020-02-19 04:38:40 +03:00
|
|
|
#if defined(__cpp_impl_three_way_comparison) && defined(__cpp_lib_concepts)
|
|
|
|
// clang-format off
|
|
|
|
template <class _Ty, class _Cat>
|
|
|
|
concept _Compares_as = same_as<common_comparison_category_t<_Ty, _Cat>, _Cat>;
|
|
|
|
|
|
|
|
template <class _Ty, class _Cat = partial_ordering>
|
|
|
|
concept three_way_comparable = _Half_equality_comparable<_Ty, _Ty> && _Half_ordered<_Ty, _Ty>
|
|
|
|
&& requires(const remove_reference_t<_Ty>& __a, const remove_reference_t<_Ty>& __b) {
|
|
|
|
{ __a <=> __b } -> _Compares_as<_Cat>;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class _Ty1, class _Ty2, class _Cat = partial_ordering>
|
|
|
|
concept three_way_comparable_with = three_way_comparable<_Ty1, _Cat> && three_way_comparable<_Ty2, _Cat>
|
|
|
|
&& common_reference_with<const remove_reference_t<_Ty1>&, const remove_reference_t<_Ty2>&>
|
|
|
|
&& three_way_comparable<common_reference_t<const remove_reference_t<_Ty1>&, const remove_reference_t<_Ty2>&>, _Cat>
|
|
|
|
&& _Weakly_equality_comparable_with<_Ty1, _Ty2> && _Partially_ordered_with<_Ty1, _Ty2>
|
|
|
|
&& requires(const remove_reference_t<_Ty1>& __t, const remove_reference_t<_Ty2>& __u) {
|
|
|
|
{ __t <=> __u } -> _Compares_as<_Cat>;
|
|
|
|
{ __u <=> __t } -> _Compares_as<_Cat>;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class _Ty1, class _Ty2 = _Ty1>
|
|
|
|
using compare_three_way_result_t =
|
|
|
|
decltype(_STD declval<const remove_reference_t<_Ty1>&>() <=> _STD declval<const remove_reference_t<_Ty2>&>());
|
|
|
|
|
|
|
|
template <class _Ty1, class _Ty2 = _Ty1>
|
|
|
|
struct compare_three_way_result {};
|
|
|
|
|
|
|
|
template <class _Ty1, class _Ty2>
|
|
|
|
requires requires { typename compare_three_way_result_t<_Ty1, _Ty2>; }
|
|
|
|
struct compare_three_way_result<_Ty1, _Ty2> {
|
|
|
|
using type = compare_three_way_result_t<_Ty1, _Ty2>;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct compare_three_way {
|
|
|
|
template <class _Ty1, class _Ty2>
|
|
|
|
requires three_way_comparable_with<_Ty1, _Ty2> // TRANSITION, GH-489
|
|
|
|
constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const
|
|
|
|
noexcept(noexcept(_STD forward<_Ty1>(_Left) <=> _STD forward<_Ty2>(_Right))) /* strengthened */ {
|
|
|
|
return _STD forward<_Ty1>(_Left) <=> _STD forward<_Ty2>(_Right);
|
|
|
|
}
|
|
|
|
|
|
|
|
using is_transparent = int;
|
|
|
|
};
|
|
|
|
// clang-format on
|
|
|
|
#endif // defined(__cpp_impl_three_way_comparison) && defined(__cpp_lib_concepts)
|
2019-09-05 01:57:56 +03:00
|
|
|
|
2019-11-01 03:37:56 +03:00
|
|
|
// Other components not yet implemented
|
2019-09-05 01:57:56 +03:00
|
|
|
_STD_END
|
|
|
|
|
|
|
|
#pragma pop_macro("new")
|
|
|
|
_STL_RESTORE_CLANG_WARNINGS
|
|
|
|
#pragma warning(pop)
|
|
|
|
#pragma pack(pop)
|
|
|
|
#endif // _HAS_CXX20
|
|
|
|
|
|
|
|
#endif // _STL_COMPILER_PREPROCESSOR
|
|
|
|
#endif // _COMPARE_
|