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 |
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.
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 292 of file proxyVector.hpp.
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 317 of file proxyVector.hpp.
typedef container_type::const_pointer bitpit::ProxyVector< value_t, thread_safe >::const_pointer |
Constant pointer
Definition at line 331 of file proxyVector.hpp.
typedef container_type::const_reference bitpit::ProxyVector< value_t, thread_safe >::const_reference |
Constant reference
Definition at line 355 of file proxyVector.hpp.
typedef std::vector<value_no_cv_t> bitpit::ProxyVector< value_t, thread_safe >::container_type |
Container type
Definition at line 302 of file proxyVector.hpp.
typedef ProxyVectorIterator<value_t, container_type> bitpit::ProxyVector< value_t, thread_safe >::iterator |
Iterator for the container
Definition at line 312 of file proxyVector.hpp.
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 326 of file proxyVector.hpp.
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 350 of file proxyVector.hpp.
typedef container_type::const_pointer bitpit::ProxyVector< value_t, thread_safe >::storage_const_pointer |
Constant storage pointer
Definition at line 341 of file proxyVector.hpp.
typedef container_type::pointer bitpit::ProxyVector< value_t, thread_safe >::storage_pointer |
Storage pointer type
Definition at line 336 of file proxyVector.hpp.
typedef value_t bitpit::ProxyVector< value_t, thread_safe >::value_type |
Type of data stored in the container
Definition at line 307 of file proxyVector.hpp.
bitpit::ProxyVector< value_t, thread_safe >::ProxyVector | ( | ) |
Constructor
Definition at line 533 of file proxyVector.tpp.
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.
size | is the number elements contained in the data |
Definition at line 552 of file proxyVector.tpp.
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.
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).
data | a pointer to the data |
size | is the number elements contained in the data |
Definition at line 595 of file proxyVector.tpp.
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.
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.
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.
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.
bitpit::ProxyVector< value_t, thread_safe >::ProxyVector | ( | const ProxyVector< value_t, thread_safe > & | other | ) |
Copy constructor.
other | is another container whose content is copied in this container |
Definition at line 649 of file proxyVector.tpp.
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
other | is another container whose content is moved in this container |
Definition at line 666 of file proxyVector.tpp.
__PXV_REFERENCE__ bitpit::ProxyVector< value_t, thread_safe >::at | ( | std::size_t | n | ) |
Returns a reference to the specified element.
n | is the position of the requested element |
Definition at line 1008 of file proxyVector.tpp.
__PXV_CONST_REFERENCE__ bitpit::ProxyVector< value_t, thread_safe >::at | ( | std::size_t | n | ) | const |
Returns a constant reference to the specified element.
n | is the position of the requested element |
Definition at line 1020 of file proxyVector.tpp.
__PXV_REFERENCE__ bitpit::ProxyVector< value_t, thread_safe >::back | ( | ) |
Gets a reference to the last element in the container.
Definition at line 1055 of file proxyVector.tpp.
__PXV_CONST_REFERENCE__ bitpit::ProxyVector< value_t, thread_safe >::back | ( | ) | const |
Gets a constant reference to the last element in the container.
Definition at line 1066 of file proxyVector.tpp.
__PXV_ITERATOR__ bitpit::ProxyVector< value_t, thread_safe >::begin | ( | ) |
Returns an iterator pointing to the first element in the container.
Definition at line 1078 of file proxyVector.tpp.
__PXV_CONST_ITERATOR__ bitpit::ProxyVector< value_t, thread_safe >::begin | ( | ) | const |
Returns a constant iterator pointing to the first element in the container.
Definition at line 1089 of file proxyVector.tpp.
__PXV_CONST_ITERATOR__ bitpit::ProxyVector< value_t, thread_safe >::cbegin | ( | ) |
Returns a constant iterator pointing to the first element in the container.
Definition at line 1125 of file proxyVector.tpp.
__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.
|
noexcept |
Returns a direct constant pointer to the memory where the elments are stored.
Definition at line 970 of file proxyVector.tpp.
|
noexcept |
Returns a direct pointer to the memory where the elments are stored.
Definition at line 957 of file proxyVector.tpp.
bool bitpit::ProxyVector< value_t, thread_safe >::empty | ( | ) | const |
Tests whether the container is empty.
Definition at line 934 of file proxyVector.tpp.
__PXV_ITERATOR__ bitpit::ProxyVector< value_t, thread_safe >::end | ( | ) |
Returns an iterator referring to the past-the-end element in the container.
Definition at line 1101 of file proxyVector.tpp.
__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.
Definition at line 1114 of file proxyVector.tpp.
__PXV_REFERENCE__ bitpit::ProxyVector< value_t, thread_safe >::front | ( | ) |
Gets a reference to the first element in the container.
Definition at line 1032 of file proxyVector.tpp.
__PXV_CONST_REFERENCE__ bitpit::ProxyVector< value_t, thread_safe >::front | ( | ) | const |
Gets a constant reference to the first element in the container.
Definition at line 1043 of file proxyVector.tpp.
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.
other | is another container whose content is copied in this container |
Definition at line 680 of file proxyVector.tpp.
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
other | is another container whose content is moved in this container |
Definition at line 705 of file proxyVector.tpp.
bool bitpit::ProxyVector< value_t, thread_safe >::operator== | ( | const ProxyVector< value_t, thread_safe > & | other | ) | const |
Tests whether two containers are equal.
Definition at line 907 of file proxyVector.tpp.
__PXV_REFERENCE__ bitpit::ProxyVector< value_t, thread_safe >::operator[] | ( | std::size_t | n | ) |
Returns a reference to the specified element.
n | is the position of the requested element |
Definition at line 983 of file proxyVector.tpp.
__PXV_CONST_REFERENCE__ bitpit::ProxyVector< value_t, thread_safe >::operator[] | ( | std::size_t | n | ) | const |
Returns a constant reference to the specified element.
n | is the position of the requested element |
Definition at line 995 of file proxyVector.tpp.
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.
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).
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.
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.
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.
std::size_t bitpit::ProxyVector< value_t, thread_safe >::size | ( | ) | const |
Returns the number of elements in the container
Definition at line 945 of file proxyVector.tpp.
|
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.
Definition at line 835 of file proxyVector.tpp.
|
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.
Definition at line 814 of file proxyVector.tpp.
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.
forceCreation | if set to true and the storage is not associated with a container, an empty container will be created |
Definition at line 862 of file proxyVector.tpp.
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.
forceCreation | if set to true and the storage is not associated with a container, an empty container will be created |
Definition at line 882 of file proxyVector.tpp.
void bitpit::ProxyVector< value_t, thread_safe >::swap | ( | ProxyVector< value_t, thread_safe > & | other | ) |
Swaps the content.
other | is another container of the same type |
Definition at line 893 of file proxyVector.tpp.
|
staticconstexpr |
Flag to use the internal storage
Definition at line 360 of file proxyVector.hpp.