diff --git a/include/chaiscript/dispatchkit/bootstrap_stl.hpp b/include/chaiscript/dispatchkit/bootstrap_stl.hpp index 40ff1df..ffbf341 100644 --- a/include/chaiscript/dispatchkit/bootstrap_stl.hpp +++ b/include/chaiscript/dispatchkit/bootstrap_stl.hpp @@ -148,82 +148,6 @@ namespace chaiscript }; namespace detail { - template - int return_int_impl(const std::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 - std::function return_int(size_t (T::*t_func)() const) - { - return std::bind(&return_int_impl, std::function(std::mem_fn(t_func)), std::placeholders::_1); - } - - template - int return_int_impl(const std::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 - int return_int_impl_non_const(const std::function &t_func, 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 - std::function return_int(size_t (T::*t_func)(P1) const) - { - return std::bind(&return_int_impl, std::function(std::mem_fn(t_func)), std::placeholders::_1, std::placeholders::_2); - } - - template - std::function return_int(size_t (T::*t_func)(P1) ) - { - return std::bind(&return_int_impl_non_const, std::function(std::mem_fn(t_func)), std::placeholders::_1, std::placeholders::_2); - } - - - template - int return_int_impl(const std::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 - std::function return_int(size_t (T::*t_func)(P1, P2) const) - { - return std::bind(&return_int_impl, std::function(std::mem_fn(t_func)), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3); - } template void insert(T &t_target, const T &t_other) @@ -483,11 +407,9 @@ namespace chaiscript { m->add(fun(&ContainerType::count), "count"); + typedef size_t (ContainerType::*erase_ptr)(const typename ContainerType::key_type &); - typedef size_t (ContainerType::*erase)(const typename ContainerType::key_type &); - erase eraseptr(&ContainerType::erase); - - m->add(fun(std::function(detail::return_int(eraseptr))), "erase"); + m->add(fun(static_cast(&ContainerType::erase)), "erase"); m->add(fun(&detail::insert), "insert"); @@ -621,6 +543,7 @@ namespace chaiscript typedef std::function find_func; + m->add(fun(find_func( [](const String *s, const String &f, int pos) { return s->find(f, pos); } )), "find"); m->add(fun(find_func( [](const String *s, const String &f, int pos) { return s->rfind(f, pos); } ) ), "rfind"); m->add(fun(find_func( [](const String *s, const String &f, int pos) { return s->find_first_of(f, pos); } ) ), "find_first_of"); @@ -630,7 +553,7 @@ namespace chaiscript m->add(fun( std::function( [](const String *s) { return s->c_str(); } ) ), "c_str"); m->add(fun( std::function( [](const String *s) { return s->data(); } ) ), "data"); - + m->add(fun( std::function( [](const String *s, int pos, int len) { return s->substr(pos, len); } ) ), "substr"); return m; } diff --git a/include/chaiscript/dispatchkit/proxy_functions_detail.hpp b/include/chaiscript/dispatchkit/proxy_functions_detail.hpp index 686db78..470cdc8 100644 --- a/include/chaiscript/dispatchkit/proxy_functions_detail.hpp +++ b/include/chaiscript/dispatchkit/proxy_functions_detail.hpp @@ -143,7 +143,6 @@ namespace chaiscript } } - } diff --git a/unittests/number_suffixes.chai b/unittests/number_suffixes.chai new file mode 100644 index 0000000..99ac03f --- /dev/null +++ b/unittests/number_suffixes.chai @@ -0,0 +1,11 @@ +assert_equal(true, int_type.bare_equal(1.get_type_info())) +assert_equal(true, unsigned_int_type.bare_equal(1u.get_type_info())) +assert_equal(true, unsigned_long_type.bare_equal(1lu.get_type_info())) +assert_equal(true, long_type.bare_equal(1l.get_type_info())) +assert_equal(true, int64_t_type.bare_equal(1ll.get_type_info())) +assert_equal(true, uint64_t_type.bare_equal(1ull.get_type_info())) + +assert_equal(true, double_type.bare_equal(1.6.get_type_info())) +assert_equal(true, float_type.bare_equal(1.6f.get_type_info())) +assert_equal(true, long_double_type.bare_equal(1.6l.get_type_info())) + diff --git a/unittests/string_substr.chai b/unittests/string_substr.chai new file mode 100644 index 0000000..19128bc --- /dev/null +++ b/unittests/string_substr.chai @@ -0,0 +1 @@ +assert_equal("3ab", "123abab".substr(2,3))