diff --git a/CMakeLists.txt b/CMakeLists.txt index 44c8b6d..69aa2d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ list(APPEND CPACK_SOURCE_IGNORE_FILES ".swp") list(APPEND CPACK_SOURCE_IGNORE_FILES ".*~") set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/license.txt") -set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/readme.txt") +set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/readme.md") set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/description.txt") set(CPACK_PACKAGE_VERSION_MAJOR 4) diff --git a/include/chaiscript/dispatchkit/bootstrap_stl.hpp b/include/chaiscript/dispatchkit/bootstrap_stl.hpp index 40f9687..0a53201 100644 --- a/include/chaiscript/dispatchkit/bootstrap_stl.hpp +++ b/include/chaiscript/dispatchkit/bootstrap_stl.hpp @@ -176,6 +176,19 @@ namespace chaiscript return t_func(t_obj, p1); #ifdef BOOST_MSVC #pragma warning(pop) +#endif + } + + template + int return_int_impl_non_const(const boost::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 } @@ -185,6 +198,13 @@ namespace chaiscript return boost::bind(&return_int_impl, boost::function(boost::mem_fn(t_func)), _1, _2); } + template + boost::function return_int(size_t (T::*t_func)(P1) ) + { + return boost::bind(&return_int_impl_non_const, 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) { @@ -452,6 +472,11 @@ namespace chaiscript { m->add(fun(boost::function(detail::return_int(&ContainerType::count))), "count"); + + typedef size_t (ContainerType::*erase)(const typename ContainerType::key_type &); + erase eraseptr(&ContainerType::erase); + + m->add(fun(boost::function(detail::return_int(eraseptr))), "erase"); return m; } diff --git a/unittests/map.chai b/unittests/map.chai index a0a31ee..3fe753a 100644 --- a/unittests/map.chai +++ b/unittests/map.chai @@ -1 +1,13 @@ assert_equal([true, false, true], map([1,2,3], odd)) + + + +var m = ["a":1, "b":2]; + +assert_equal(1, m.count("a")) +assert_equal(0, m.count("c")) +assert_equal(1, m.erase("a")) +assert_equal(1, m.size()) +assert_equal(0, m.erase("a")) + +