d0e026b896cb0f17c2d6d31ab991d29392bd8bd1
[platform/upstream/boost.git] / boost / interprocess / indexes / null_index.hpp
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
13 #if defined(_MSC_VER)
14 #  pragma once
15 #endif
16
17 #include <boost/interprocess/detail/config_begin.hpp>
18 #include <boost/interprocess/detail/workaround.hpp>
19
20 #include <boost/interprocess/offset_ptr.hpp>
21
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
26 namespace boost {
27 namespace interprocess {
28
29 //!Null index type
30 //!used to save compilation time when
31 //!named indexes are not needed.
32 template <class MapConfig>
33 class null_index
34 {
35    #if !defined(BOOST_INTERPROCESS_DOXYGEN_INVOKED)
36    typedef typename MapConfig::
37       segment_manager_base    segment_manager_base;
38    #endif   //#ifndef BOOST_INTERPROCESS_DOXYGEN_INVOKED
39
40    public:
41    typedef int * iterator;
42    typedef const int * const_iterator;
43
44    //!begin() is equal
45    //!to end()
46    const_iterator begin() const
47    {  return const_iterator(0);  }
48
49    //!begin() is equal
50    //!to end()
51    iterator begin()
52    {  return iterator(0);  }
53
54    //!begin() is equal
55    //!to end()
56    const_iterator end() const
57    {  return const_iterator(0);  }
58
59    //!begin() is equal
60    //!to end()
61    iterator end()
62    {  return iterator(0);  }
63
64    //!Empty constructor
65    null_index(segment_manager_base *){}
66 };
67
68 }}   //namespace boost { namespace interprocess {
69
70 #include <boost/interprocess/detail/config_end.hpp>
71
72 #endif   //#ifndef BOOST_INTERPROCESS_NULL_INDEX_HPP