non_unique_views_helper.hpp 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Boost.Bimap
  2. //
  3. // Copyright (c) 2006-2007 Matias Capeletto
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. /// \file detail/non_unique_views_helper.hpp
  9. /// \brief Details for non unique views
  10. #ifndef BOOST_BIMAP_DETAIL_NON_UNIQUE_VIEWS_HELPER_HPP
  11. #define BOOST_BIMAP_DETAIL_NON_UNIQUE_VIEWS_HELPER_HPP
  12. #if defined(_MSC_VER)
  13. #pragma once
  14. #endif
  15. #include <boost/config.hpp>
  16. /*===========================================================================*/
  17. #define BOOST_BIMAP_NON_UNIQUE_VIEW_INSERT_FUNCTIONS \
  18. \
  19. template <class InputIterator> \
  20. void insert(InputIterator iterBegin, InputIterator iterEnd) \
  21. { \
  22. for( ; iterBegin != iterEnd ; ++iterBegin ) \
  23. { \
  24. this->base().insert( \
  25. this->template functor< \
  26. BOOST_DEDUCED_TYPENAME base_::value_to_base>()( \
  27. BOOST_DEDUCED_TYPENAME base_::value_type(*iterBegin)) ); \
  28. } \
  29. } \
  30. \
  31. std::pair<BOOST_DEDUCED_TYPENAME base_::iterator, bool> insert( \
  32. BOOST_DEDUCED_TYPENAME ::boost::call_traits< \
  33. BOOST_DEDUCED_TYPENAME base_::value_type >::param_type x) \
  34. { \
  35. typedef BOOST_DEDUCED_TYPENAME base_::base_type::iterator base_iterator; \
  36. \
  37. std::pair< base_iterator, bool > r( \
  38. this->base().insert( \
  39. this->template functor< \
  40. BOOST_DEDUCED_TYPENAME base_::value_to_base>()(x) ) \
  41. ); \
  42. \
  43. return std::pair<typename base_::iterator, bool>( \
  44. this->template functor< \
  45. BOOST_DEDUCED_TYPENAME base_::iterator_from_base>()(r.first), \
  46. r.second \
  47. ); \
  48. } \
  49. \
  50. BOOST_DEDUCED_TYPENAME base_::iterator insert( \
  51. BOOST_DEDUCED_TYPENAME base_::iterator pos, \
  52. BOOST_DEDUCED_TYPENAME ::boost::call_traits< \
  53. BOOST_DEDUCED_TYPENAME base_::value_type >::param_type x) \
  54. { \
  55. return this->template functor< \
  56. BOOST_DEDUCED_TYPENAME base_::iterator_from_base>()( \
  57. this->base().insert( \
  58. this->template functor< \
  59. BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(pos), \
  60. this->template functor< \
  61. BOOST_DEDUCED_TYPENAME base_::value_to_base>()(x)) \
  62. ); \
  63. }
  64. /*===========================================================================*/
  65. #endif // BOOST_BIMAP_DETAIL_NON_UNIQUE_VIEWS_HELPER_HPP