Skip to content

Commit b331f8d

Browse files
Don't include <bit> in <compare> (#3627)
1 parent 7eeef47 commit b331f8d

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

stl/inc/compare

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
_EMIT_STL_WARNING(STL4038, "The contents of <compare> are available only with C++20 or later.");
1414
#else // ^^^ !_HAS_CXX20 / _HAS_CXX20 vvv
1515
#ifdef __cpp_lib_concepts
16-
#include <bit>
1716
#include <concepts>
1817
#else // ^^^ __cpp_lib_concepts / !__cpp_lib_concepts vvv
1918
#include <xtr1common>
@@ -427,8 +426,8 @@ namespace _Strong_order {
427426
using _Uint_type = typename _Traits::_Uint_type;
428427
using _Sint_type = make_signed_t<_Uint_type>;
429428

430-
const auto _Left_uint = _STD bit_cast<_Uint_type>(_Left);
431-
const auto _Right_uint = _STD bit_cast<_Uint_type>(_Right);
429+
const auto _Left_uint = _Bit_cast<_Uint_type>(_Left);
430+
const auto _Right_uint = _Bit_cast<_Uint_type>(_Right);
432431

433432
// 1. Ultra-fast path: equal representations are equal.
434433
if (_Left_uint == _Right_uint) {
@@ -534,8 +533,8 @@ namespace _Weak_order {
534533
using _Uint_type = typename _Traits::_Uint_type;
535534
using _Sint_type = make_signed_t<_Uint_type>;
536535

537-
auto _Left_uint = _STD bit_cast<_Uint_type>(_Left);
538-
auto _Right_uint = _STD bit_cast<_Uint_type>(_Right);
536+
auto _Left_uint = _Bit_cast<_Uint_type>(_Left);
537+
auto _Right_uint = _Bit_cast<_Uint_type>(_Right);
539538

540539
// 1. Ultra-fast path: equal representations are equivalent.
541540
if (_Left_uint == _Right_uint) {

stl/inc/format

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ _EMIT_STL_WARNING(STL4038, "The contents of <format> are available only with C++
4444
#else // ^^^ !defined(__cpp_lib_concepts) / defined(__cpp_lib_concepts) vvv
4545

4646
#include <__msvc_format_ucd_tables.hpp>
47+
#include <bit>
4748
#include <charconv>
4849
#include <concepts>
4950
#include <cstdint>
@@ -1982,7 +1983,7 @@ private:
19821983
template <class _Ty>
19831984
_NODISCARD static auto _Get_value_from_memory(const unsigned char* const _Val) noexcept {
19841985
auto& _Temp = *reinterpret_cast<const unsigned char(*)[sizeof(_Ty)]>(_Val);
1985-
return _Bit_cast<_Ty>(_Temp);
1986+
return _STD bit_cast<_Ty>(_Temp);
19861987
}
19871988

19881989
size_t _Num_args = 0;

stl/inc/type_traits

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2344,6 +2344,14 @@ struct _Floating_type_traits<long double> : _Floating_type_traits<double> {};
23442344

23452345
// ^^^^^^^^^^ DERIVED FROM corecrt_internal_fltintrn.h ^^^^^^^^^^
23462346

2347+
template <class _To, class _From,
2348+
enable_if_t<conjunction_v<bool_constant<sizeof(_To) == sizeof(_From)>, is_trivially_copyable<_To>,
2349+
is_trivially_copyable<_From>>,
2350+
int> = 0>
2351+
_NODISCARD constexpr _To _Bit_cast(const _From& _Val) noexcept {
2352+
return __builtin_bit_cast(_To, _Val);
2353+
}
2354+
23472355
#if _HAS_TR1_NAMESPACE
23482356
_STL_DISABLE_DEPRECATED_WARNING
23492357
namespace _DEPRECATE_TR1_NAMESPACE tr1 {

stl/inc/xutility

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,6 @@ _Ty* __std_max_element(_Ty* _First, _Ty* _Last) noexcept {
186186

187187
_STD_BEGIN
188188

189-
template <class _To, class _From,
190-
enable_if_t<conjunction_v<bool_constant<sizeof(_To) == sizeof(_From)>, is_trivially_copyable<_To>,
191-
is_trivially_copyable<_From>>,
192-
int> = 0>
193-
_NODISCARD constexpr _To _Bit_cast(const _From& _Val) noexcept {
194-
return __builtin_bit_cast(_To, _Val);
195-
}
196-
197189
template <class _Ty>
198190
struct _Get_first_parameter;
199191

0 commit comments

Comments
 (0)