[mrpt-containers]

Container and STL-helper classes.

Library mrpt-containers

This C++ library is part of MRPT and can be installed in Debian-based systems with:

sudo apt install libmrpt-containers-dev

Read also how to import MRPT into your CMake scripts.

Find below some examples of use.

YAML-like parameter container

See mrpt::containers::yaml, and the examples therein.

// typedefs

typedef internal::generic_copier_ptr<T, internal::CopyCloner<T>> mrpt::containers::poly_ptr;
typedef internal::generic_copier_ptr<T, internal::CopyStatic<T>> mrpt::containers::copy_ptr;

// structs

struct mrpt::containers::ci_less;

// classes

template <class T>
class mrpt::containers::CDynamicGrid;

template <class T, class coord_t = double>
class mrpt::containers::CDynamicGrid3D;

template <class T>
class mrpt::containers::CThreadSafeQueue;

template <class T>
class mrpt::containers::NonCopiableData;

template <class T>
class mrpt::containers::PerThreadDataHolder;

template <typename KEY, typename VALUE>
class mrpt::containers::bimap;

template <typename T>
class mrpt::containers::circular_buffer;

template <typename T>
class mrpt::containers::deepcopy_poly_ptr;

template <class T>
class mrpt::containers::list_searchable;

template <
    typename KEY,
    typename VALUE,
    typename VECTOR_T = typename std::vector<std::pair<KEY, VALUE>>
    >
class mrpt::containers::map_as_vector;

template <typename VAL, size_t small_size, size_t alignment = 16>
class mrpt::containers::vector_with_small_size_optimization;

// global functions

template <class Visitor, class... T>
void mrpt::visit_each(
    const Visitor& vis,
    T&&... t
    );

template <typename src_container, typename dst_container>
void mrpt::containers::copy_container_typecasting(
    const src_container& src,
    dst_container& trg
    );

Typedefs

typedef internal::generic_copier_ptr<T, internal::CopyCloner<T>> mrpt::containers::poly_ptr

Smart pointer for polymorphic classes with a clone() method.

No shared copies, that is, each poly_ptr<T> owns a unique instance of T. Copying a poly_ptr<T> invokes the copy operator for T.

See also:

copy_ptr<T>

typedef internal::generic_copier_ptr<T, internal::CopyStatic<T>> mrpt::containers::copy_ptr

Smart pointer for non-polymorphic classes.

No shared copies, that is, each copy_ptr<T> owns a unique instance of T. Copying a copy_ptr<T> invokes the copy operator for T.

See also:

poly_ptr<T>

Global Functions

template <typename src_container, typename dst_container>
void mrpt::containers::copy_container_typecasting(
    const src_container& src,
    dst_container& trg
    )

Copy all the elements in a container (vector, deque, list) into a different one performing the appropriate typecasting.

The target container is automatically resized to the appropriate size, and previous contents are lost. This can be used to assign std::vector’s of different types:

std::vector<int>    vi(10);
std::vector<float>  vf;
vf = vi;   // Compiler error
mrpt::containers::copy_container_typecasting(v1,vf);  // Ok