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::containers
15 {
16 /** \addtogroup stlext_grp
17  * @{ */
18 
19 /** A generic proxy accessor template that only allows read-only access to the
20  * original binded STL container object. */
21 template <typename STLCONTAINER>
23 {
24  /** ctor: binds to source object */
26  /** (Deleted ctor) ignore copies (keep reference to original object) */
29  /** Don't copy the reference to the source object, but copy the contained
30  * data. This is only allowed if the size of the buffers coincide. */
33  {
34  ASSERT_EQUAL_(m_source.size(), o.m_source.size());
35  m_source = o.m_source;
36  return *this;
37  }
38  /** Transparent conversion to const ref to original source object. */
39  operator const STLCONTAINER&() const { return m_source; }
40  size_t size() const { return m_source.size(); }
41  const typename STLCONTAINER::value_type& operator[](const int i) const
42  {
43  return m_source[i];
44  }
45 
47  {
48  return m_source.begin();
49  }
50  typename STLCONTAINER::const_iterator end() const { return m_source.end(); }
51  typename STLCONTAINER::const_reverse_iterator rbegin() const
52  {
53  return m_source.rbegin();
54  }
55  typename STLCONTAINER::const_reverse_iterator rend() const
56  {
57  return m_source.rend();
58  }
59 
60  private:
61  STLCONTAINER& m_source;
62 };
63 
64 /** @} */ // end of grouping
65 }
66 
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
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: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020