insert_impl.hpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef BOOST_MPL_SET_AUX_INSERT_IMPL_HPP_INCLUDED
  2. #define BOOST_MPL_SET_AUX_INSERT_IMPL_HPP_INCLUDED
  3. // Copyright Aleksey Gurtovoy 2003-2007
  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/set/aux_/has_key_impl.hpp>
  16. #include <boost/mpl/set/aux_/item.hpp>
  17. #include <boost/mpl/set/aux_/tag.hpp>
  18. #include <boost/mpl/identity.hpp>
  19. #include <boost/mpl/base.hpp>
  20. #include <boost/mpl/eval_if.hpp>
  21. #include <boost/mpl/aux_/na.hpp>
  22. #include <boost/type_traits/is_same.hpp>
  23. namespace boost { namespace mpl {
  24. namespace aux {
  25. template< typename Set, typename T > struct set_insert_impl
  26. : eval_if<
  27. has_key_impl<aux::set_tag>::apply<Set,T>
  28. , identity<Set>
  29. , eval_if<
  30. is_same< T,typename Set::last_masked_ >
  31. , base<Set>
  32. , identity< s_item<T,typename Set::item_> >
  33. >
  34. >
  35. {
  36. };
  37. }
  38. template<>
  39. struct insert_impl< aux::set_tag >
  40. {
  41. template<
  42. typename Set
  43. , typename PosOrKey
  44. , typename KeyOrNA
  45. >
  46. struct apply
  47. : aux::set_insert_impl<
  48. Set
  49. , typename if_na<KeyOrNA,PosOrKey>::type
  50. >
  51. {
  52. };
  53. };
  54. }}
  55. #endif // BOOST_MPL_SET_AUX_INSERT_IMPL_HPP_INCLUDED