From a5f29e93f5260cbd207b575eb01d27a279b46c93 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Fri, 1 Jun 2012 12:21:14 -0600 Subject: [PATCH] Eliminate all VC++10 64bit Warnings. --- .../chaiscript/dispatchkit/bootstrap_stl.hpp | 77 ++++++++++++++++--- 1 file changed, 68 insertions(+), 9 deletions(-) diff --git a/include/chaiscript/dispatchkit/bootstrap_stl.hpp b/include/chaiscript/dispatchkit/bootstrap_stl.hpp index d7bff65..40f9687 100644 --- a/include/chaiscript/dispatchkit/bootstrap_stl.hpp +++ b/include/chaiscript/dispatchkit/bootstrap_stl.hpp @@ -147,6 +147,64 @@ namespace chaiscript }; namespace detail { + template + int return_int_impl(const boost::function &t_func, const T *t_obj) + { +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable : 4267) +#endif + return t_func(t_obj); +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + } + + template + boost::function return_int(size_t (T::*t_func)() const) + { + return boost::bind(&return_int_impl, boost::function(boost::mem_fn(t_func)), _1); + } + + template + int return_int_impl(const boost::function &t_func, const T *t_obj, P1 p1) + { +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable : 4267) +#endif + return t_func(t_obj, p1); +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + } + + template + boost::function return_int(size_t (T::*t_func)(P1) const) + { + return boost::bind(&return_int_impl, boost::function(boost::mem_fn(t_func)), _1, _2); + } + + template + int return_int_impl(const boost::function &t_func, const T *t_obj, P1 p1, P2 p2) + { +#ifdef BOOST_MSVC +#pragma warning(push) +#pragma warning(disable : 4267) +#endif + return t_func(t_obj, p1, p2); +#ifdef BOOST_MSVC +#pragma warning(pop) +#endif + } + + template + boost::function return_int(size_t (T::*t_func)(P1, P2) const) + { + return boost::bind(&return_int_impl, boost::function(boost::mem_fn(t_func)), _1, _2, _3); + } + + /** * Add Bidir_Range support for the given ContainerType */ @@ -255,7 +313,9 @@ namespace chaiscript template ModulePtr container_type(const std::string &/*type*/, ModulePtr m = ModulePtr(new Module())) { - m->add(fun(boost::function(boost::mem_fn(&ContainerType::size))), "size"); + boost::function f = detail::return_int(&ContainerType::size); + m->add(fun(f), "size"); +// m->add(fun(boost::function(boost::mem_fn(&ContainerType::size))), "size"); m->add(fun(&ContainerType::empty), "empty"); m->add(fun(&ContainerType::clear), "clear"); @@ -390,7 +450,7 @@ namespace chaiscript template ModulePtr unique_associative_container_type(const std::string &/*type*/, ModulePtr m = ModulePtr(new Module())) { - m->add(fun(boost::function(boost::mem_fn(&ContainerType::count))), "count"); + m->add(fun(boost::function(detail::return_int(&ContainerType::count))), "count"); return m; } @@ -512,15 +572,14 @@ namespace chaiscript m->add(fun(&String::push_back), push_back_name); typedef typename String::size_type (String::*find_func_ptr)(const String &, typename String::size_type) const; - typedef boost::function find_func; - m->add(fun(find_func(boost::mem_fn(static_cast(&String::find)))), "find"); - m->add(fun(find_func(boost::mem_fn(static_cast(&String::rfind)))), "rfind"); - m->add(fun(find_func(boost::mem_fn(static_cast(&String::find_first_of)))), "find_first_of"); - m->add(fun(find_func(boost::mem_fn(static_cast(&String::find_last_of)))), "find_last_of"); - m->add(fun(find_func(boost::mem_fn(static_cast(&String::find_first_not_of)))), "find_first_not_of"); - m->add(fun(find_func(boost::mem_fn(static_cast(&String::find_last_not_of)))), "find_last_not_of"); + m->add(fun(find_func(detail::return_int(static_cast(&String::find)))), "find"); + m->add(fun(find_func(detail::return_int(static_cast(&String::rfind)))), "rfind"); + m->add(fun(find_func(detail::return_int(static_cast(&String::find_first_of)))), "find_first_of"); + m->add(fun(find_func(detail::return_int(static_cast(&String::find_last_of)))), "find_last_of"); + m->add(fun(find_func(detail::return_int(static_cast(&String::find_first_not_of)))), "find_first_not_of"); + m->add(fun(find_func(detail::return_int(static_cast(&String::find_last_not_of)))), "find_last_not_of"); m->add(fun(&String::c_str), "c_str"); m->add(fun(&String::data), "data");