node_type.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* Copyright 2003-2013 Joaquin M Lopez Munoz.
  2. * Distributed under the Boost Software License, Version 1.0.
  3. * (See accompanying file LICENSE_1_0.txt or copy at
  4. * http://www.boost.org/LICENSE_1_0.txt)
  5. *
  6. * See http://www.boost.org/libs/multi_index for library home page.
  7. */
  8. #ifndef BOOST_MULTI_INDEX_DETAIL_NODE_TYPE_HPP
  9. #define BOOST_MULTI_INDEX_DETAIL_NODE_TYPE_HPP
  10. #if defined(_MSC_VER)
  11. #pragma once
  12. #endif
  13. #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
  14. #include <boost/detail/workaround.hpp>
  15. #include <boost/mpl/bind.hpp>
  16. #include <boost/mpl/reverse_iter_fold.hpp>
  17. #include <boost/mpl/deref.hpp>
  18. #include <boost/multi_index_container_fwd.hpp>
  19. #include <boost/multi_index/detail/header_holder.hpp>
  20. #include <boost/multi_index/detail/index_node_base.hpp>
  21. #include <boost/multi_index/detail/is_index_list.hpp>
  22. #include <boost/static_assert.hpp>
  23. namespace boost{
  24. namespace multi_index{
  25. namespace detail{
  26. /* MPL machinery to construct the internal node type associated to an
  27. * index list.
  28. */
  29. struct index_node_applier
  30. {
  31. template<typename IndexSpecifierIterator,typename Super>
  32. struct apply
  33. {
  34. typedef typename mpl::deref<IndexSpecifierIterator>::type index_specifier;
  35. typedef typename index_specifier::
  36. BOOST_NESTED_TEMPLATE node_class<Super>::type type;
  37. };
  38. };
  39. template<typename Value,typename IndexSpecifierList,typename Allocator>
  40. struct multi_index_node_type
  41. {
  42. BOOST_STATIC_ASSERT(detail::is_index_list<IndexSpecifierList>::value);
  43. typedef typename mpl::reverse_iter_fold<
  44. IndexSpecifierList,
  45. index_node_base<Value,Allocator>,
  46. mpl::bind2<index_node_applier,mpl::_2,mpl::_1>
  47. >::type type;
  48. };
  49. } /* namespace multi_index::detail */
  50. } /* namespace multi_index */
  51. } /* namespace boost */
  52. #endif