Main MRPT website > C++ reference for MRPT 1.9.9
ContainerReadOnlyProxyAccessor.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <cstdlib> // size_t
12 #include <mrpt/core/exceptions.h>
13 
14 namespace mrpt
15 {
16 namespace containers
17 {
18 /** \addtogroup stlext_grp
19  * @{ */
20 
21 /** A generic proxy accessor template that only allows read-only access to the
22  * original binded STL container object. */
23 template <typename STLCONTAINER>
25 {
26  /** ctor: binds to source object */
28  /** (Deleted ctor) ignore copies (keep reference to original object) */
31  /** Don't copy the reference to the source object, but copy the contained
32  * data. This is only allowed if the size of the buffers coincide. */
35  {
36  ASSERT_EQUAL_(m_source.size(), o.m_source.size());
37  m_source = o.m_source;
38  return *this;
39  }
40  /** Transparent conversion to const ref to original source object. */
41  operator const STLCONTAINER&() const { return m_source; }
42  size_t size() const { return m_source.size(); }
43  const typename STLCONTAINER::value_type& operator[](const int i) const
44  {
45  return m_source[i];
46  }
47 
49  {
50  return m_source.begin();
51  }
52  typename STLCONTAINER::const_iterator end() const { return m_source.end(); }
53  typename STLCONTAINER::const_reverse_iterator rbegin() const
54  {
55  return m_source.rbegin();
56  }
57  typename STLCONTAINER::const_reverse_iterator rend() const
58  {
59  return m_source.rend();
60  }
61 
62  private:
63  STLCONTAINER& m_source;
64 };
65 
66 /** @} */ // end of grouping
67 }
68 }
A generic proxy accessor template that only allows read-only access to the original binded STL contai...
#define ASSERT_EQUAL_(__A, __B)
Assert comparing two values, reporting their actual values upon failure.
Definition: exceptions.h:153
const STLCONTAINER::value_type & operator[](const int i) const
ContainerReadOnlyProxyAccessor< STLCONTAINER > & operator=(const ContainerReadOnlyProxyAccessor< STLCONTAINER > &o)
Don&#39;t copy the reference to the source object, but copy the contained data.
STLCONTAINER::const_reverse_iterator rbegin() const
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
ContainerReadOnlyProxyAccessor(STLCONTAINER &source)
ctor: binds to source object
GLsizei GLsizei GLchar * source
Definition: glext.h:4082
const Scalar * const_iterator
Definition: eigen_plugins.h:27
STLCONTAINER::const_reverse_iterator rend() const



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019