Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions stl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ set(HEADERS
${CMAKE_CURRENT_LIST_DIR}/inc/ostream
${CMAKE_CURRENT_LIST_DIR}/inc/queue
${CMAKE_CURRENT_LIST_DIR}/inc/random
${CMAKE_CURRENT_LIST_DIR}/inc/ranges
${CMAKE_CURRENT_LIST_DIR}/inc/ratio
${CMAKE_CURRENT_LIST_DIR}/inc/regex
${CMAKE_CURRENT_LIST_DIR}/inc/scoped_allocator
Expand Down
1 change: 1 addition & 0 deletions stl/inc/__msvc_all_public_headers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
#include <ostream>
#include <queue>
#include <random>
#include <ranges>
#include <ratio>
#include <regex>
#include <scoped_allocator>
Expand Down
12 changes: 6 additions & 6 deletions stl/inc/concepts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ concept default_initializable = constructible_from<_Ty>
template <class _Ty>
concept move_constructible = constructible_from<_Ty, _Ty> && convertible_to<_Ty, _Ty>;

// CONCEPT _Has_class_or_enum_type
template <class _Ty>
concept _Has_class_or_enum_type = __is_class(remove_reference_t<_Ty>) || __is_enum(remove_reference_t<_Ty>);

// CUSTOMIZATION POINT OBJECT ranges::swap
namespace ranges {
namespace _Swap {
Expand All @@ -131,12 +135,8 @@ namespace ranges {
template <class _Ty>
void swap(_Ty&, _Ty&) = delete;

template <class _Ty>
inline constexpr bool _Is_class_or_enum = __is_class(_Ty) || __is_enum(_Ty);

template <class _Ty1, class _Ty2>
concept _Use_ADL_swap =
(_Is_class_or_enum<remove_reference_t<_Ty1>> || _Is_class_or_enum<remove_reference_t<_Ty2>>)
concept _Use_ADL_swap = (_Has_class_or_enum_type<_Ty1> || _Has_class_or_enum_type<_Ty2>)
&& requires(_Ty1&& __t, _Ty2&& __u) {
swap(static_cast<_Ty1&&>(__t), static_cast<_Ty2&&>(__u));
};
Expand Down Expand Up @@ -364,7 +364,7 @@ _STL_RESTORE_CLANG_WARNINGS
#pragma warning(pop)
#pragma pack(pop)
#else // ^^^ <concepts> supported / <concepts> not supported vvv
#pragma message("The contents of <concepts> are only available with C++20 or later.")
#pragma message("The contents of <concepts> are only available with C++20 concepts support.")
#endif // __cpp_lib_concepts
#endif // _STL_COMPILER_PREPROCESSOR
#endif // _CONCEPTS_
4 changes: 2 additions & 2 deletions stl/inc/hash_map
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,8 @@ namespace stdext {
}
} // namespace stdext
_STD_BEGIN
using stdext::hash_map;
using stdext::hash_multimap;
using _STDEXT hash_map;
using _STDEXT hash_multimap;
_STD_END

#pragma pop_macro("new")
Expand Down
15 changes: 13 additions & 2 deletions stl/inc/hash_set
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,20 @@ namespace stdext {
return !(_Left == _Right);
}
} // namespace stdext

_STD_BEGIN
using stdext::hash_multiset;
using stdext::hash_set;
using _STDEXT hash_multiset;
using _STDEXT hash_set;

#ifdef __cpp_lib_concepts
namespace ranges {
template <class _Kty, class _Tr, class _Alloc>
inline constexpr bool enable_view<_STDEXT hash_set<_Kty, _Tr, _Alloc>> = false;

template <class _Kty, class _Tr, class _Alloc>
inline constexpr bool enable_view<_STDEXT hash_multiset<_Kty, _Tr, _Alloc>> = false;
} // namespace ranges
#endif // __cpp_lib_concepts
_STD_END

#pragma pop_macro("new")
Expand Down
26 changes: 0 additions & 26 deletions stl/inc/memory
Original file line number Diff line number Diff line change
Expand Up @@ -2173,32 +2173,6 @@ basic_ostream<_Elem, _Traits>& operator<<(basic_ostream<_Elem, _Traits>& _Out, c
return _Out;
}

#if _HAS_CXX20
// FUNCTION TEMPLATE to_address
template <class _Ptr, class = void>
inline constexpr bool _Has_to_address_v = false; // determines whether _Ptr has pointer_traits<_Ptr>::to_address(p)

template <class _Ptr>
inline constexpr bool
_Has_to_address_v<_Ptr, void_t<decltype(pointer_traits<_Ptr>::to_address(_STD declval<const _Ptr&>()))>> = true;

template <class _Ty>
_NODISCARD constexpr _Ty* to_address(_Ty* const _Val) noexcept {
static_assert(!is_function_v<_Ty>,
"N4810 20.10.4 [pointer.conversion]/2: The program is ill-formed if T is a function type.");
return _Val;
}

template <class _Ptr>
_NODISCARD auto to_address(const _Ptr& _Val) noexcept {
if constexpr (_Has_to_address_v<_Ptr>) {
return pointer_traits<_Ptr>::to_address(_Val);
} else {
return _STD to_address(_Val.operator->()); // plain pointer overload must come first
}
}
#endif // _HAS_CXX20

// GARBAGE COLLECTION
enum class pointer_safety { relaxed, preferred, strict };

Expand Down
6 changes: 3 additions & 3 deletions stl/inc/random
Original file line number Diff line number Diff line change
Expand Up @@ -1851,17 +1851,17 @@ private:

template <class _Engine>
result_type _Eval(_Engine& _Eng, _Ty _Min, _Ty _Max) const { // compute next value in range [_Min, _Max]
_Rng_from_urng<_Uty, _Engine> _Rng(_Eng);
_Rng_from_urng<_Uty, _Engine> _Generator(_Eng);

const _Uty _Umin = _Adjust(_Uty(_Min));
const _Uty _Umax = _Adjust(_Uty(_Max));

_Uty _Uret;

if (_Umax - _Umin == _Uty(-1)) {
_Uret = static_cast<_Uty>(_Rng._Get_all_bits());
_Uret = static_cast<_Uty>(_Generator._Get_all_bits());
} else {
_Uret = static_cast<_Uty>(_Rng(static_cast<_Uty>(_Umax - _Umin + 1)));
_Uret = static_cast<_Uty>(_Generator(static_cast<_Uty>(_Umax - _Umin + 1)));
}

return static_cast<_Ty>(_Adjust(static_cast<_Uty>(_Uret + _Umin)));
Expand Down
7 changes: 7 additions & 0 deletions stl/inc/regex
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,13 @@ basic_ostream<_Elem, _Traits>& operator<<(basic_ostream<_Elem, _Traits>& _Ostr,
template <class _BidIt, class _Allocator = allocator<sub_match<_BidIt>>>
class match_results;

#ifdef __cpp_lib_concepts
namespace ranges {
template <class _BidIt, class _Allocator>
inline constexpr bool enable_view<match_results<_BidIt, _Allocator>> = false;
} // namespace ranges
#endif // __cpp_lib_concepts

template <class _BidIt, class _Alloc, class _InIt, class _OutIt>
_OutIt _Format_default(const match_results<_BidIt, _Alloc>& _Match, _OutIt _Out, _InIt _First, _InIt _Last,
regex_constants::match_flag_type _Flags = regex_constants::format_default);
Expand Down
10 changes: 10 additions & 0 deletions stl/inc/set
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,16 @@ namespace pmr {
using multiset = _STD multiset<_Kty, _Pr, polymorphic_allocator<_Kty>>;
} // namespace pmr
#endif // _HAS_CXX17

#ifdef __cpp_lib_concepts
namespace ranges {
template <class _Kty, class _Pr, class _Alloc>
inline constexpr bool enable_view<set<_Kty, _Pr, _Alloc>> = false;

template <class _Kty, class _Pr, class _Alloc>
inline constexpr bool enable_view<multiset<_Kty, _Pr, _Alloc>> = false;
} // namespace ranges
#endif // __cpp_lib_concepts
_STD_END
#pragma pop_macro("new")
_STL_RESTORE_CLANG_WARNINGS
Expand Down
10 changes: 10 additions & 0 deletions stl/inc/unordered_set
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,16 @@ namespace pmr {
using unordered_multiset = _STD unordered_multiset<_Kty, _Hasher, _Keyeq, polymorphic_allocator<_Kty>>;
} // namespace pmr
#endif // _HAS_CXX17

#ifdef __cpp_lib_concepts
namespace ranges {
template <class _Kty, class _Hasher, class _Keyeq, class _Alloc>
inline constexpr bool enable_view<unordered_set<_Kty, _Hasher, _Keyeq, _Alloc>> = false;

template <class _Kty, class _Hasher, class _Keyeq, class _Alloc>
inline constexpr bool enable_view<unordered_multiset<_Kty, _Hasher, _Keyeq, _Alloc>> = false;
} // namespace ranges
#endif // __cpp_lib_concepts
_STD_END
#pragma pop_macro("new")
_STL_RESTORE_CLANG_WARNINGS
Expand Down
84 changes: 0 additions & 84 deletions stl/inc/xmemory
Original file line number Diff line number Diff line change
Expand Up @@ -221,90 +221,6 @@ _Ty* _Global_new(_Types&&... _Args) { // acts as "new" while disallowing user ov
return static_cast<_Ty*>(_STD exchange(_Guard._Result, nullptr));
}

// STRUCT TEMPLATE _Get_first_parameter
template <class _Ty>
struct _Get_first_parameter;

template <template <class, class...> class _Ty, class _First, class... _Rest>
struct _Get_first_parameter<_Ty<_First, _Rest...>> { // given _Ty<_First, _Rest...>, extract _First
using type = _First;
};

// STRUCT TEMPLATE _Replace_first_parameter
template <class _Newfirst, class _Ty>
struct _Replace_first_parameter;

template <class _Newfirst, template <class, class...> class _Ty, class _First, class... _Rest>
struct _Replace_first_parameter<_Newfirst, _Ty<_First, _Rest...>> { // given _Ty<_First, _Rest...>, replace _First
using type = _Ty<_Newfirst, _Rest...>;
};

// STRUCT TEMPLATE _Get_element_type
template <class _Ty, class = void>
struct _Get_element_type {
using type = typename _Get_first_parameter<_Ty>::type;
};

template <class _Ty>
struct _Get_element_type<_Ty, void_t<typename _Ty::element_type>> {
using type = typename _Ty::element_type;
};

// STRUCT TEMPLATE _Get_ptr_difference_type
template <class _Ty, class = void>
struct _Get_ptr_difference_type {
using type = ptrdiff_t;
};

template <class _Ty>
struct _Get_ptr_difference_type<_Ty, void_t<typename _Ty::difference_type>> {
using type = typename _Ty::difference_type;
};

// STRUCT TEMPLATE _Get_rebind_alias
template <class _Ty, class _Other, class = void>
struct _Get_rebind_alias {
using type = typename _Replace_first_parameter<_Other, _Ty>::type;
};

template <class _Ty, class _Other>
struct _Get_rebind_alias<_Ty, _Other, void_t<typename _Ty::template rebind<_Other>>> {
using type = typename _Ty::template rebind<_Other>;
};

// STRUCT TEMPLATE pointer_traits
template <class _Ty>
struct pointer_traits {
using element_type = typename _Get_element_type<_Ty>::type;
using pointer = _Ty;
using difference_type = typename _Get_ptr_difference_type<_Ty>::type;

template <class _Other>
using rebind = typename _Get_rebind_alias<_Ty, _Other>::type;

using _Reftype = conditional_t<is_void_v<element_type>, char&, add_lvalue_reference_t<element_type>>;

_NODISCARD static pointer pointer_to(_Reftype _Val) {
return _Ty::pointer_to(_Val);
}
};

template <class _Ty>
struct pointer_traits<_Ty*> {
using element_type = _Ty;
using pointer = _Ty*;
using difference_type = ptrdiff_t;

template <class _Other>
using rebind = _Other*;

using _Reftype = conditional_t<is_void_v<_Ty>, char&, add_lvalue_reference_t<_Ty>>;

_NODISCARD static pointer pointer_to(_Reftype _Val) noexcept {
return _STD addressof(_Val);
}
};

// ALIAS TEMPLATE _Rebind_pointer_t
template <class _Ptr, class _Ty>
using _Rebind_pointer_t = typename pointer_traits<_Ptr>::template rebind<_Ty>;
Expand Down
13 changes: 10 additions & 3 deletions stl/inc/xtr1common
Original file line number Diff line number Diff line change
Expand Up @@ -205,22 +205,29 @@ struct is_arithmetic : bool_constant<is_arithmetic_v<_Ty>> {};
// STRUCT TEMPLATE remove_reference
template <class _Ty>
struct remove_reference {
using type = _Ty;
using type = _Ty;
using _Const_thru_ref_type = const _Ty;
};

template <class _Ty>
struct remove_reference<_Ty&> {
using type = _Ty;
using type = _Ty;
using _Const_thru_ref_type = const _Ty&;
};

template <class _Ty>
struct remove_reference<_Ty&&> {
using type = _Ty;
using type = _Ty;
using _Const_thru_ref_type = const _Ty&&;
};

template <class _Ty>
using remove_reference_t = typename remove_reference<_Ty>::type;

// ALIAS TEMPLATE _Const_thru_ref
template <class _Ty>
using _Const_thru_ref = typename remove_reference<_Ty>::_Const_thru_ref_type;

template <class _Ty>
using _Remove_cvref_t = remove_cv_t<remove_reference_t<_Ty>>;

Expand Down
Loading