Skip to content

Commit

Permalink
Cleanup product code uses of feature-test macros (#3053)
Browse files Browse the repository at this point in the history
Co-authored-by: Stephan T. Lavavej <[email protected]>
  • Loading branch information
CaseyCarter and StephanTLavavej authored Aug 27, 2022
1 parent 473245c commit 05e5e68
Show file tree
Hide file tree
Showing 25 changed files with 187 additions and 192 deletions.
13 changes: 5 additions & 8 deletions stl/inc/chrono
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,9 @@

#ifdef __cpp_lib_concepts
#include <concepts>
#endif // defined(__cpp_lib_concepts)

#ifdef __cpp_lib_format
#include <format>
#include <iomanip>
#endif // defined(__cpp_lib_format)
#endif // __cpp_lib_concepts
#endif // _HAS_CXX20

#pragma pack(push, _CRT_PACKING)
Expand Down Expand Up @@ -1683,7 +1680,7 @@ namespace chrono {
: runtime_error(_Make_string(_Tp, _Info)) {}

private:
#ifdef __cpp_lib_format
#ifdef __cpp_lib_concepts
template <class _Duration>
_NODISCARD static string _Make_string(const local_time<_Duration>& _Tp, const local_info& _Info);
#else // ^^^ no workaround / workaround vvv
Expand All @@ -1706,7 +1703,7 @@ namespace chrono {
: runtime_error(_Make_string(_Tp, _Info)) {}

private:
#ifdef __cpp_lib_format
#ifdef __cpp_lib_concepts
template <class _Duration>
_NODISCARD static string _Make_string(const local_time<_Duration>& _Tp, const local_info& _Info);
#else // ^^^ no workaround / workaround vvv
Expand Down Expand Up @@ -4653,7 +4650,7 @@ namespace chrono {
}
} // namespace chrono

#ifdef __cpp_lib_format
#ifdef __cpp_lib_concepts
// [time.format]

template <class _CharT>
Expand Down Expand Up @@ -5984,7 +5981,7 @@ namespace chrono {
return _STD move(_Os).str();
}
} // namespace chrono
#endif // __cpp_lib_format
#endif // __cpp_lib_concepts

inline namespace literals {
inline namespace chrono_literals {
Expand Down
24 changes: 12 additions & 12 deletions stl/inc/deque
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ public:
_Proxy._Release();
}

#ifdef __cpp_lib_containers_ranges
#if _HAS_CXX23 && defined(__cpp_lib_concepts) // TRANSITION, GH-395
template <_Container_compatible_range<_Ty> _Rng>
deque(from_range_t, _Rng&& _Range) : _Mypair(_Zero_then_variadic_args_t{}) {
_Alproxy_ty _Alproxy(_Getal());
Expand All @@ -689,7 +689,7 @@ public:
_Construct(_RANGES _Ubegin(_Range), _RANGES _Uend(_Range));
_Proxy._Release();
}
#endif // __cpp_lib_containers_ranges
#endif // _HAS_CXX23 && defined(__cpp_lib_concepts)

private:
template <class _Iter, class _Sent>
Expand Down Expand Up @@ -790,7 +790,7 @@ public:
emplace_front(_STD move(_Val));
}

#ifdef __cpp_lib_containers_ranges
#if _HAS_CXX23 && defined(__cpp_lib_concepts) // TRANSITION, GH-395
template <_Container_compatible_range<_Ty> _Rng>
void prepend_range(_Rng&& _Range) {
_Orphan_all();
Expand All @@ -815,14 +815,14 @@ public:
}
_Guard._Container = nullptr;
}
#endif // __cpp_lib_containers_ranges
#endif // _HAS_CXX23 && defined(__cpp_lib_concepts)

void push_back(_Ty&& _Val) {
_Orphan_all();
_Emplace_back_internal(_STD move(_Val));
}

#ifdef __cpp_lib_containers_ranges
#if _HAS_CXX23 && defined(__cpp_lib_concepts) // TRANSITION, GH-395
template <_Container_compatible_range<_Ty> _Rng>
void append_range(_Rng&& _Range) {
_Orphan_all();
Expand All @@ -837,7 +837,7 @@ public:
}
_Guard._Container = nullptr;
}
#endif // __cpp_lib_containers_ranges
#endif // _HAS_CXX23 && defined(__cpp_lib_concepts)

iterator insert(const_iterator _Where, _Ty&& _Val) {
return emplace(_Where, _STD move(_Val));
Expand Down Expand Up @@ -1240,12 +1240,12 @@ public:
_Assign_range(_Get_unwrapped(_First), _Get_unwrapped(_Last));
}

#ifdef __cpp_lib_containers_ranges
#if _HAS_CXX23 && defined(__cpp_lib_concepts) // TRANSITION, GH-395
template <_Container_compatible_range<_Ty> _Rng>
void assign_range(_Rng&& _Range) {
_Assign_range(_RANGES _Ubegin(_Range), _RANGES _Uend(_Range));
}
#endif // __cpp_lib_containers_ranges
#endif // _HAS_CXX23 && defined(__cpp_lib_concepts)

void assign(_CRT_GUARDOVERFLOW size_type _Count, const _Ty& _Val) { // assign _Count * _Val
_Orphan_all();
Expand Down Expand Up @@ -1381,7 +1381,7 @@ public:
_Off, _Get_unwrapped(_First), _Get_unwrapped(_Last));
}

#ifdef __cpp_lib_containers_ranges
#if _HAS_CXX23 && defined(__cpp_lib_concepts) // TRANSITION, GH-395
template <_Container_compatible_range<_Ty> _Rng>
iterator insert_range(const_iterator _Where, _Rng&& _Range) {
const size_type _Off = static_cast<size_type>(_Where - begin());
Expand All @@ -1393,7 +1393,7 @@ public:
return _Insert_range<_Is_bidi::_No>(_Off, _RANGES _Ubegin(_Range), _RANGES _Uend(_Range));
}
}
#endif // __cpp_lib_containers_ranges
#endif // _HAS_CXX23 && defined(__cpp_lib_concepts)

