Metafunction for generating a list of elements that can be either stored in an external vectror or, if the elements are constant, inside the container itself. More...
#include <proxyVector.hpp>

Public Types | |
typedef ProxyVectorIterator< typename std::add_const< value_no_cv_t >::type, container_type > | const_iterator |
typedef container_type::const_pointer | const_pointer |
typedef container_type::const_reference | const_reference |
typedef std::vector< value_no_cv_t > | container_type |
typedef ProxyVectorIterator< value_t, container_type > | iterator |
typedef std::conditional< std::is_const< value_t >::value, typenamecontainer_type::const_pointer, typenamecontainer_type::pointer >::type | pointer |
typedef std::conditional< std::is_const< value_t >::value, typenamecontainer_type::const_reference, typenamecontainer_type::reference >::type | reference |
typedef container_type::const_pointer | storage_const_pointer |
typedef container_type::pointer | storage_pointer |
typedef value_t | value_type |
Public Member Functions | |
ProxyVector () | |
template<typename U = value_t, typename std::enable_if< std::is_const< U >::value, int >::type = 0> | |
ProxyVector (__PXV_POINTER__ data, std::size_t size) | |
template<typename U = value_t, typename std::enable_if<!std::is_const< U >::value, int >::type = 0> | |
ProxyVector (__PXV_POINTER__ data, std::size_t size) | |
template<typename U = value_t, typename std::enable_if< std::is_const< U >::value, int >::type = 0> | |
ProxyVector (__PXV_POINTER__ data, std::size_t size, std::size_t capacity) | |
ProxyVector (const ProxyVector &other) | |
ProxyVector (ProxyVector &&other) | |
template<typename U = value_t, typename std::enable_if< std::is_const< U >::value, int >::type = 0> | |
ProxyVector (std::size_t size) | |
template<typename U = value_t, typename std::enable_if< std::is_const< U >::value, int >::type = 0> | |
ProxyVector (std::size_t size, std::size_t capacity) | |
template<typename U = value_t, typename std::enable_if<!std::is_const< U >::value, int >::type = 0> | |
__PXV_REFERENCE__ | at (std::size_t n) |
__PXV_CONST_REFERENCE__ | at (std::size_t n) const |
template<typename U = value_t, typename std::enable_if<!std::is_const< U >::value, int >::type = 0> | |
__PXV_REFERENCE__ | back () |
__PXV_CONST_REFERENCE__ | back () const |
template<typename U = value_t, typename std::enable_if<!std::is_const< U >::value, int >::type = 0> | |
__PXV_ITERATOR__ | begin () |
__PXV_CONST_ITERATOR__ | begin () const |
__PXV_CONST_ITERATOR__ | cbegin () |
__PXV_CONST_ITERATOR__ | cend () |
__PXV_CONST_POINTER__ | data () const noexcept |
template<typename U = value_t, typename std::enable_if<!std::is_const< U >::value, int >::type = 0> | |
__PXV_POINTER__ | data () noexcept |
bool | empty () const |
template<typename U = value_t, typename std::enable_if<!std::is_const< U >::value, int >::type = 0> | |
__PXV_ITERATOR__ | end () |
__PXV_CONST_ITERATOR__ | end () const |
template<typename U = value_t, typename std::enable_if<!std::is_const< U >::value, int >::type = 0> | |
__PXV_REFERENCE__ | front () |
__PXV_CONST_REFERENCE__ | front () const |
ProxyVector & | operator= (const ProxyVector &other) |
ProxyVector & | operator= (ProxyVector &&other) |
bool | operator== (const ProxyVector &other) const |
template<typename U = value_t, typename std::enable_if<!std::is_const< U >::value, int >::type = 0> | |
__PXV_REFERENCE__ | operator[] (std::size_t n) |
__PXV_CONST_REFERENCE__ | operator[] (std::size_t n) const |
template<typename U = value_t, typename std::enable_if< std::is_const< U >::value, int >::type = 0> | |
void | set (__PXV_POINTER__ data, std::size_t size) |
template<typename U = value_t, typename std::enable_if<!std::is_const< U >::value, int >::type = 0> | |
void | set (__PXV_POINTER__ data, std::size_t size) |
template<typename U = value_t, typename std::enable_if< std::is_const< U >::value, int >::type = 0> | |
void | set (__PXV_POINTER__ data, std::size_t size, std::size_t capacity) |
std::size_t | size () const |
__PXV_STORAGE_CONST_POINTER__ | storedData () const noexcept |
__PXV_STORAGE_POINTER__ | storedData () noexcept |
template<typename U = value_t, typename std::enable_if< std::is_const< U >::value, int >::type = 0> | |
container_type * | storedDataContainer (bool forceCreation=false) |
template<typename U = value_t, typename std::enable_if< std::is_const< U >::value, int >::type = 0> | |
const container_type * | storedDataContainer (bool forceCreation=false) const |
void | swap (ProxyVector &other) |
Static Public Attributes | |
static constexpr __PXV_POINTER__ | INTERNAL_STORAGE = nullptr |
Detailed Description
class bitpit::ProxyVector< value_t, thread_safe >
Metafunction for generating a list of elements that can be either stored in an external vectror or, if the elements are constant, inside the container itself.
Usage: Use ProxyVector<value_t>
to declare a list of elements that can be either stored in an external vectror or, if the elements are constant, inside the container itself. When the ProxyVector is destroyed, the elements of the list will be destroyed only if owned by the ProxyVector o bject itself.
- Template Parameters
-
value_t is the type of the objects handled by the ProxyVector thread_safe controls if it is safe to use the container in a multi-threaded code
Definition at line 291 of file proxyVector.hpp.
Member Typedef Documentation
◆ const_iterator
typedef ProxyVectorIterator<typename std::add_const<value_no_cv_t>::type, container_type> bitpit::ProxyVector< value_t, thread_safe >::const_iterator |
Constant iterator for the container
Definition at line 316 of file proxyVector.hpp.
◆ const_pointer
typedef container_type::const_pointer bitpit::ProxyVector< value_t, thread_safe >::const_pointer |
Constant pointer
Definition at line 330 of file proxyVector.hpp.
◆ const_reference
typedef container_type::const_reference bitpit::ProxyVector< value_t, thread_safe >::const_reference |
Constant reference
Definition at line 354 of file proxyVector.hpp.
◆ container_type
typedef std::vector<value_no_cv_t> bitpit::ProxyVector< value_t, thread_safe >::container_type |
Container type
Definition at line 301 of file proxyVector.hpp.
◆ iterator
typedef ProxyVectorIterator<value_t, container_type> bitpit::ProxyVector< value_t, thread_safe >::iterator |
Iterator for the container
Definition at line 311 of file proxyVector.hpp.
◆ pointer
typedef std::conditional<std::is_const<value_t>::value,typenamecontainer_type::const_pointer,typenamecontainer_type::pointer>::type bitpit::ProxyVector< value_t, thread_safe >::pointer |
Pointer type
Definition at line 325 of file proxyVector.hpp.
◆ reference
typedef std::conditional<std::is_const<value_t>::value,typenamecontainer_type::const_reference,typenamecontainer_type::reference>::type bitpit::ProxyVector< value_t, thread_safe >::reference |
Reference type
Definition at line 349 of file proxyVector.hpp.
◆ storage_const_pointer
typedef container_type::const_pointer bitpit::ProxyVector< value_t, thread_safe >::storage_const_pointer |
Constant storage pointer
Definition at line 340 of file proxyVector.hpp.
◆ storage_pointer
typedef container_type::pointer bitpit::ProxyVector< value_t, thread_safe >::storage_pointer |
Storage pointer type
Definition at line 335 of file proxyVector.hpp.
◆ value_type
typedef value_t bitpit::ProxyVector< value_t, thread_safe >::value_type |
Type of data stored in the container
Definition at line 306 of file proxyVector.hpp.
Constructor & Destructor Documentation
◆ ProxyVector() [1/7]
bitpit::ProxyVector< value_t, thread_safe >::ProxyVector | ( | ) |
Constructor
Definition at line 533 of file proxyVector.tpp.
◆ ProxyVector() [2/7]
bitpit::ProxyVector< value_t, thread_safe >::ProxyVector | ( | std::size_t | size | ) |
Constructor
The container will create an internal storage that later can be filled with data. This is allowed because the container points to constant data, i.e., the container is not allowed to change the data it points to. Having the data stored internallt or pointing to external data doesn't change the behaviour of the container: in both cases it acts as a proxy to some constant data.
- Parameters
-
size is the number elements contained in the data
Definition at line 552 of file proxyVector.tpp.
◆ ProxyVector() [3/7]
bitpit::ProxyVector< value_t, thread_safe >::ProxyVector | ( | __PXV_POINTER__ | data, |
std::size_t | size ) |
Constructor
The container will create an internal storage that later can be filled with data. This is allowed because the container points to constant data, i.e., the container is not allowed to change the data it points to. Having the data stored internallt or pointing to external data doesn't change the behaviour of the container: in both cases it acts as a proxy to some constant data.
- Parameters
-
data a pointer to the data size is the number elements contained in the data
Constructor
Containers that point to non-constant data cannot use the internal storage. This guarantees that all the pointers returned by the container are always pointing to the original data (i.e., the container acts as a proxy to the original data).
- Parameters
-
data a pointer to the data size is the number elements contained in the data
Definition at line 595 of file proxyVector.tpp.
◆ ProxyVector() [4/7]
bitpit::ProxyVector< value_t, thread_safe >::ProxyVector | ( | std::size_t | size, |
std::size_t | capacity ) |
Constructor
The container will create an internal storage that later can be filled with data. This is allowed because the container points to constant data, i.e., the container is not allowed to change the data it points to. Having the data stored internallt or pointing to external data doesn't change the behaviour of the container: in both cases it acts as a proxy to some constant data.
- Parameters
-
size is the number elements contained in the data capacity is the size of the internal storage space expressed in number of elements, the capacity of the container cannot be smaller than the size of the data, if a smaller capacity is specified the storage will be resized using data size
Definition at line 575 of file proxyVector.tpp.
◆ ProxyVector() [5/7]
bitpit::ProxyVector< value_t, thread_safe >::ProxyVector | ( | __PXV_POINTER__ | data, |
std::size_t | size, | ||
std::size_t | capacity ) |
Constructor
If data is set to INTERNAL_STORAGE, the container will create an internal storage that later can be filled with data. This is allowed because the container points to constant data, i.e., the container is not allowed to change the data it points to. Having the data stored internallt or pointing to external data doesn't change the behaviour of the container: in both cases it acts as a proxy to some constant data.
- Parameters
-
data a pointer to the data size is the number elements contained in the data capacity is the size of the internal storage space expressed in number of elements, the capacity of the container cannot be smaller than the size of the data, if a smaller capacity is specified the storage will be resized using data size
Definition at line 619 of file proxyVector.tpp.
◆ ProxyVector() [6/7]
bitpit::ProxyVector< value_t, thread_safe >::ProxyVector | ( | const ProxyVector< value_t, thread_safe > & | other | ) |
Copy constructor.
- Parameters
-
other is another container whose content is copied in this container
Definition at line 649 of file proxyVector.tpp.
◆ ProxyVector() [7/7]
bitpit::ProxyVector< value_t, thread_safe >::ProxyVector | ( | ProxyVector< value_t, thread_safe > && | other | ) |
Move constructor.
We need to explicitly implement the move constructor to workaround a bug in gcc, see:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60796 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57728
- Parameters
-
other is another container whose content is moved in this container
Definition at line 666 of file proxyVector.tpp.
Member Function Documentation
◆ at() [1/2]
__PXV_REFERENCE__ bitpit::ProxyVector< value_t, thread_safe >::at | ( | std::size_t | n | ) |
Returns a reference to the specified element.
- Parameters
-
n is the position of the requested element
- Returns
- A reference to the specified element.
Definition at line 1008 of file proxyVector.tpp.
◆ at() [2/2]
__PXV_CONST_REFERENCE__ bitpit::ProxyVector< value_t, thread_safe >::at | ( | std::size_t | n | ) | const |
Returns a constant reference to the specified element.
- Parameters
-
n is the position of the requested element
- Returns
- A constant reference to the specified element.
Definition at line 1020 of file proxyVector.tpp.
◆ back() [1/2]
__PXV_REFERENCE__ bitpit::ProxyVector< value_t, thread_safe >::back | ( | ) |
Gets a reference to the last element in the container.
- Returns
- A reference to the last element in the container.
Definition at line 1055 of file proxyVector.tpp.
◆ back() [2/2]
__PXV_CONST_REFERENCE__ bitpit::ProxyVector< value_t, thread_safe >::back | ( | ) | const |
Gets a constant reference to the last element in the container.
- Returns
- A constant reference to the last element in the container.
Definition at line 1066 of file proxyVector.tpp.
◆ begin() [1/2]
__PXV_ITERATOR__ bitpit::ProxyVector< value_t, thread_safe >::begin | ( | ) |
Returns an iterator pointing to the first element in the container.
- Returns
- An iterator pointing to the first element in the container.
Definition at line 1078 of file proxyVector.tpp.
◆ begin() [2/2]
__PXV_CONST_ITERATOR__ bitpit::ProxyVector< value_t, thread_safe >::begin | ( | ) | const |
Returns a constant iterator pointing to the first element in the container.
- Returns
- A constant iterator pointing to the first element in the container.
Definition at line 1089 of file proxyVector.tpp.
◆ cbegin()
__PXV_CONST_ITERATOR__ bitpit::ProxyVector< value_t, thread_safe >::cbegin | ( | ) |
Returns a constant iterator pointing to the first element in the container.
- Returns
- A constant iterator pointing to the first element in the container.
Definition at line 1125 of file proxyVector.tpp.
◆ cend()
__PXV_CONST_ITERATOR__ bitpit::ProxyVector< value_t, thread_safe >::cend | ( | ) |
Returns a constant iterator referring to the past-the-end element in the container.
git gui
\result A constant iterator referring to the past-the-end element in the container.
Definition at line 1139 of file proxyVector.tpp.
◆ data() [1/2]
|
noexcept |
Returns a direct constant pointer to the memory where the elments are stored.
- Returns
- A direct constant pointer to the memory where the elments are stored.
Definition at line 970 of file proxyVector.tpp.
◆ data() [2/2]
|
noexcept |
Returns a direct pointer to the memory where the elments are stored.
- Returns
- A direct pointer to the memory where the elments are stored.
Definition at line 957 of file proxyVector.tpp.
◆ empty()
bool bitpit::ProxyVector< value_t, thread_safe >::empty | ( | ) | const |
Tests whether the container is empty.
- Returns
- true if the container size is 0, false otherwise.
Definition at line 934 of file proxyVector.tpp.
◆ end() [1/2]
__PXV_ITERATOR__ bitpit::ProxyVector< value_t, thread_safe >::end | ( | ) |
Returns an iterator referring to the past-the-end element in the container.
- Returns
- An iterator referring to the past-the-end element in the container.
Definition at line 1101 of file proxyVector.tpp.
◆ end() [2/2]
__PXV_CONST_ITERATOR__ bitpit::ProxyVector< value_t, thread_safe >::end | ( | ) | const |
Returns a constant iterator referring to the past-the-end element in the container.
- Returns
- A constant iterator referring to the past-the-end element in the container.
Definition at line 1114 of file proxyVector.tpp.
◆ front() [1/2]
__PXV_REFERENCE__ bitpit::ProxyVector< value_t, thread_safe >::front | ( | ) |
Gets a reference to the first element in the container.
- Returns
- A reference to the first element in the container.
Definition at line 1032 of file proxyVector.tpp.
◆ front() [2/2]
__PXV_CONST_REFERENCE__ bitpit::ProxyVector< value_t, thread_safe >::front | ( | ) | const |
Gets a constant reference to the first element in the container.
- Returns
- A constant reference to the first element in the container.
Definition at line 1043 of file proxyVector.tpp.
◆ operator=() [1/2]
ProxyVector< value_t, thread_safe > & bitpit::ProxyVector< value_t, thread_safe >::operator= | ( | const ProxyVector< value_t, thread_safe > & | other | ) |
Copy assignment operator.
Assigns new contents to the container, replacing its current contents, and modifying its size accordingly.
- Parameters
-
other is another container whose content is copied in this container
Definition at line 680 of file proxyVector.tpp.
◆ operator=() [2/2]
ProxyVector< value_t, thread_safe > & bitpit::ProxyVector< value_t, thread_safe >::operator= | ( | ProxyVector< value_t, thread_safe > && | other | ) |
Move assignment operator.
Assigns new contents to the container, replacing its current contents, and modifying its size accordingly.
We need to explicitly implement the move assignment operator to workaround a bug in gcc, see:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60796 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57728
- Parameters
-
other is another container whose content is moved in this container
Definition at line 705 of file proxyVector.tpp.
◆ operator==()
bool bitpit::ProxyVector< value_t, thread_safe >::operator== | ( | const ProxyVector< value_t, thread_safe > & | other | ) | const |
Tests whether two containers are equal.
- Returns
- true if the containers are equal, false otherwise.
Definition at line 907 of file proxyVector.tpp.
◆ operator[]() [1/2]
__PXV_REFERENCE__ bitpit::ProxyVector< value_t, thread_safe >::operator[] | ( | std::size_t | n | ) |
Returns a reference to the specified element.
- Parameters
-
n is the position of the requested element
- Returns
- A reference to the specified element.
Definition at line 983 of file proxyVector.tpp.
◆ operator[]() [2/2]
__PXV_CONST_REFERENCE__ bitpit::ProxyVector< value_t, thread_safe >::operator[] | ( | std::size_t | n | ) | const |
Returns a constant reference to the specified element.
- Parameters
-
n is the position of the requested element
- Returns
- A constant reference to the specified element.
Definition at line 995 of file proxyVector.tpp.
◆ set() [1/2]
void bitpit::ProxyVector< value_t, thread_safe >::set | ( | __PXV_POINTER__ | data, |
std::size_t | size ) |
Sets the content of the container.
If data is set to INTERNAL_STORAGE, the container will create an internal storage that later can be filled with data. This is allowed because the container points to constant data, i.e., the container is not allowed to change the data it points to. Having the data stored internallt or pointing to external data doesn't change the behaviour of the container: in both cases it acts as a proxy to some constant data.
- Parameters
-
data a pointer to the data, if the value INTERNAL_STORAGE is specified, the proxy will point to the data contained in the internal storage size is the number elements contained in the data
Sets the content of the container.
Containers that point to non-constant data cannot use the internal storage. This guarantees that all the pointers returned by the container are always pointing to the original data (i.e., the container acts as a proxy to the original data).
- Parameters
-
data a pointer to the data, containers that point to non-constant data cannot use the internal storage, hence the value INTERNAL_STORAGE in not allowed size is the number elements contained in the data
Definition at line 732 of file proxyVector.tpp.
◆ set() [2/2]
void bitpit::ProxyVector< value_t, thread_safe >::set | ( | __PXV_POINTER__ | data, |
std::size_t | size, | ||
std::size_t | capacity ) |
Sets the content of the container.
If data is set to INTERNAL_STORAGE, the container will create an internal storage that later can be filled with data. This is allowed because the container points to constant data, i.e., the container is not allowed to change the data it points to. Having the data stored internallt or pointing to external data doesn't change the behaviour of the container: in both cases it acts as a proxy to some constant data.
- Parameters
-
data a pointer to the data, if the value INTERNAL_STORAGE is specified, the proxy will point to the data contained in the internal storage size is the number elements contained in the data capacity is the number elements the internal contained should be able to contain, the capacity of the container cannot be smaller thatn the size of the data, if a smaller capacity is specified the storage will be resize using data size
Definition at line 764 of file proxyVector.tpp.
◆ size()
std::size_t bitpit::ProxyVector< value_t, thread_safe >::size | ( | ) | const |
Returns the number of elements in the container
- Returns
- The number of elements in the container.
Definition at line 945 of file proxyVector.tpp.
◆ storedData() [1/2]
|
noexcept |
Returns a constant direct pointer to the memory of the internal storage.
If the container is not using the internal storage, a null pointer is returned.
- Returns
- A a direct pointer to the memory of the internal storage.
Definition at line 835 of file proxyVector.tpp.
◆ storedData() [2/2]
|
noexcept |
Returns a direct pointer to the memory of the internal storage.
If the container is not using the internal storage, a null pointer is returned.
- Returns
- A a direct pointer to the memory of the internal storage.
Definition at line 814 of file proxyVector.tpp.
◆ storedDataContainer() [1/2]
ProxyVector< value_t, thread_safe >::container_type * bitpit::ProxyVector< value_t, thread_safe >::storedDataContainer | ( | bool | forceCreation = false | ) |
Returns a direct reference to the container associated with the internal storage.
Interacting directly with the container associated with the internal storage may leave the proxy vector in an inconsistent state. It's up to the caller of this function to guarantee that this will not happen.
- Parameters
-
forceCreation if set to true and the storage is not associated with a container, an empty container will be created
- Returns
- A direct reference to the container associated with the internal storage.
Definition at line 862 of file proxyVector.tpp.
◆ storedDataContainer() [2/2]
const ProxyVector< value_t, thread_safe >::container_type * bitpit::ProxyVector< value_t, thread_safe >::storedDataContainer | ( | bool | forceCreation = false | ) | const |
Returns a constant direct reference to the container associated with the internal storage.
Interacting directly with the container associated with the internal storage may leave the proxy vector in an inconsistent state. It's up to the caller of this function to guarantee that this will not happen.
- Parameters
-
forceCreation if set to true and the storage is not associated with a container, an empty container will be created
- Returns
- A constant direct reference to the container associated with the internal storage.
Definition at line 882 of file proxyVector.tpp.
◆ swap()
void bitpit::ProxyVector< value_t, thread_safe >::swap | ( | ProxyVector< value_t, thread_safe > & | other | ) |
Swaps the content.
- Parameters
-
other is another container of the same type
Definition at line 893 of file proxyVector.tpp.
Member Data Documentation
◆ INTERNAL_STORAGE
|
staticconstexpr |
Flag to use the internal storage
Definition at line 359 of file proxyVector.hpp.
The documentation for this class was generated from the following files:
- src/containers/proxyVector.hpp
- src/containers/proxyVector.tpp
