Skip to content
New issue

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

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

Already on GitHub? # to your account

[R&D] Check compile time improvement with alternative to std::declval #95

Open
SadiinsoSnowfall opened this issue Nov 11, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@SadiinsoSnowfall
Copy link

SadiinsoSnowfall commented Nov 11, 2024

Eric Niebler on twitter seems to have found an alternative to std::declval that compiles at least twice as fast under clang 17.

template class T>
using identity_t = T;

template class, class = void>
extern identity_t<void (*)() noexcept> declval;

template <class T>
extern identity_t<T && (*)() noexcept> declval<T, void_t<T &&>>;

As well as another implementation which is said to compile up to three time faster but cannot handle some function types:

template <class T>
using identity_t = T;

template <class T>
extern identity_t<T&& (*)() noexcept> declval;

template <>
constexpr identity_t<void (*)() noexcept> declval<void>;

template <>
constexpr identity_t<void (*)() noexcept> declval<void const>;

template <>
constexpr identity_t<void (*)() noexcept> declval<void volatile>;

template <>
constexpr identity_t<void (*)() noexcept> declval<void const volatile>;

This might be something we want to look into.

@SadiinsoSnowfall SadiinsoSnowfall added the enhancement New feature or request label Nov 11, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant