Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expand <type_traits> and <concepts> #554

Merged
merged 5 commits into from
Mar 22, 2025
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 src/libcxx/header_test.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <__config>
#include <algorithm>
#include <bit>
#include <cassert>
#include <cctype>
Expand Down
86 changes: 56 additions & 30 deletions src/libcxx/include/concepts
Original file line number Diff line number Diff line change
@@ -1,30 +1,56 @@
// -*- C++ -*-
#ifndef _EZCXX_CONCEPTS
#define _EZCXX_CONCEPTS

#include <type_traits>

#pragma clang system_header

namespace std {

template <class _Tp, class _Up>
concept same_as = is_same<_Tp, _Up>::value && is_same<_Up, _Tp>::value;

// arithmetic:

template <class _Tp>
concept integral = is_integral_v<_Tp>;

template <class _Tp>
concept signed_integral = integral<_Tp> && is_signed_v<_Tp>;

template <class _Tp>
concept unsigned_integral = integral<_Tp> && !signed_integral<_Tp>;

template <class _Tp>
concept floating_point = is_floating_point_v<_Tp>;

} // namespace std

#endif // _EZCXX_CONCEPTS
// -*- C++ -*-
#ifndef _EZCXX_CONCEPTS
#define _EZCXX_CONCEPTS

#include <type_traits>

#pragma clang system_header

namespace std {

template<class _Tp, class _Up>
concept same_as = is_same<_Tp, _Up>::value && is_same<_Up, _Tp>::value;

template<class _From, class _To>
concept convertible_to =
is_convertible_v<_From, _To> &&
requires { static_cast<_To>(std::declval<_From>()); };

template <class _Dp, class _Bp>
concept derived_from =
is_base_of_v<_Bp, _Dp> &&
is_convertible_v<const volatile _Dp*, const volatile _Bp*>;

template<class _Tp>
concept destructible = is_nothrow_destructible_v<_Tp>;

template<class _Tp, class... _Args>
concept constructible_from =
destructible<_Tp> && is_constructible_v<_Tp, _Args...>;

template<class _Tp>
concept integral = is_integral_v<_Tp>;

template<class _Tp>
concept signed_integral = integral<_Tp> && is_signed_v<_Tp>;

template<class _Tp>
concept unsigned_integral = integral<_Tp> && !signed_integral<_Tp>;

template<class _Tp>
concept floating_point = is_floating_point_v<_Tp>;

template<class _Tp>
concept move_constructible =
constructible_from<_Tp, _Tp> && std::convertible_to<_Tp, _Tp>;

template<class _Tp>
concept copy_constructible =
move_constructible<_Tp> &&
constructible_from<_Tp, _Tp&> && convertible_to<_Tp&, _Tp> &&
constructible_from<_Tp, const _Tp&> && convertible_to<const _Tp&, _Tp> &&
constructible_from<_Tp, const _Tp> && convertible_to<const _Tp, _Tp>;

} // namespace std

#endif // _EZCXX_CONCEPTS
Loading
Loading