null_index.hpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2005-2012. Distributed under the Boost
  4. // Software License, Version 1.0. (See accompanying file
  5. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // See http://www.boost.org/libs/interprocess for documentation.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. #ifndef BOOST_INTERPROCESS_NULL_INDEX_HPP
  11. #define BOOST_INTERPROCESS_NULL_INDEX_HPP
  12. #include <boost/interprocess/detail/config_begin.hpp>
  13. #include <boost/interprocess/detail/workaround.hpp>
  14. #include <boost/interprocess/offset_ptr.hpp>
  15. //!\file
  16. //!Describes a null index adaptor, so that if we don't want to construct
  17. //!named objects, we can use this null index type to save resources.
  18. namespace boost {
  19. namespace interprocess {
  20. //!Null index type
  21. //!used to save compilation time when
  22. //!named indexes are not needed.
  23. template <class MapConfig>
  24. class null_index
  25. {
  26. /// @cond
  27. typedef typename MapConfig::
  28. segment_manager_base segment_manager_base;
  29. /// @endcond
  30. public:
  31. typedef void * iterator;
  32. typedef const void * const_iterator;
  33. //!begin() is equal
  34. //!to end()
  35. const_iterator begin() const
  36. { return const_iterator(0); }
  37. //!begin() is equal
  38. //!to end()
  39. iterator begin()
  40. { return iterator(0); }
  41. //!begin() is equal
  42. //!to end()
  43. const_iterator end() const
  44. { return const_iterator(0); }
  45. //!begin() is equal
  46. //!to end()
  47. iterator end()
  48. { return iterator(0); }
  49. //!Empty constructor
  50. null_index(segment_manager_base *){}
  51. };
  52. }} //namespace boost { namespace interprocess {
  53. #include <boost/interprocess/detail/config_end.hpp>
  54. #endif //#ifndef BOOST_INTERPROCESS_NULL_INDEX_HPP