Close #69 Unused Var: Warning

Close #69
[This](http://stackoverflow.com/a/3418951)
stackoverflow post recommended
[that](http://herbsutter.com/2009/10/18/mailbag-shutting-up-compiler-warnings/)
Herb Sutter blog post with a general and portable solution and it
works great! :)
This commit is contained in:
Axel Huebl 2016-01-21 17:18:47 +01:00
parent 80a06745d3
commit 2dd5e3bc2a

View File

@ -250,24 +250,26 @@ template <int Nurse, int Patient> struct process_attribute<keep_alive<Nurse, Pat
static void postcall(handle args, handle ret) { keep_alive_impl(Nurse, Patient, args, ret); }
};
/// Ignore that a variable is unused in compiler warnings
template<class T> void ignore_unused(const T&) { }
/// Recursively iterate over variadic template arguments
template <typename... Args> struct process_attributes {
static void init(const Args&... args, function_record *r) {
int unused[] = { 0, (process_attribute<typename std::decay<Args>::type>::init(args, r), 0) ... };
(void) unused; (void) r;
ignore_unused(unused);
}
static void init(const Args&... args, type_record *r) {
int unused[] = { 0, (process_attribute<typename std::decay<Args>::type>::init(args, r), 0) ... };
(void) unused; (void) r;
ignore_unused(unused);
}
static void precall(handle fn_args) {
int unused[] = { 0, (process_attribute<typename std::decay<Args>::type>::precall(fn_args), 0) ... };
(void) unused; (void) fn_args;
ignore_unused(unused);
}
static void postcall(handle fn_args, handle fn_ret) {
int unused[] = { 0, (process_attribute<typename std::decay<Args>::type>::postcall(fn_args, fn_ret), 0) ... };
(void) unused; (void) fn_args; (void) fn_ret;
ignore_unused(unused);
}
};