insert_impl.hpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef BOOST_MPL_MAP_AUX_INSERT_IMPL_HPP_INCLUDED
  2. #define BOOST_MPL_MAP_AUX_INSERT_IMPL_HPP_INCLUDED
  3. // Copyright Aleksey Gurtovoy 2003-2004
  4. // Copyright David Abrahams 2003-2004
  5. //
  6. // Distributed under the Boost Software License, Version 1.0.
  7. // (See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. // See http://www.boost.org/libs/mpl for documentation.
  11. // $Id$
  12. // $Date$
  13. // $Revision$
  14. #include <boost/mpl/insert_fwd.hpp>
  15. #include <boost/mpl/next_prior.hpp>
  16. #include <boost/mpl/map/aux_/contains_impl.hpp>
  17. #include <boost/mpl/map/aux_/item.hpp>
  18. #include <boost/mpl/map/aux_/tag.hpp>
  19. #include <boost/mpl/aux_/na.hpp>
  20. #include <boost/mpl/aux_/config/typeof.hpp>
  21. namespace boost { namespace mpl {
  22. namespace aux {
  23. template< typename Map, typename Pair >
  24. struct map_insert_impl
  25. : if_<
  26. contains_impl<aux::map_tag>::apply<Map,Pair>
  27. , Map
  28. #if defined(BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES)
  29. , m_item<
  30. typename Pair::first
  31. , typename Pair::second
  32. , Map
  33. >
  34. #else
  35. , m_item<
  36. Map::order::value
  37. , typename Pair::first
  38. , typename Pair::second
  39. , Map
  40. >
  41. #endif
  42. >
  43. {
  44. };
  45. }
  46. template<>
  47. struct insert_impl< aux::map_tag >
  48. {
  49. template<
  50. typename Map
  51. , typename PosOrKey
  52. , typename KeyOrNA
  53. >
  54. struct apply
  55. : aux::map_insert_impl<
  56. Map
  57. , typename if_na<KeyOrNA,PosOrKey>::type
  58. >
  59. {
  60. };
  61. };
  62. }}
  63. #endif // BOOST_MPL_MAP_AUX_INSERT_IMPL_HPP_INCLUDED