You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At first glance it is only about constructors.
Would it be OK to change vec(T x, T y) : x(x), y(y) etc to, say, vec(T x_, T y_) : x(x_), y(y_)?
-Wshadow needs to be enabled explicitely so I guess few people use it. What's your opinion? I could provide PR if it'd be helpful.
../linalg.h: In constructor ‘constexpr linalg::vec<T, 2>::vec(T, T)’:
../linalg.h:69:69: warning: declaration of ‘y’ shadows a member of ‘linalg::vec<T, 2>’ [-Wshadow]
constexpr vec(T x, T y) : x(x), y(y) {}
^
../linalg.h:67:39: note: shadowed declaration is here
T x,y;
^
The text was updated successfully, but these errors were encountered:
Thanks for bringing this to my attention. I've gone ahead and made this change.
In my own code, I make the deliberate choice to shadow member variables with constructor parameter names, both for brevity and for safety, as it prevents the (surprisingly legal in standard C++?!) mistake of copy-constructing a member variable from itself.
However, I understand that users may wish to compile with strict sets of warnings, and may possibly wish to do so in conjunction with -Werror. A minor stylistic quibble would be a silly reason to turn away users.
At first glance it is only about constructors.
Would it be OK to change
vec(T x, T y) : x(x), y(y)
etc to, say,vec(T x_, T y_) : x(x_), y(y_)
?-Wshadow needs to be enabled explicitely so I guess few people use it. What's your opinion? I could provide PR if it'd be helpful.
The text was updated successfully, but these errors were encountered: