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
Implement optional per C++17 + P0602 #674
Conversation
Yes, it takes a ridiculous number of nested classes to implement conditionally trivial special member functions. FOR THE LOVE OF GOD PUT CONCEPTS IN C++20. |
Last change before PR: "Oh, |
How does this not break |
It does break it. I should have given more credence to the failing assignment tests and not have written them off as all being due to concept mismatch. EDIT: Apparently I still haven't implemented optional enough times. |
Now passes all non-hash libc++ tests; except for the test that expects EDIT: I should clarify this passes tests only with |
{} | ||
T & get() | ||
template<typename T> | ||
struct semiregular_base |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you move the contents of semiregular_base
into semiregular
, you can eliminate semiregular_base
from the design altogether and use optional<T>
directly.
To reviewers: note that
|
There's a fresh push that:
I promise I'll stop messing with the PR now. |
I lied. I decided that This difference is user observable via non-trivial special member functions; I should probably constrain it to trivially copyable types as well. |
Last chance for more tweaks, @CaseyCarter. Going once, going twice ... |
...because I love implementing optional over and over. Not quite conforming due to my use of Assignable instead of is_assignable for constraints, since Assignable has a CommonReference requirement, but otherwise passes the libc++ tests. There's a ton of adjustment necessary to semiregular, which now: * *conditionally* implements assignment as construction * value-inits the contained T object when it is default constructible * perfectly forwards *this * supports semiregular<T &&> generator changes: * semiregular<Reference> now perfectly supports generator_promise for all Reference types * eliminate generator_promise_storage from the implementation
Now that you mention it...
|
Big improvement, thanks Casey. |
Implement optional per C++17 + P0602
...because I love implementing optional over and over.
Not quite conforming due to my use of
Assignable
instead ofis_assignable
for constraints, sinceAssignable
has aCommonReference
requirement, but otherwise passes the libc++ tests.There's a ton of adjustment necessary to
semiregular
, which now:T
object when it is default constructible*this
semiregular<T &&>
generator
changes:semiregular<Reference>
now perfectly supportsgenerator_promise
for allReference
typesgenerator_promise_storage
from the implementation