iterator erase(const_iterator _Where) noexcept(is_nothrow_move_assignable_v<value_type>) /* strengthened */ {
return erase(_Where, _Next_iter(_Where));
Expand Down Expand Up @@ -1690,11 +1690,11 @@ template <class _Iter, class _Alloc = allocator<_Iter_value_t<_Iter>>,
deque(_Iter, _Iter, _Alloc = _Alloc()) -> deque<_Iter_value_t<_Iter>, _Alloc>;
#endif // _HAS_CXX17

#ifdef __cpp_lib_containers_ranges
#if _HAS_CXX23 && defined(__cpp_lib_concepts) // TRANSITION, GH-395
template <_RANGES input_range _Rng, class _Alloc = allocator<_RANGES range_value_t<_Rng>>,
enable_if_t<_Is_allocator<_Alloc>::value, int> = 0>
deque(from_range_t, _Rng&&, _Alloc = _Alloc()) -> deque<_RANGES range_value_t<_Rng>, _Alloc>;
#endif // __cpp_lib_containers_ranges
#endif // _HAS_CXX23 && defined(__cpp_lib_concepts)

template <class _Ty, class _Alloc>
void swap(deque<_Ty, _Alloc>& _Left, deque<_Ty, _Alloc>& _Right) noexcept /* strengthened */ {
Expand Down
6 changes: 3 additions & 3 deletions stl/inc/expected
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#define _EXPECTED_
#include <yvals.h>
#if _STL_COMPILER_PREPROCESSOR
#ifndef __cpp_lib_expected
#if !_HAS_CXX23 || !defined(__cpp_lib_concepts) // TRANSITION, GH-395
_EMIT_STL_WARNING(STL4038, "The contents of <expected> are available only with C++23 or later.");
#else // ^^^ !__cpp_lib_expected / __cpp_lib_expected vvv
#else // ^^^ not supported / supported language mode vvv
#include <exception>
#include <initializer_list>
#include <type_traits>
Expand Down Expand Up @@ -1083,6 +1083,6 @@ _STD_END
_STL_RESTORE_CLANG_WARNINGS
#pragma warning(pop)
#pragma pack(pop)
#endif // __cpp_lib_expected
#endif // ^^^ supported language mode ^^^
#endif // _STL_COMPILER_PREPROCESSOR
#endif // _EXPECTED_
6 changes: 3 additions & 3 deletions stl/inc/format
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
#define _FORMAT_
#include <yvals_core.h>
#if _STL_COMPILER_PREPROCESSOR
#ifndef __cpp_lib_format
#ifndef __cpp_lib_concepts
_EMIT_STL_WARNING(STL4038, "The contents of <format> are available only with C++20 or later.");
#else // ^^^ !defined(__cpp_lib_format) / defined(__cpp_lib_format) vvv
#else // ^^^ !defined(__cpp_lib_concepts) / defined(__cpp_lib_concepts) vvv

#include <__msvc_format_ucd_tables.hpp>
#include <algorithm>
Expand Down Expand Up @@ -3606,6 +3606,6 @@ _STL_RESTORE_CLANG_WARNINGS
#pragma warning(pop)
#pragma pack(pop)

#endif // __cpp_lib_format
#endif // __cpp_lib_concepts
#endif // _STL_COMPILER_PREPROCESSOR
#endif // _FORMAT_
20 changes: 10 additions & 10 deletions stl/inc/forward_list
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ public:
_Insert_op._Attach_after(_Mypair._Myval2._Before_head());
}

#ifdef __cpp_lib_containers_ranges
#if _HAS_CXX23 && defined(__cpp_lib_concepts) // TRANSITION, GH-395
template <_Container_compatible_range<_Ty> _Rng>
forward_list(from_range_t, _Rng&& _Range) : _Mypair(_Zero_then_variadic_args_t{}) {
_Flist_insert_after_op2<_Alnode> _Insert_op(_Getal());
Expand All @@ -623,7 +623,7 @@ public:
_Alloc_proxy();
_Insert_op._Attach_after(_Mypair._Myval2._Before_head());
}
#endif // __cpp_lib_containers_ranges
#endif // _HAS_CXX23 && defined(__cpp_lib_concepts)

forward_list(forward_list&& _Right) noexcept // strengthened
: _Mypair(_One_then_variadic_args_t{}, _STD move(_Right._Getal())) {
Expand Down Expand Up @@ -915,12 +915,12 @@ public:
_Insert_after(_Mypair._Myval2._Before_head(), _Val);
}

#ifdef __cpp_lib_containers_ranges
#if _HAS_CXX23 && defined(__cpp_lib_concepts) // TRANSITION, GH-395
template <_Container_compatible_range<_Ty> _Rng>
void prepend_range(_Rng&& _Range) {
_Insert_range_after(_Mypair._Myval2._Before_head(), _RANGES _Ubegin(_Range), _RANGES _Uend(_Range));
}
#endif // __cpp_lib_containers_ranges
#endif // _HAS_CXX23 && defined(__cpp_lib_concepts)

void pop_front() noexcept /* strengthened */ {
_Erase_after(_Mypair._Myval2._Before_head());
Expand Down Expand Up @@ -960,12 +960,12 @@ public:
_Assign_unchecked(_Get_unwrapped(_First), _Get_unwrapped(_Last));
}

#ifdef __cpp_lib_containers_ranges
#if _HAS_CXX23 && defined(__cpp_lib_concepts) // TRANSITION, GH-395
template <_Container_compatible_range<_Ty> _Rng>
void assign_range(_Rng&& _Range) {
_Assign_unchecked(_RANGES _Ubegin(_Range), _RANGES _Uend(_Range));
}
#endif // __cpp_lib_containers_ranges
#endif // _HAS_CXX23 && defined(__cpp_lib_concepts)

void assign(_CRT_GUARDOVERFLOW size_type _Count, const _Ty& _Val) {
clear();
Expand Down Expand Up @@ -1022,7 +1022,7 @@ public:
return _Insert_range_after(_Where._Ptr, _Get_unwrapped(_First), _Get_unwrapped(_Last));
}

#ifdef __cpp_lib_containers_ranges
#if _HAS_CXX23 && defined(__cpp_lib_concepts) // TRANSITION, GH-395
template <_Container_compatible_range<_Ty> _Rng>
iterator insert_range_after(const_iterator _Where, _Rng&& _Range) {
#if _ITERATOR_DEBUG_LEVEL == 2
Expand All @@ -1031,7 +1031,7 @@ public:
#endif // _ITERATOR_DEBUG_LEVEL == 2
return _Insert_range_after(_Where._Ptr, _RANGES _Ubegin(_Range), _RANGES _Uend(_Range));
}
#endif // __cpp_lib_containers_ranges
#endif // _HAS_CXX23 && defined(__cpp_lib_concepts)

private:
void _Erase_after(_Nodeptr _Pnode) noexcept { // erase element after _Pnode
Expand Down Expand Up @@ -1555,11 +1555,11 @@ template <class _Iter, class _Alloc = allocator<_Iter_value_t<_Iter>>,
forward_list(_Iter, _Iter, _Alloc = _Alloc()) -> forward_list<_Iter_value_t<_Iter>, _Alloc>;
#endif // _HAS_CXX17

#ifdef __cpp_lib_containers_ranges
#if _HAS_CXX23 && defined(__cpp_lib_concepts) // TRANSITION, GH-395
template <_RANGES input_range _Rng, class _Alloc = allocator<_RANGES range_value_t<_Rng>>,
enable_if_t<_Is_allocator<_Alloc>::value, int> = 0>
forward_list(from_range_t, _Rng&&, _Alloc = _Alloc()) -> forward_list<_RANGES range_value_t<_Rng>, _Alloc>;
#endif // __cpp_lib_containers_ranges
#endif // _HAS_CXX23 && defined(__cpp_lib_concepts)

template <class _Ty, class _Alloc>
void swap(forward_list<_Ty, _Alloc>& _Left, forward_list<_Ty, _Alloc>& _Right) noexcept /* strengthened */ {
Expand Down
24 changes: 12 additions & 12 deletions stl/inc/list
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ public:
_Construct_range_unchecked(_Get_unwrapped(_First), _Get_unwrapped(_Last));
}

#ifdef __cpp_lib_containers_ranges
#if _HAS_CXX23 && defined(__cpp_lib_concepts) // TRANSITION, GH-395
template <_Container_compatible_range<_Ty> _Rng>
list(from_range_t, _Rng&& _Range) : _Mypair(_Zero_then_variadic_args_t{}) {
_Construct_range_unchecked(_RANGES _Ubegin(_Range), _RANGES _Uend(_Range));
Expand All @@ -892,7 +892,7 @@ public:
list(from_range_t, _Rng&& _Range, const _Alloc& _Al) : _Mypair(_One_then_variadic_args_t{}, _Al) {
_Construct_range_unchecked(_RANGES _Ubegin(_Range), _RANGES _Uend(_Range));
}
#endif // __cpp_lib_containers_ranges
#endif // _HAS_CXX23 && defined(__cpp_lib_concepts)

list(list&& _Right) : _Mypair(_One_then_variadic_args_t{}, _STD move(_Right._Getal())) {
_Alloc_sentinel_and_proxy();
Expand Down Expand Up @@ -1235,14 +1235,14 @@ public:
_Emplace(_Mypair._Myval2._Myhead->_Next, _Val);
}

#ifdef __cpp_lib_containers_ranges
#if _HAS_CXX23 && defined(__cpp_lib_concepts) // TRANSITION, GH-395
template <_Container_compatible_range<_Ty> _Rng>
void prepend_range(_Rng&& _Range) {
_List_node_insert_op2<_Alnode> _Op(_Getal());
_Op._Append_range_unchecked(_RANGES _Ubegin(_Range), _RANGES _Uend(_Range));
_Op._Attach_before(_Mypair._Myval2, _Mypair._Myval2._Myhead->_Next);
}
#endif // __cpp_lib_containers_ranges
#endif // _HAS_CXX23 && defined(__cpp_lib_concepts)

void pop_front() noexcept /* strengthened */ {
#if _CONTAINER_DEBUG_LEVEL > 0
Expand All @@ -1256,14 +1256,14 @@ public:
_Emplace(_Mypair._Myval2._Myhead, _Val);
}

#ifdef __cpp_lib_containers_ranges
#if _HAS_CXX23 && defined(__cpp_lib_concepts) // TRANSITION, GH-395
template <_Container_compatible_range<_Ty> _Rng>
void append_range(_Rng&& _Range) {
_List_node_insert_op2<_Alnode> _Op(_Getal());
_Op._Append_range_unchecked(_RANGES _Ubegin(_Range), _RANGES _Uend(_Range));
_Op._Attach_at_end(_Mypair._Myval2);
}
#endif // __cpp_lib_containers_ranges
#endif // _HAS_CXX23 && defined(__cpp_lib_concepts)

void pop_back() noexcept /* strengthened */ {
#if _CONTAINER_DEBUG_LEVEL > 0
Expand Down Expand Up @@ -1333,12 +1333,12 @@ public:
_Assign_unchecked(_Get_unwrapped(_First), _Get_unwrapped(_Last));
}

#ifdef __cpp_lib_containers_ranges
#if _HAS_CXX23 && defined(__cpp_lib_concepts) // TRANSITION, GH-395
template <_Container_compatible_range<_Ty> _Rng>
void assign_range(_Rng&& _Range) {
_Assign_unchecked(_RANGES _Ubegin(_Range), _RANGES _Uend(_Range));
}
#endif // __cpp_lib_containers_ranges
#endif // _HAS_CXX23 && defined(__cpp_lib_concepts)

void assign(_CRT_GUARDOVERFLOW size_type _Count, const _Ty& _Val) { // assign _Count * _Val
const auto _Myend = _Mypair._Myval2._Myhead;
Expand Down Expand Up @@ -1392,7 +1392,7 @@ public:
return _Make_iter(_Op._Attach_before(_Mypair._Myval2, _Where._Ptr));
}

#ifdef __cpp_lib_containers_ranges
#if _HAS_CXX23 && defined(__cpp_lib_concepts) // TRANSITION, GH-395
template <_Container_compatible_range<_Ty> _Rng>
iterator insert_range(const_iterator _Where, _Rng&& _Range) {
#if _ITERATOR_DEBUG_LEVEL == 2
Expand All @@ -1402,7 +1402,7 @@ public:
_Op._Append_range_unchecked(_RANGES _Ubegin(_Range), _RANGES _Uend(_Range));
return _Make_iter(_Op._Attach_before(_Mypair._Myval2, _Where._Ptr));
}
#endif // __cpp_lib_containers_ranges
#endif // _HAS_CXX23 && defined(__cpp_lib_concepts)

iterator erase(const const_iterator _Where) noexcept /* strengthened */ {
#if _ITERATOR_DEBUG_LEVEL == 2
Expand Down Expand Up @@ -1858,11 +1858,11 @@ template <class _Iter, class _Alloc = allocator<_Iter_value_t<_Iter>>,
list(_Iter, _Iter, _Alloc = _Alloc()) -> list<_Iter_value_t<_Iter>, _Alloc>;
#endif // _HAS_CXX17

#ifdef __cpp_lib_containers_ranges
#if _HAS_CXX23 && defined(__cpp_lib_concepts) // TRANSITION, GH-395
template <_RANGES input_range _Rng, class _Alloc = allocator<_RANGES range_value_t<_Rng>>,
enable_if_t<_Is_allocator<_Alloc>::value, int> = 0>
list(from_range_t, _Rng&&, _Alloc = _Alloc()) -> list<_RANGES range_value_t<_Rng>, _Alloc>;
#endif // __cpp_lib_containers_ranges
#endif // _HAS_CXX23 && defined(__cpp_lib_concepts)

template <class _Ty, class _Alloc>
void swap(list<_Ty, _Alloc>& _Left, list<_Ty, _Alloc>& _Right) noexcept /* strengthened */ {
Expand Down
Loading

0 comments on commit 05e5e68

Please sign in to comment.