BipedalLocomotion::GenericContainer::Vector::Ref class

The class ref is used a substitution to a classical reference to a Vector.

The advantage of using this, is that custom vectors (all those supported by GenericContainer::Vector) can be implicitly casted to Ref. Ref does not allocate any memory in construction, hence can be used as a parameter to be passed by copy. The = operator clones the content. Ref inherits Vector<T>, hence it can be used as it was a Vector<T>.

Base classes

template<typename T>
class BipedalLocomotion::GenericContainer::Vector<T>
Forward declaration of Vector class.

Constructors, destructors, conversion operators

Ref() deleted
A reference cannot exist on its own.
Ref(BipedalLocomotion::GenericContainer::Vector<T>::Ref& other)
Copy constructor.
Ref(BipedalLocomotion::GenericContainer::Vector<T>::Ref&& other)
Move constructor.
Ref(BipedalLocomotion::GenericContainer::Vector<T>& other)
Constructor from a GenericContainer::Vector<T>&.
Ref(BipedalLocomotion::GenericContainer::Vector<T>&& other)
Constructor from a GenericContainer::Vector<T>&.
template<class Vector, typename = typename std::enable_if<!GenericContainer::is_vector<Vector>::value&& !std::is_same<Vector, std::string>::value&& GenericContainer::is_vector_ref_constructible<T,Vector>::value&& !std::is_const_v<T>&& !is_container_const<Vector>::value>::type>
Ref(Vector& input)
Constructor from another container.
template<class Vector, typename = typename std::enable_if<!GenericContainer::is_vector<Vector>::value&& !std::is_same<Vector, std::string>::value&& GenericContainer::is_vector_ref_constructible<T,Vector>::value&& std::is_const_v<T>>::type>
Ref(const Vector& input)
Constructor from another container.
~Ref() defaulted
Default constructor.

Public functions

auto operator=(const Ref& other) -> Ref
Copy operator.
auto operator=(Ref&& other) -> Ref
Copy operator.

Function documentation

BipedalLocomotion::GenericContainer::Vector::Ref::Ref(BipedalLocomotion::GenericContainer::Vector<T>::Ref& other)

Copy constructor.

Parameters
other The ref from which to copy the context.

BipedalLocomotion::GenericContainer::Vector::Ref::Ref(BipedalLocomotion::GenericContainer::Vector<T>::Ref&& other)

Move constructor.

Parameters
other The ref from which to get the context.

BipedalLocomotion::GenericContainer::Vector::Ref::Ref(BipedalLocomotion::GenericContainer::Vector<T>& other)

Constructor from a GenericContainer::Vector<T>&.

Parameters
other The input vector from which the context is copied

BipedalLocomotion::GenericContainer::Vector::Ref::Ref(BipedalLocomotion::GenericContainer::Vector<T>&& other)

Constructor from a GenericContainer::Vector<T>&.

Parameters
other The input vector from which the context is taken In principle, Ref should be the reference of a Vector<T> which should remain alive while Ref is alive. On the other hand, Vector<T> is only a pointer to some data which does not own. Hence, Ref can remain alive even if the Vector<T> is deleted, provided that the original container stays alive.

template<class Vector, typename = typename std::enable_if<!GenericContainer::is_vector<Vector>::value&& !std::is_same<Vector, std::string>::value&& GenericContainer::is_vector_ref_constructible<T,Vector>::value&& !std::is_const_v<T>&& !is_container_const<Vector>::value>::type>
BipedalLocomotion::GenericContainer::Vector::Ref::Ref(Vector& input)

Constructor from another container.

This is used if:

  • the input container is not a GenericContainer::Vector, to avoid ambiguities with other constructors
  • the input container is not a string. This allows using Ref and string with overloaded methods.
  • a GenericContainer::Vector<T>::Ref can be constructed from the Container
  • T is not const
  • the input container is not const.

template<class Vector, typename = typename std::enable_if<!GenericContainer::is_vector<Vector>::value&& !std::is_same<Vector, std::string>::value&& GenericContainer::is_vector_ref_constructible<T,Vector>::value&& std::is_const_v<T>>::type>
BipedalLocomotion::GenericContainer::Vector::Ref::Ref(const Vector& input)

Constructor from another container.

This is used if:

  • the input container is not a GenericContainer::Vector, to avoid ambiguities with other constructors
  • the input container is not a string. This allows using Ref and string with overloaded methods.
  • a GenericContainer::Vector<T>::Ref can be constructed from the Container
  • T is const.

Ref BipedalLocomotion::GenericContainer::Vector::Ref::operator=(const Ref& other)

Copy operator.

Parameters
other The other Ref, from which the data is copied
Returns A reference to the vector resulting from the copy.

Ref BipedalLocomotion::GenericContainer::Vector::Ref::operator=(Ref&& other)

Copy operator.

Parameters
other The other Ref, from which the data is copied
Returns A reference to the vector resulting from the copy.