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
template <typename F> struct Select<F> { template <typename InputIt> static void Exec(const F& f, InputIt first, InputIt last) { assert(first == last); f(); } };
keep in mind that assert turns into void in release builds, either always check and throw exceptions, or ensure that the code can compile when the assert is gone.
In release build (assert turns into void) the arguments first and last are not used, and the compiler warns about that, and in our good practices book warnings turn into errors, and as such our build is broken.
@killerbot242 thank you very much for opening this issue. I solved it with the cast because the library targets C++14, so that we can't use the [[maybe_unused]] available in C++17.
File : cli.h
affected code:
template <typename F> struct Select<F> { template <typename InputIt> static void Exec(const F& f, InputIt first, InputIt last) { assert(first == last); f(); } };
keep in mind that assert turns into void in release builds, either always check and throw exceptions, or ensure that the code can compile when the assert is gone.
In release build (assert turns into void) the arguments first and last are not used, and the compiler warns about that, and in our good practices book warnings turn into errors, and as such our build is broken.
Solutions:
old style:
template <typename F> struct Select<F> { template <typename InputIt> static void Exec(const F& f, InputIt first, InputIt last) { assert(first == last); f(); (void)first;(void)last; <======================== } };
or you can also use c++17 attributes [[maybe_unused]], I would prefer that, but depends what you want as minimum compiler requirements.
kind regards,
Lieven
The text was updated successfully, but these errors were encountered: