forked from boostorg/mp11
Add mp_map_find.
This commit is contained in:
@@ -1,21 +1,27 @@
|
|||||||
#ifndef BOOST_MP11_MAP_HPP_INCLUDED
|
#ifndef BOOST_MP11_MAP_HPP_INCLUDED
|
||||||
#define BOOST_MP11_MAP_HPP_INCLUDED
|
#define BOOST_MP11_MAP_HPP_INCLUDED
|
||||||
|
|
||||||
// Copyright 2015 Peter Dimov.
|
// Copyright 2015, 2016 Peter Dimov.
|
||||||
//
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
//
|
//
|
||||||
// See accompanying file LICENSE_1_0.txt or copy at
|
// See accompanying file LICENSE_1_0.txt or copy at
|
||||||
// http://www.boost.org/LICENSE_1_0.txt
|
// http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
|
#include <boost/mp11/detail/mp_map_find.hpp>
|
||||||
|
#include <boost/mp11/integral.hpp>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
|
|
||||||
// mp_map_find<M, K>
|
|
||||||
// mp_map_contains<M, K>
|
// mp_map_contains<M, K>
|
||||||
|
template<class M, class K> using mp_map_contains = mp_not<std::is_same<mp_map_find<M, K>, void>>;
|
||||||
|
|
||||||
// mp_map_insert<M, T>
|
// mp_map_insert<M, T>
|
||||||
// mp_map_replace<M, T>
|
// mp_map_replace<M, T>
|
||||||
// mp_map_update<M, T, F>
|
// mp_map_update<M, T, F>
|
||||||
|
// mp_map_erase<M, K>
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
|
@@ -88,3 +88,6 @@ run mp_all.cpp : : : $(REQ) ;
|
|||||||
run mp_and.cpp : : : $(REQ) ;
|
run mp_and.cpp : : : $(REQ) ;
|
||||||
run mp_any.cpp : : : $(REQ) ;
|
run mp_any.cpp : : : $(REQ) ;
|
||||||
run mp_or.cpp : : : $(REQ) ;
|
run mp_or.cpp : : : $(REQ) ;
|
||||||
|
|
||||||
|
# map
|
||||||
|
run mp_map_find.cpp : : : $(REQ) ;
|
||||||
|
48
test/mp_map_find.cpp
Normal file
48
test/mp_map_find.cpp
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
|
||||||
|
// Copyright 2016 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 <boost/mp11/map.hpp>
|
||||||
|
#include <boost/mp11/list.hpp>
|
||||||
|
#include <boost/core/lightweight_test_trait.hpp>
|
||||||
|
#include <type_traits>
|
||||||
|
#include <tuple>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
using boost::mp_map_find;
|
||||||
|
using boost::mp_list;
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<mp_list<>, char>, void>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::tuple<>, int>, void>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<mp_list<std::pair<int, int const>, std::pair<long, long const>>, char>, void>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<mp_list<std::pair<int, int const>, std::pair<long, long const>>, int>, std::pair<int, int const>>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<mp_list<std::pair<int, int const>, std::pair<long, long const>>, long>, std::pair<long, long const>>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::tuple<std::pair<int, int const>, std::pair<long, long const>>, char>, void>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::tuple<std::pair<int, int const>, std::pair<long, long const>>, int>, std::pair<int, int const>>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::tuple<std::pair<int, int const>, std::pair<long, long const>>, long>, std::pair<long, long const>>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::pair<std::pair<int, int const>, std::pair<long, long const>>, char>, void>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::pair<std::pair<int, int const>, std::pair<long, long const>>, int>, std::pair<int, int const>>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::pair<std::pair<int, int const>, std::pair<long, long const>>, long>, std::pair<long, long const>>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<mp_list<mp_list<int>, mp_list<long, long>, mp_list<long long, long long, long long>>, char>, void>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<mp_list<mp_list<int>, mp_list<long, long>, mp_list<long long, long long, long long>>, int>, mp_list<int>>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<mp_list<mp_list<int>, mp_list<long, long>, mp_list<long long, long long, long long>>, long>, mp_list<long, long>>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<mp_list<mp_list<int>, mp_list<long, long>, mp_list<long long, long long, long long>>, long long>, mp_list<long long, long long, long long>>));
|
||||||
|
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::tuple<mp_list<int>, std::pair<long, long>, std::tuple<long long, long long, long long>>, char>, void>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::tuple<mp_list<int>, std::pair<long, long>, std::tuple<long long, long long, long long>>, int>, mp_list<int>>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::tuple<mp_list<int>, std::pair<long, long>, std::tuple<long long, long long, long long>>, long>, std::pair<long, long>>));
|
||||||
|
BOOST_TEST_TRAIT_TRUE((std::is_same<mp_map_find<std::tuple<mp_list<int>, std::pair<long, long>, std::tuple<long long, long long, long long>>, long long>, std::tuple<long long, long long, long long>>));
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
Reference in New Issue
Block a user