null_index.hpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. #ifndef BOOST_CONFIG_HPP
  13. # include <boost/config.hpp>
  14. #endif
  15. #
  16. #if defined(BOOST_HAS_PRAGMA_ONCE)
  17. # pragma once
  18. #endif
  19. #include <boost/interprocess/detail/config_begin.hpp>
  20. #include <boost/interprocess/detail/workaround.hpp>
  21. #include <boost/interprocess/offset_ptr.hpp>
  22. //!\file
  23. //!Describes a null index adaptor, so that if we don't want to construct
  24. //!named objects, we can use this null index type to save resources.
  25. namespace boost {
  26. namespace interprocess {
  27. //!Null index type
  28. //!used to save compilation time when
  29. //!named indexes are not needed.
  30. template <class MapConfig>
  31. class null_index
  32. {
  33. #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
  34. typedef typename MapConfig::
  35. segment_manager_base segment_manager_base;
  36. #endif //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
  37. public:
  38. typedef int * iterator;
  39. typedef const int * const_iterator;
  40. //!begin() is equal
  41. //!to end()
  42. const_iterator begin() const
  43. { return const_iterator(0); }
  44. //!begin() is equal
  45. //!to end()
  46. iterator begin()
  47. { return iterator(0); }
  48. //!begin() is equal
  49. //!to end()
  50. const_iterator end() const
  51. { return const_iterator(0); }
  52. //!begin() is equal
  53. //!to end()
  54. iterator end()
  55. { return iterator(0); }
  56. //!Empty constructor
  57. null_index(segment_manager_base *){}
  58. };
  59. }} //namespace boost { namespace interprocess {
  60. #include <boost/interprocess/detail/config_end.hpp>
  61. #endif //#ifndef BOOST_INTERPROCESS_NULL_INDEX_HPP