Skip to content

Commit

Permalink
Enable __cpp_lib_concepts for EDG, part 1 (#4296)
Browse files Browse the repository at this point in the history
Co-authored-by: Casey Carter <[email protected]>
Co-authored-by: Stephan T. Lavavej <[email protected]>
  • Loading branch information
3 people authored Feb 1, 2024
1 parent 202e382 commit 446444e
Show file tree
Hide file tree
Showing 34 changed files with 214 additions and 186 deletions.
4 changes: 4 additions & 0 deletions stl/inc/memory
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,11 @@ namespace ranges {
noexcept(noexcept(::new (static_cast<void*>(_Location))
_Ty(_STD forward<_Types>(_Args)...))) /* strengthened */ {
// clang-format on
#ifdef __EDG__
return _STD construct_at(_Location, _STD forward<_Types>(_Args)...);
#else // ^^^ EDG / Other vvv
_MSVC_CONSTEXPR return ::new (static_cast<void*>(_Location)) _Ty(_STD forward<_Types>(_Args)...);
#endif // ^^^ Other ^^^
}
};

Expand Down
10 changes: 9 additions & 1 deletion stl/inc/ranges
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,17 @@ namespace ranges {
template <sized_range _Ty>
inline constexpr auto _Compile_time_max_size<_Ty> = (numeric_limits<range_size_t<_Ty>>::max)();

#ifdef __EDG__ // TRANSITION, VSO-1898880
template <class _Ty>
concept _Constant_sized_range = sized_range<_Ty> && requires { typename _Require_constant<_Ty::size()>; };

template <_Constant_sized_range _Ty>
inline constexpr auto _Compile_time_max_size<_Ty> = _Ty::size();
#else // ^^^ workaround / no workaround vvv
template <sized_range _Ty>
requires requires { typename _Require_constant<_Ty::size()>; }
inline constexpr auto _Compile_time_max_size<_Ty> = _Ty::size();
#endif // ^^^ no workaround ^^^

template <class _Ty, size_t _Size>
inline constexpr auto _Compile_time_max_size<_Ty[_Size]> = _Size;
Expand Down Expand Up @@ -9768,7 +9776,7 @@ namespace ranges {
template <class _Rng>
_NODISCARD consteval int _Cartesian_product_max_size_bit_width() {
using _Size_type = decltype(_Compile_time_max_size<_Rng>);
if constexpr (requires(_Size_type _Val) { _STD bit_width(_Val); }) {
if constexpr (requires { _STD bit_width(_Compile_time_max_size<_Rng>); }) {
return _STD bit_width(_Compile_time_max_size<_Rng>);
} else {
return numeric_limits<_Size_type>::digits;
Expand Down
12 changes: 6 additions & 6 deletions stl/inc/tuple
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ template <class... _Types, class _Other, size_t... _Indices>
inline constexpr bool _Can_construct_values_from_tuple_like_v<tuple<_Types...>, _Other, index_sequence<_Indices...>> =
conjunction_v<is_constructible<_Types, decltype(_STD get<_Indices>(_STD declval<_Other>()))>...>;

#ifdef __clang__ // TRANSITION, LLVM-59827
#if defined(__clang__) || defined(__EDG__) // TRANSITION, LLVM-59827 and VSO-1900279
template <class _TupleLike, class _Tuple>
concept _Can_construct_from_tuple_like =
_Different_from<_TupleLike, _Tuple> && _Tuple_like<_TupleLike> && !_Is_subrange_v<remove_cvref_t<_TupleLike>>
Expand All @@ -195,16 +195,16 @@ concept _Can_construct_from_tuple_like =
&& (tuple_size_v<_Tuple> != 1
|| (!is_convertible_v<_TupleLike, tuple_element_t<0, _Tuple>>
&& !is_constructible_v<tuple_element_t<0, _Tuple>, _TupleLike>) );
#endif // defined(__clang__)
#endif // defined(__clang__) || defined(__EDG__)

template <class _TTuple, class _UTuple, class _Indices = make_index_sequence<tuple_size_v<_UTuple>>>
struct _Three_way_comparison_result_with_tuple_like {};

template <class... _TTypes, class _UTuple, size_t... _Indices>
requires
#ifndef __clang__ // TRANSITION, DevCom-10265237
#if !defined(__clang__) && !defined(__EDG__) // TRANSITION, DevCom-10265237
(sizeof...(_TTypes) == sizeof...(_Indices)) &&
#endif // !defined(__clang__)
#endif // ^^^ workaround ^^^
(requires { typename _Synth_three_way_result<_TTypes, tuple_element_t<_Indices, _UTuple>>; } && ...)
struct _Three_way_comparison_result_with_tuple_like<tuple<_TTypes...>, _UTuple, index_sequence<_Indices...>> {
using type = common_comparison_category_t<_Synth_three_way_result<_TTypes, tuple_element_t<_Indices, _UTuple>>...>;
Expand Down Expand Up @@ -432,7 +432,7 @@ public:
negation_v<conjunction<is_convertible<decltype(_STD get<0>(_STD declval<_Other>())), _This>,
is_convertible<decltype(_STD get<_Indices + 1>(_STD declval<_Other>())), _Rest>...>>;

#ifdef __clang__ // TRANSITION, LLVM-59827
#if defined(__clang__) || defined(__EDG__) // TRANSITION, LLVM-59827 and VSO-1900279
template <class _Other, enable_if_t<_Can_construct_from_tuple_like<_Other, tuple>, int> = 0>
#else // ^^^ workaround / no workaround vvv
template <_Different_from<tuple> _Other>
Expand Down Expand Up @@ -540,7 +540,7 @@ public:
: tuple(_Alloc_unpack_tuple_t{}, _Al, _STD move(_Right)) {}

#ifdef __cpp_lib_concepts
#ifdef __clang__ // TRANSITION, LLVM-59827
#if defined(__clang__) || defined(__EDG__) // TRANSITION, LLVM-59827 and VSO-1900279
template <class _Alloc, class _Other, enable_if_t<_Can_construct_from_tuple_like<_Other, tuple>, int> = 0>
#else // ^^^ workaround / no workaround vvv
template <class _Alloc, _Different_from<tuple> _Other>
Expand Down
6 changes: 3 additions & 3 deletions stl/inc/utility
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,12 @@ concept _Tuple_like = _Tuple_like_impl<remove_cvref_t<_Ty>>;
template <class _Ty>
concept _Pair_like = _Tuple_like<_Ty> && tuple_size_v<remove_cvref_t<_Ty>> == 2;

#ifdef __clang__ // TRANSITION, LLVM-59827
#if defined(__clang__) || defined(__EDG__) // TRANSITION, LLVM-59827 and VSO-1900279
template <class _PairLike, class _Ty1, class _Ty2>
concept _Can_construct_from_pair_like = _Pair_like<_PairLike> && !_Is_subrange_v<remove_cvref_t<_PairLike>>
&& is_constructible_v<_Ty1, decltype(_STD get<0>(_STD declval<_PairLike>()))>
&& is_constructible_v<_Ty2, decltype(_STD get<1>(_STD declval<_PairLike>()))>;
#endif // defined(__clang__)
#endif // defined(__clang__) || defined(__EDG__)
#endif // _HAS_CXX23
#endif // defined(__cpp_lib_concepts)

Expand Down Expand Up @@ -289,7 +289,7 @@ struct pair { // store a pair of values
: first(_STD forward<const _Other1>(_Right.first)), second(_STD forward<const _Other2>(_Right.second)) {}

#ifdef __cpp_lib_concepts
#ifdef __clang__ // TRANSITION, LLVM-59827
#if defined(__clang__) || defined(__EDG__) // TRANSITION, LLVM-59827 and VSO-1900279
template <class _Other, enable_if_t<_Can_construct_from_pair_like<_Other, _Ty1, _Ty2>, int> = 0>
#else // ^^^ workaround / no workaround vvv
template <_Pair_like _Other>
Expand Down
8 changes: 4 additions & 4 deletions stl/inc/xutility
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ struct _Get_rebind_alias<_Ty, _Other, void_t<typename _Ty::template rebind<_Othe
};

#if _HAS_CXX20
#ifdef __EDG__ // TRANSITION, DevCom-1691516
#if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-1691516
// per LWG-3888
_EXPORT_STD template <class _Ty, class... _Types,
class = void_t<decltype(::new(static_cast<void*>(_STD declval<_Ty*>())) _Ty(_STD declval<_Types>()...))>>
Expand Down Expand Up @@ -3972,6 +3972,9 @@ struct _Move_iterator_category {

_EXPORT_STD template <class _Iter>
class move_iterator : public _Move_iterator_category<_Iter> {
private:
_Iter _Current{};

public:
using iterator_type = _Iter;
using value_type = _Iter_value_t<_Iter>;
Expand Down Expand Up @@ -4211,9 +4214,6 @@ public:
_NODISCARD constexpr iterator_type&& _Get_current() && noexcept {
return _STD move(_Current);
}

private:
iterator_type _Current{};
};

_EXPORT_STD template <class _Iter1, class _Iter2>
Expand Down
Loading

0 comments on commit 446444e

Please sign in to comment.