-
Notifications
You must be signed in to change notification settings - Fork 5
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
Improve Compiler Errors #133
Improve Compiler Errors #133
Conversation
b7ee0ef
to
19014e8
Compare
19014e8
to
28b7785
Compare
98fc167
to
28b7785
Compare
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.
Do you have some before-after compiler errors?
I see nothing wrong with the code, but macros aren't something I'm very familiar with.
If this helps development by being more explicit that templated functions aren't defined, I'm for the changes.
@seth-swiftnav just updated the description with an example. |
Perhaps worth noting that I haven't done it in this change, but in the future I hope to use these macros to start catching some common errors such as slight misspellings, lack of const on methods, invalid return type etc ... Ie, setup some catches like |
#define ALBATROSS_FAIL(dummy, msg) \ | ||
{ static_assert(delay_static_assert<dummy>::value, msg); } | ||
|
||
//#define ALBATROSS_FAIL(dummy, msg) = delete |
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.
Should this be deleted?
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.
I intentionally left that in as an example of an alternate definition of ALBATROSS_FAIL
. I'll make that more explicit.
template <typename T> static std::false_type test(...); | ||
|
||
public: | ||
static constexpr bool value = decltype(test<X>(0))::value; |
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.
Would it make sense to use std::decay<X>::type
to get rid of potential reference/const-ness?
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.
Yeah seems prudent, thanks.
a7de4e9
to
7c87e30
Compare
One of the more difficult issues when iterating on
albatross
is the often cryptic compiler errors that are produced when developing. The current approach to this problem is to insert a bunch of static checks which explicitly delete functions that aren't valid which then leads the compiler to dump all the information about the templated types used which lead to the selection of the deleted function. The problem with this is that there isn't a way to add a human readable description of what the problem was.This change attempts to improve the situation slightly by defining a macro
ALBATROSS_FAIL
which lets you use the= delete
approach or switch to adelay_static_assert
approach similar to cereal. Usingdelay_static_assert
let's you provide a human readable message along with the resolved template parameters which should make debugging issues easier.In addition to the these changes I've adding a few additional macros which build some of the frequently used trait inspection routines. This made it easier to create even more
has_any_*
methods which in turn should make it easier to add moreALBATROSS_FAIL
instances.BEFORE:
AFTER: