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

is_optional would be more efficient as a variable template #45

Open
jwakely opened this issue Jul 18, 2024 · 1 comment
Open

is_optional would be more efficient as a variable template #45

jwakely opened this issue Jul 18, 2024 · 1 comment
Assignees

Comments

@jwakely
Copy link

jwakely commented Jul 18, 2024

https://github.com/beman-project/Optional26/blob/bfeb9080c0d9c501965ae857a1decf7ed74686f5/include/Beman/Optional26/optional.hpp#L237-L242

There seems to be no reason to prefer a class template to a variable template, it just makes it slower to compile. Why decay_t not remove_cvref_t? Or why do that at all? All uses of is_optional already use either remove_cvref or decay (which should be remove_cvref in all cases), except for the use in optional<T&>::and_then which is probably incorrect.

template <class T>
inline constexpr bool is_optional = false;
template <class T>
inline constexpr bool is_optional<optional<T>> = true;
@steve-downey steve-downey self-assigned this Jul 18, 2024
@steve-downey
Copy link
Member

Testing the static_asserts moved up the priority list, too. It was ad-hoc, and therefore wrong.

@steve-downey steve-downey mentioned this issue Jul 22, 2024
steve-downey added a commit to steve-downey/optional that referenced this issue Jul 22, 2024
Increase efficiency, reduce complexity. Suggestion from @jwakely in bemanproject#45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants