diff --git a/include/boost/mp11/map.hpp b/include/boost/mp11/map.hpp index 92c5164..30c4a64 100644 --- a/include/boost/mp11/map.hpp +++ b/include/boost/mp11/map.hpp @@ -46,7 +46,20 @@ template class M, class... U, class T> struct mp_map_replace_ template using mp_map_replace = typename detail::mp_map_replace_impl::type; // mp_map_update + // mp_map_erase +namespace detail +{ + +template struct mp_map_erase_impl +{ + template using _f = std::is_same, K>; + using type = mp_remove_if; +}; + +} // namespace detail + +template using mp_map_erase = typename detail::mp_map_erase_impl::type; } // namespace boost diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 6d2c767..48b993b 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -1,6 +1,6 @@ # Boost.Mp11 Library Test Jamfile # -# Copyright 2015 Peter Dimov +# Copyright 2015-2017 Peter Dimov # # Distributed under the Boost Software License, Version 1.0. # See accompanying file LICENSE_1_0.txt or copy at @@ -94,3 +94,4 @@ run mp_map_find.cpp : : : $(REQ) ; run mp_map_contains.cpp : : : $(REQ) ; run mp_map_insert.cpp : : : $(REQ) ; run mp_map_replace.cpp : : : $(REQ) ; +run mp_map_erase.cpp : : : $(REQ) ; diff --git a/test/mp_map_erase.cpp b/test/mp_map_erase.cpp new file mode 100644 index 0000000..c03ffc8 --- /dev/null +++ b/test/mp_map_erase.cpp @@ -0,0 +1,61 @@ + +// Copyright 2016, 2017 Peter Dimov. +// +// Distributed under the Boost Software License, Version 1.0. +// +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt + + +#include +#include +#include +#include +#include +#include + +int main() +{ + using boost::mp_map_erase; + using boost::mp_list; + using boost::mp_push_back; + + BOOST_TEST_TRAIT_TRUE((std::is_same, void>, mp_list<>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, int>, std::tuple<>>)); + + { + using M = mp_list, std::pair>; + + BOOST_TEST_TRAIT_TRUE((std::is_same, M>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_list>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_list>>)); + } + + { + using M = std::tuple, std::pair>; + + BOOST_TEST_TRAIT_TRUE((std::is_same, M>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, std::tuple>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, std::tuple>>)); + } + + { + using M = mp_list, mp_list, mp_list>; + + BOOST_TEST_TRAIT_TRUE((std::is_same, M>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_list, mp_list>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_list, mp_list>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, mp_list, mp_list>>)); + } + + { + using M = std::tuple, std::pair, std::tuple>; + + BOOST_TEST_TRAIT_TRUE((std::is_same, M>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, std::tuple, std::tuple>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, std::tuple, std::tuple>>)); + BOOST_TEST_TRAIT_TRUE((std::is_same, std::tuple, std::pair>>)); + } + + return boost::report_errors(); +}