-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
STL: Finish replacing tag dispatch with if constexpr
#189
Labels
throughput
Must compile faster
Comments
StephanTLavavej
added
enhancement
Something can be improved
throughput
Must compile faster
labels
Oct 18, 2019
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This was referenced Sep 26, 2021
Merged
This comment was marked as resolved.
This comment was marked as resolved.
AlexGuteniev
added a commit
to AlexGuteniev/STL
that referenced
this issue
Oct 20, 2021
Towards microsoft#189
Merged
Merged
AlexGuteniev
added a commit
to AlexGuteniev/STL
that referenced
this issue
Jan 13, 2022
Towards microsoft#189 Separated from microsoft#2219
AlexGuteniev
added a commit
to AlexGuteniev/STL
that referenced
this issue
Jan 15, 2022
Towards microsoft#189 @miscco would suggest enum instead of bool, so doing it in advance
AlexGuteniev
added a commit
to AlexGuteniev/STL
that referenced
this issue
Jan 15, 2022
AlexGuteniev
added a commit
to AlexGuteniev/STL
that referenced
this issue
Jan 15, 2022
This was referenced Jan 15, 2022
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
AlexGuteniev
added a commit
to AlexGuteniev/STL
that referenced
this issue
Jan 16, 2022
Towards microsoft#189 Separated from microsoft#2219
Merged
This comment was marked as resolved.
This comment was marked as resolved.
Dispatching on iterator strength:
|
AlexGuteniev
added a commit
to AlexGuteniev/STL
that referenced
this issue
Apr 21, 2022
AlexGuteniev
added a commit
to AlexGuteniev/STL
that referenced
this issue
Apr 23, 2022
AlexGuteniev
added a commit
to AlexGuteniev/STL
that referenced
this issue
May 2, 2022
This was referenced May 2, 2022
There are candidates in Lines 1721 to 1743 in bd3d740
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tag dispatch is the STL's original metaprogramming technique: overload a helper function on a tag struct (e.g.
input_iterator_tag
versusforward_iterator_tag
, ortrue_type
versusfalse_type
) and then call it with a tag object to select the appropriate overload. This has several downsides, though - it is somewhat verbose, it interferes with code organization, and it results in actual function calls in debug mode. (This is slower, more work to step through when debugging, and bloats object files.) C++17if constexpr
supersedes tag dispatch in almost every situation (see note below) and we're using it in new C++17-and-later code. We can use it in C++14 mode too (compilers support it unconditionally with a warning that we've suppressed).We should finish overhauling the STL to use
if constexpr
.Note: Tag dispatch works with delegating constructors, whereas
if constexpr
works only in function bodies.subrange
's delegating constructors are a rare example of necessary tag dispatch:STL/stl/inc/xutility
Lines 3345 to 3356 in f099e9c
The text was updated successfully, but these errors were encountered: