From c0f75c27fa7d3853ef82fe8c389a6876398b4bbd Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Thu, 18 Jun 2015 22:01:45 +0300 Subject: [PATCH] Avoid warnings in some tests and do more checks --- examples/exact_types_match.cpp | 15 ++++++++++++++- examples/registry.cpp | 15 ++++++++++++++- examples/user_defined_typeinfo.cpp | 11 +++++++++-- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/examples/exact_types_match.cpp b/examples/exact_types_match.cpp index fc39f26..f245066 100644 --- a/examples/exact_types_match.cpp +++ b/examples/exact_types_match.cpp @@ -1,4 +1,4 @@ -// Copyright 2013-2014 Antony Polukhin +// Copyright 2013-2015 Antony Polukhin // Distributed under the Boost Software License, Version 1.0. // (See the accompanying file LICENSE_1_0.txt @@ -17,7 +17,20 @@ #include #include #include +//<- +// Making `#include ` visible in docs, while actually using hand-made check +// instead of `assert`. This is required to verify correct behavior even if NDEBUG +// is defined and to avoid `unused local variable` warnings with defined NDEBUG. +#ifdef assert +# undef assert +#endif +#define assert(X) if (!(X)) std::exit(__LINE__) + /* !Comment block is not closed intentionaly! +//-> #include +//<- + !Closing comment block! */ +//-> class type_erased_unary_function { void* function_ptr_; diff --git a/examples/registry.cpp b/examples/registry.cpp index 2d14a9a..e969235 100644 --- a/examples/registry.cpp +++ b/examples/registry.cpp @@ -1,4 +1,4 @@ -// Copyright 2013-2014 Antony Polukhin +// Copyright 2013-2015 Antony Polukhin // Distributed under the Boost Software License, Version 1.0. // (See the accompanying file LICENSE_1_0.txt @@ -13,7 +13,20 @@ #include #include #include +//<- +// Making `#include ` visible in docs, while actually using hand-made check +// instead of `assert`. This is required to verify correct behavior even if NDEBUG +// is defined and to avoid `unused local variable` warnings with defined NDEBUG. +#ifdef assert +# undef assert +#endif +#define assert(X) if (!(X)) std::exit(__LINE__) + /* !Comment block is not closed intentionaly! +//-> #include +//<- + !Closing comment block! */ +//-> int main() { boost::unordered_set types; diff --git a/examples/user_defined_typeinfo.cpp b/examples/user_defined_typeinfo.cpp index 948989d..0d2518c 100644 --- a/examples/user_defined_typeinfo.cpp +++ b/examples/user_defined_typeinfo.cpp @@ -1,4 +1,4 @@ -// Copyright 2013-2014 Antony Polukhin +// Copyright 2013-2015 Antony Polukhin // Distributed under the Boost Software License, Version 1.0. // (See the accompanying file LICENSE_1_0.txt @@ -21,7 +21,14 @@ using namespace my_namespace; -#include +//<- +// Using hand-made check +// instead of `assert`. This is required to verify correct behavior even if NDEBUG +// is defined and to avoid `unused local variable` warnings with defined NDEBUG. +#ifdef assert +# undef assert +#endif +#define assert(X) if (!(X)) std::exit(__LINE__) int main() { //[type_index_my_type_index_usage