-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add type_util
meta-programming utilities.
#7682
Add type_util
meta-programming utilities.
#7682
Conversation
@drake-jenkins-bot mac-sierra-clang-bazel-experimental please. |
+@ggould-tri for feature review, please. Review status: 0 of 3 files reviewed at latest revision, all discussions resolved. Comments from Reviewable |
Review status: 0 of 3 files reviewed at latest revision, 1 unresolved discussion. common/BUILD.bazel, line 354 at r1 (raw file):
Will move Comments from Reviewable |
Reviewed 3 of 3 files at r1. common/type_util.h, line 66 at r1 (raw file):
BTW -- is the compiler error message for an overlarge common/type_util.h, line 104 at r1 (raw file):
BTW -- is the compiler error message for a class without a default ctor remotely comprehensible? common/type_util.h, line 129 at r1 (raw file):
FYI -- you should probably TODO removing this when we get to party like it's C++17. common/test/type_util_test.cc, line 80 at r1 (raw file):
FYI typo "containd" common/test/type_util_test.cc, line 82 at r1 (raw file):
BTW -- would it make sense to test that case as well in addition to describing it? common/test/type_util_test.cc, line 94 at r1 (raw file):
This is beautiful sorcery and I fear it. Comments from Reviewable |
22d220e
to
3d73cbe
Compare
Thanks! Review status: 0 of 3 files reviewed at latest revision, 6 unresolved discussions. common/BUILD.bazel, line 354 at r1 (raw file): Previously, EricCousineau-TRI wrote…
Done. common/type_util.h, line 66 at r1 (raw file): Previously, ggould-tri wrote…
Done. Yup! (added in check for negative numbers too, just in case
common/type_util.h, line 104 at r1 (raw file): Previously, ggould-tri wrote…
Done. It's only slight comprehensible; unfortunately, it doesn't explicitly state Unfortunately, I don't know how to bubble up common/type_util.h, line 129 at r1 (raw file): Previously, ggould-tri wrote…
Done. common/test/type_util_test.cc, line 80 at r1 (raw file): Previously, ggould-tri wrote…
Done. common/test/type_util_test.cc, line 82 at r1 (raw file): Previously, ggould-tri wrote…
Done. common/test/type_util_test.cc, line 94 at r1 (raw file): Previously, ggould-tri wrote…
Yeah, it's a tad bit odd, but was useful when wanting to expose literal template parameters to Comments from Reviewable |
Reviewed 2 of 3 files at r2. common/type_util.h, line 66 at r1 (raw file): Previously, EricCousineau-TRI wrote…
That's surprisingly readable. Yay. common/type_util.h, line 104 at r1 (raw file): Previously, EricCousineau-TRI wrote…
Alas. I'll mark this satisfied, but users may be very sad if they try to use this. With any luck, they won't. Comments from Reviewable |
Reviewed 1 of 3 files at r2. Comments from Reviewable |
Checkpoint. Reviewed 1 of 3 files at r2. common/BUILD.bazel, line 21 at r2 (raw file):
The new Comments from Reviewable |
3d73cbe
to
edcae62
Compare
Review status: 1 of 3 files reviewed at latest revision, 1 unresolved discussion. common/BUILD.bazel, line 21 at r2 (raw file): Previously, jwnimmer-tri (Jeremy Nimmer) wrote…
Done. Comments from Reviewable |
Reviewed 2 of 2 files at r3. Comments from Reviewable |
870bd4c
to
ea7bf3a
Compare
Review status: 1 of 3 files reviewed at latest revision, all discussions resolved. common/type_util.h, line 104 at r1 (raw file): Previously, ggould-tri wrote…
BTW I was able to bubble up a little more info by sticking the assertion in a relatively bare structure. The errors now look like this, still with a bunch of cruft, but at least calling out
Comments from Reviewable |
Reviewed 2 of 2 files at r4. Comments from Reviewable |
Reviewed 1 of 3 files at r2, 1 of 2 files at r3, 2 of 2 files at r4. common/type_util.h, line 3 at r4 (raw file):
FYI The name Maybe common/type_util.h, line 114 at r4 (raw file):
I was okay having common/type_util.h, line 161 at r4 (raw file):
I think Comments from Reviewable |
ea7bf3a
to
e5aaeb1
Compare
Review status: 0 of 3 files reviewed at latest revision, 3 unresolved discussions. common/type_pack.h, line 3 at r4 (raw file): Previously, jwnimmer-tri (Jeremy Nimmer) wrote…
Named it to common/type_pack.h, line 114 at r4 (raw file): Previously, jwnimmer-tri (Jeremy Nimmer) wrote…
Prepended common/type_pack.h, line 161 at r4 (raw file): Previously, jwnimmer-tri (Jeremy Nimmer) wrote…
Done. Comments from Reviewable |
Switched Review status: 0 of 3 files reviewed at latest revision, 3 unresolved discussions. Comments from Reviewable |
My intuition is that this plausibly could will be used in places beyond the python bindings helpers within the next, say, 12 months. But if you think that chance is low, then we should put this in Reviewed 5 of 5 files at r5. Comments from Reviewable |
e5aaeb1
to
4577029
Compare
I'd say it might be pretty low for now. Went ahead and put it in Review status: 0 of 3 files reviewed at latest revision, all discussions resolved, some commit checks failed. Comments from Reviewable |
Reviewed 2 of 7 files at r5, 5 of 6 files at r6. Comments from Reviewable |
4577029
to
9a0863b
Compare
Reviewed 1 of 2 files at r7. Comments from Reviewable |
This adds some basic meta-programming utilities for handling template parameter packs (and a little bit of sugar for type hashing).
This related #7660: template classes and methods in
pybind11
.For a protoype, see Python output for binding basic templates and a Python derived-class scalar conversion example.
NOTE: Compilation of this code seems significantly slower on my desktop than on my laptop. Will check and see if there's anything that can be changed to fix this.
This change is