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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ZERICO2005
Copy link
Contributor

@ZERICO2005 ZERICO2005 commented Mar 14, 2025

Changes:

  • expanded <type_traits>
  • added to <concepts>
  • added C++23 std::unreachable to <utility>

I have added to <type_traits> by replacing __has_feature(is_foo) to __has_builtin(__is_foo). From this, almost all of C++17 <type_traits> has been implemented except for:

/* C++11 */
common_type
aligned_storage
aligned_union
result_of
is_trivially_copy_assignable
is_trivially_move_assignable
make_signed
make_unsigned
is_destructable // works in C++20, requires Clang 16 to work in C++11
is_nothrow_destructable // works in C++20, requires Clang 16 to work in C++11
/* C++17 */
is_swappable
is_nothrow_swappable
invoke_result

I also replaced existing functions in <type_traits> with builtins if possible. I still need to do testing to ensure that all transformations are correct.

__has_builtin is the same as __has_feature, except that the latter is "deprecated", so it won't return true for newer builtins https://releases.llvm.org/15.0.0/tools/clang/docs/LanguageExtensions.html#builtin-functions

There are multiple ways to detect support for a type trait __X in the compiler, depending on the oldest version of Clang you wish to support.
* From Clang 10 onwards, __has_builtin(__X) can be used.
* From Clang 6 onwards, !__is_identifier(__X) can be used.
* From Clang 3 onwards, __has_feature(X) can be used, but only supports the following traits:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant