From 9656b83d1f70ebef52497efe39dbf43130e5ac4b Mon Sep 17 00:00:00 2001 From: Nicolas Cornu Date: Wed, 29 Apr 2015 13:23:53 +0200 Subject: [PATCH] GCC warns about unused local typedef --- include/boost/python/args_fwd.hpp | 9 --------- include/boost/python/cast.hpp | 3 ++- include/boost/python/class.hpp | 26 ++++++-------------------- include/boost/python/def.hpp | 7 ++++--- include/boost/python/detail/defaults_gen.hpp | 11 +++++------ include/boost/python/init.hpp | 21 +++++---------------- include/boost/python/make_constructor.hpp | 5 ++--- include/boost/python/make_function.hpp | 5 ++--- include/boost/python/object/pickle_support.hpp | 10 +++------- 9 files changed, 29 insertions(+), 68 deletions(-) diff --git a/include/boost/python/args_fwd.hpp b/include/boost/python/args_fwd.hpp index 39239461b..83933f4fd 100644 --- a/include/boost/python/args_fwd.hpp +++ b/include/boost/python/args_fwd.hpp @@ -36,15 +36,6 @@ namespace detail BOOST_STATIC_CONSTANT(std::size_t, size = 0); static keyword_range range() { return keyword_range(); } }; - - namespace error - { - template - struct more_keywords_than_function_arguments - { - typedef char too_many_keywords[keywords > function_args ? -1 : 1]; - }; - } } }} // namespace boost::python diff --git a/include/boost/python/cast.hpp b/include/boost/python/cast.hpp index 31c61dbf8..3a1fd23b8 100755 --- a/include/boost/python/cast.hpp +++ b/include/boost/python/cast.hpp @@ -12,6 +12,7 @@ # include # include # include +# include namespace boost { namespace python { @@ -70,7 +71,7 @@ namespace detail template inline void assert_castable(boost::type* = 0) { - typedef char must_be_a_complete_type[sizeof(T)]; + BOOST_MPL_ASSERT_MSG(sizeof(T) == sizeof(T), T_MUST_BE_A_COMPLETE_TYPE, (T)); } template diff --git a/include/boost/python/class.hpp b/include/boost/python/class.hpp index f43b615ac..cb8934a18 100644 --- a/include/boost/python/class.hpp +++ b/include/boost/python/class.hpp @@ -39,6 +39,7 @@ # include # include # include +# include # include @@ -106,23 +107,6 @@ namespace detail namespace error { // - // A meta-assertion mechanism which prints nice error messages and - // backtraces on lots of compilers. Usage: - // - // assertion::failed - // - // where C is an MPL metafunction class - // - - template struct assertion_failed { }; - template struct assertion_ok { typedef C failed; }; - - template - struct assertion - : mpl::if_, assertion_failed >::type - {}; - - // // Checks for validity of arguments used to define virtual // functions with default implementations. // @@ -140,9 +124,11 @@ namespace detail // https://svn.boost.org/trac/boost/ticket/5803 //typedef typename assertion > >::failed test0; # if !BOOST_WORKAROUND(__MWERKS__, <= 0x2407) - typedef typename assertion >::failed test1; -# endif - typedef typename assertion >::failed test2; + BOOST_MPL_ASSERT_MSG(is_polymorphic::value, + NOT_POLYMORPHIC, (T)); +# endif + BOOST_MPL_ASSERT_MSG(is_member_function_pointer::value, + NOT_MEMBER_FUNCTION_POINTER, (Fn)); not_a_derived_class_member(Fn()); } }; diff --git a/include/boost/python/def.hpp b/include/boost/python/def.hpp index 76829b085..bde35f31b 100644 --- a/include/boost/python/def.hpp +++ b/include/boost/python/def.hpp @@ -15,6 +15,8 @@ # include # include +# include + namespace boost { namespace python { namespace detail @@ -35,9 +37,8 @@ namespace detail char const* name, F const& fn, Helper const& helper) { // Must not try to use default implementations except with method definitions. - typedef typename error::multiple_functions_passed_to_def< - Helper::has_default_implementation - >::type assertion; + BOOST_MPL_ASSERT_MSG(!Helper::has_default_implementation, + MULTIPLE_FUNCTIONS_PASSED_TO_DEF, (Helper)); detail::scope_setattr_doc( name, boost::python::make_function( diff --git a/include/boost/python/detail/defaults_gen.hpp b/include/boost/python/detail/defaults_gen.hpp index 0b3e0e260..f77912ea3 100644 --- a/include/boost/python/detail/defaults_gen.hpp +++ b/include/boost/python/detail/defaults_gen.hpp @@ -26,6 +26,7 @@ #include #include #include +#include #include namespace boost { namespace python { @@ -211,18 +212,16 @@ namespace detail : ::boost::python::detail::overloads_common( \ doc, keywords.range()) \ { \ - typedef typename ::boost::python::detail:: \ - error::more_keywords_than_function_arguments< \ - N,n_args>::too_many_keywords assertion; \ + BOOST_MPL_ASSERT_MSG(N <= n_args, \ + MORE_KEYWORDS_THAN_FUNCTION_ARGUMENTS, ()); \ } \ template \ fstubs_name(::boost::python::detail::keywords const& keywords, char const* doc = 0) \ : ::boost::python::detail::overloads_common( \ doc, keywords.range()) \ { \ - typedef typename ::boost::python::detail:: \ - error::more_keywords_than_function_arguments< \ - N,n_args>::too_many_keywords assertion; \ + BOOST_MPL_ASSERT_MSG(N <= n_args, \ + MORE_KEYWORDS_THAN_FUNCTION_ARGUMENTS, ()); \ } # if defined(BOOST_NO_VOID_RETURNS) diff --git a/include/boost/python/init.hpp b/include/boost/python/init.hpp index b82ab01e1..ae383e650 100644 --- a/include/boost/python/init.hpp +++ b/include/boost/python/init.hpp @@ -26,7 +26,7 @@ #include #include #include - +#include #include #include @@ -63,15 +63,6 @@ struct optional; // forward declaration namespace detail { - namespace error - { - template - struct more_keywords_than_init_arguments - { - typedef char too_many_keywords[init_args - keywords >= 0 ? 1 : -1]; - }; - } - // is_optional::value // // This metaprogram checks if T is an optional @@ -222,18 +213,16 @@ class init : public init_base > init(char const* doc_, detail::keywords const& kw) : base(doc_, kw.range()) { - typedef typename detail::error::more_keywords_than_init_arguments< - N, n_arguments::value + 1 - >::too_many_keywords assertion; + BOOST_MPL_ASSERT_MSG(N <= n_arguments::value + 1, + MORE_KEYWORDS_THAN_FUNCTION_ARGUMENTS, ()); } template init(detail::keywords const& kw, char const* doc_ = 0) : base(doc_, kw.range()) { - typedef typename detail::error::more_keywords_than_init_arguments< - N, n_arguments::value + 1 - >::too_many_keywords assertion; + BOOST_MPL_ASSERT_MSG(N <= n_arguments::value + 1, + MORE_KEYWORDS_THAN_FUNCTION_ARGUMENTS, ()); } template diff --git a/include/boost/python/make_constructor.hpp b/include/boost/python/make_constructor.hpp index 47cdf469c..94d61cc62 100644 --- a/include/boost/python/make_constructor.hpp +++ b/include/boost/python/make_constructor.hpp @@ -172,10 +172,9 @@ namespace detail { enum { arity = mpl::size::value - 1 }; - typedef typename detail::error::more_keywords_than_function_arguments< - NumKeywords::value, arity - >::too_many_keywords assertion; + BOOST_MPL_ASSERT_MSG(NumKeywords::value <= arity, + MORE_KEYWORDS_THAN_FUNCTION_ARGUMENTS, ()); typedef typename outer_constructor_signature::type outer_signature; typedef constructor_policy inner_policy; diff --git a/include/boost/python/make_function.hpp b/include/boost/python/make_function.hpp index f2f2a9e54..60b27238e 100644 --- a/include/boost/python/make_function.hpp +++ b/include/boost/python/make_function.hpp @@ -53,9 +53,8 @@ namespace detail { enum { arity = mpl::size::value - 1 }; - typedef typename detail::error::more_keywords_than_function_arguments< - NumKeywords::value, arity - >::too_many_keywords assertion; + BOOST_MPL_ASSERT_MSG(NumKeywords::value <= arity, + MORE_KEYWORDS_THAN_FUNCTION_ARGUMENTS, ()); return objects::function_object( detail::caller(f, p) diff --git a/include/boost/python/object/pickle_support.hpp b/include/boost/python/object/pickle_support.hpp index cbdbcbb9d..8d781a368 100644 --- a/include/boost/python/object/pickle_support.hpp +++ b/include/boost/python/object/pickle_support.hpp @@ -6,6 +6,7 @@ # define BOOST_PYTHON_OBJECT_PICKLE_SUPPORT_RWGK20020603_HPP # include +# include namespace boost { namespace python { @@ -21,10 +22,6 @@ BOOST_PYTHON_DECL object const& make_instance_reduce_function(); struct pickle_suite; namespace error_messages { - - template - struct missing_pickle_suite_function_or_incorrect_signature {}; - inline void must_be_derived_from_pickle_suite(pickle_suite const&) {} } @@ -105,9 +102,8 @@ namespace detail { Class_&, ...) { - typedef typename - error_messages::missing_pickle_suite_function_or_incorrect_signature< - Class_>::error_type error_type; + BOOST_MPL_ASSERT_MSG + (false, MISSING_PICKLE_SUITE_FUNCTION_OR_INCORRECT_SIGNATURE, ()); } };