Skip to content

Commit

Permalink
Enable __cpp_lib_concepts for EDG, part 3 (#4298)
Browse files Browse the repository at this point in the history
Co-authored-by: Stephan T. Lavavej <[email protected]>
  • Loading branch information
cpplearner and StephanTLavavej committed Feb 6, 2024
1 parent d008413 commit 0c47a7c
Show file tree
Hide file tree
Showing 86 changed files with 1,029 additions and 1,674 deletions.
8 changes: 4 additions & 4 deletions stl/inc/__msvc_chrono.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ namespace chrono {
return !(_Left < _Right);
}

#ifdef __cpp_lib_concepts
#if _HAS_CXX20
_EXPORT_STD template <class _Rep1, class _Period1, class _Rep2, class _Period2>
requires three_way_comparable<typename common_type_t<duration<_Rep1, _Period1>, duration<_Rep2, _Period2>>::rep>
_NODISCARD constexpr auto operator<=>(const duration<_Rep1, _Period1>& _Left,
Expand All @@ -414,7 +414,7 @@ namespace chrono {
using _CT = common_type_t<duration<_Rep1, _Period1>, duration<_Rep2, _Period2>>;
return _CT(_Left).count() <=> _CT(_Right).count();
}
#endif // defined(__cpp_lib_concepts)
#endif // _HAS_CXX20

_EXPORT_STD template <class _To, class _Rep, class _Period, enable_if_t<_Is_duration_v<_To>, int> /* = 0 */>
_NODISCARD constexpr _To duration_cast(const duration<_Rep, _Period>& _Dur) noexcept(
Expand Down Expand Up @@ -593,14 +593,14 @@ namespace chrono {
return !(_Left < _Right);
}

#ifdef __cpp_lib_concepts
#if _HAS_CXX20
_EXPORT_STD template <class _Clock, class _Duration1, three_way_comparable_with<_Duration1> _Duration2>
_NODISCARD constexpr auto
operator<=>(const time_point<_Clock, _Duration1>& _Left, const time_point<_Clock, _Duration2>& _Right) noexcept(
is_arithmetic_v<typename _Duration1::rep> && is_arithmetic_v<typename _Duration2::rep>) /* strengthened */ {
return _Left.time_since_epoch() <=> _Right.time_since_epoch();
}
#endif // defined(__cpp_lib_concepts)
#endif // _HAS_CXX20

_EXPORT_STD template <class _To, class _Clock, class _Duration, enable_if_t<_Is_duration_v<_To>, int> = 0>
_NODISCARD constexpr time_point<_Clock, _To> time_point_cast(const time_point<_Clock, _Duration>& _Time) noexcept(
Expand Down
4 changes: 2 additions & 2 deletions stl/inc/__msvc_formatter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
#include <yvals_core.h>
#if _STL_COMPILER_PREPROCESSOR

#if !_HAS_CXX20 || !defined(__cpp_lib_concepts) // TRANSITION, GH-395
#if !_HAS_CXX20
#error The contents of <format> are only available with C++20. (Also, you should not include this internal header.)
#endif // !_HAS_CXX20 || !defined(__cpp_lib_concepts)
#endif // !_HAS_CXX20

#include <concepts>
#include <cstddef>
Expand Down
12 changes: 4 additions & 8 deletions stl/inc/__msvc_int128.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,15 @@

#if _HAS_CXX20
#include <compare>
#include <concepts>
#define _TEMPLATE_CLASS_INTEGRAL(type) template <integral type>
#define _ZERO_OR_NO_INIT
#else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv
#define _TEMPLATE_CLASS_INTEGRAL(type) template <class type, enable_if_t<is_integral_v<type>, int> = 0>
#define _ZERO_OR_NO_INIT \
{} // Trivial default initialization is not allowed in constexpr functions before C++20.
#endif // ^^^ !_HAS_CXX20 ^^^

#ifdef __cpp_lib_concepts
#include <concepts>
#define _TEMPLATE_CLASS_INTEGRAL(type) template <integral type>
#else // ^^^ defined(__cpp_lib_concepts) / !defined(__cpp_lib_concepts) vvv
#define _TEMPLATE_CLASS_INTEGRAL(type) template <class type, enable_if_t<is_integral_v<type>, int> = 0>
#endif // ^^^ !defined(__cpp_lib_concepts) ^^^

#pragma pack(push, _CRT_PACKING)
#pragma warning(push, _STL_WARNING_LEVEL)
#pragma warning(disable : _STL_DISABLED_WARNINGS)
Expand Down Expand Up @@ -308,7 +304,7 @@ struct

_TEMPLATE_CLASS_INTEGRAL(_Ty)
constexpr _Base128(const _Ty _Val) noexcept : _Word{static_cast<uint64_t>(_Val)} {
#ifdef __cpp_lib_concepts
#if _HAS_CXX20
if constexpr (signed_integral<_Ty>)
#else
if constexpr (is_signed_v<_Ty>)
Expand Down
6 changes: 3 additions & 3 deletions stl/inc/__msvc_iter_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ _EXPORT_STD struct bidirectional_iterator_tag : forward_iterator_tag {};

_EXPORT_STD struct random_access_iterator_tag : bidirectional_iterator_tag {};

#ifdef __cpp_lib_concepts
#if _HAS_CXX20
_EXPORT_STD struct contiguous_iterator_tag : random_access_iterator_tag {};

template <class _Ty>
Expand Down Expand Up @@ -482,7 +482,7 @@ template <class _It, class _Se, ranges::subrange_kind _Ki>
struct tuple_element<1, const ranges::subrange<_It, _Se, _Ki>> {
using type = _Se;
};
#else // ^^^ defined(__cpp_lib_concepts) / !defined(__cpp_lib_concepts) vvv
#else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv
template <class, class = void>
struct _Iterator_traits_base {}; // empty for non-iterators

Expand Down Expand Up @@ -515,7 +515,7 @@ struct iterator_traits : _Iterator_traits_base<_Iter> {}; // get traits from ite

template <class _Ty>
struct iterator_traits<_Ty*> : _Iterator_traits_pointer_base<_Ty> {}; // get traits from pointer, if possible
#endif // ^^^ !defined(__cpp_lib_concepts) ^^^
#endif // ^^^ !_HAS_CXX20 ^^^
_STD_END

#pragma pop_macro("new")
Expand Down
4 changes: 2 additions & 2 deletions stl/inc/__msvc_print.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#include <yvals_core.h>
#if _STL_COMPILER_PREPROCESSOR

#ifndef __cpp_lib_concepts // note: <format> includes this header in C++20 mode
#if !_HAS_CXX20 // note: <format> includes this header in C++20 mode
#error The contents of <print> are available only with C++23. (Also, you should not include this internal header.)
#endif // ^^^ !defined(__cpp_lib_concepts) ^^^
#endif // ^^^ !_HAS_CXX20 ^^^

#include <cstdio>
#include <xfilesystem_abi.h>
Expand Down
Loading

0 comments on commit 0c47a7c

Please sign in to comment.