-
Notifications
You must be signed in to change notification settings - Fork 7
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
FWD implementation #1
Comments
Really glad you liked the talk - thanks for the feedback and for bringing this issue up. The reason I implemented
Now that I think about it, I don't believe this problem applies to
Unless there is a possible situation I am missing where either |
The
There may be a few cases where it could be valid:
One other approach that should work seamlessly without any breakage is to write a c++14 wrapper around template<typename T>
constexpr auto FWD(T&& x) -> decltype(std::forward<T>(x)){ return std::forward<T>(x); } Assuming this library isn't trying to keep any conformance to c++11, this should be valid and retain the normal semantics of It's just a thought either way. Once again, great library and great work 👍 |
I don't think that will work correctly. See this basic example and this StackOverflow question. (Also, isn't your |
Whoops, didn't actually realize that caused issues -- thanks for the link! Not sure why I thought that would work... As for the c++14 conformance, that was more a comment since |
First of all I wanted to say impressive talk today at CPPCon for
static_if
andstatic_for
-- excellent ideas and implementations. During the talk though I noticed something that might be worth bringing up.In the implementation of the FWD macro there are a couple of possible errors
Currently it's written as:
Unless this
std::forward
is a custom implementation, there are two things here that may lead to more cryptic errors.<decltype(__VA_ARGS__)>
will only deduce the type of the last arg in the set, because it would expand with the comma operator. For example,decltype(1,1.0)
only deducesdouble
and notint,double
.std::forward
in the standard only takes one argument, making the__VA_ARGS__
part of this likely unnecessary.The reason I bring this up is because something like
FWD(1,1.0)
will essentially translate into a call of:::std::forward<double>( 1, 1.0 )
-- and this leads to strange compiler messages.It may be worth changing to just
FWD(x)
instead.The text was updated successfully, but these errors were encountered: