MRPT  2.0.5
Classes | Namespaces | Typedefs | Functions

Detailed Description

Container and STL-helper classes.

Back to list of all libraries | See all modules

Library `mrpt-containers`

[New in MRPT 2.0.0]

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

    sudo apt install libmrpt-containers-dev

See: Using MRPT from your CMake project

Find below some examples of use.

YAML-like parameter container

See mrpt::containers::Parameters, and the examples below.

See: containers_parameters_example/test.cpp

#include <mrpt/core/demangle.h> // demangle() utility
#include <iostream>
p["K"] = 2.0;
p["N"].asRef<uint64_t>() = 10;
p["name"] = "Foo";
p["enabled"] = true;
p["books"].push_back("The Hobbit");
std::cout << "K=" << p["K"] << " N=" << p["N"] << "\n";
std::cout << "name=" << p["name"]
<< " bar=" << p.getOrDefault<std::string>("bar", "default")
<< "\n";
// Iterate a dictionary:
for (const auto& kv : p.asMap())
std::cout << "key: `" << kv.first
<< "` type: " << mrpt::demangle(kv.second.type().name())
<< "\n";
// Access value:<double>(), etc.
// Iterate sequence:
for (const auto& item : p["books"].asSequence())
std::cout << "sequence item type: "
<< mrpt::demangle(item.type().name()) << "\n";
// Access value:<std::string>(), etc.
// You can use {} to initialize mappings (dictionaries):
{{"K", 2.0}, {"book", std::string("silmarillion")}});
// or a sequence (each element may have a different type)
const auto p2 =
mrpt::containers::Parameters::Sequence({1.0, 2.0, "foo", true});


class  mrpt::containers::bimap< KEY, VALUE >
 A bidirectional version of std::map, declared as bimap<KEY,VALUE> and which actually contains two std::map's, one for keys and another for values. More...
class  mrpt::containers::CDynamicGrid< T >
 A 2D grid of dynamic size which stores any kind of data at each cell. More...
class  mrpt::containers::CDynamicGrid3D< T, coord_t >
 A 3D rectangular grid of dynamic size which stores any kind of data at each voxel. More...
struct  mrpt::containers::ci_less
 A case-insensitive comparator class for use within STL containers, etc. More...
class  mrpt::containers::circular_buffer< T >
 A circular buffer of fixed size (defined at construction-time), implemented with a std::vector as the underlying storage. More...
class  mrpt::containers::CThreadSafeQueue< T >
 A thread-safe template queue for object passing between threads; for a template argument of T, the objects being passed in the queue are "T*". More...
class  mrpt::containers::deepcopy_poly_ptr< T >
 Wrapper to a std::shared_ptr<>, adding deep-copy semantics to copy ctor and copy operator, suitable for polymorphic classes with a clone() method. More...
class  mrpt::containers::list_searchable< T >
 This class implements a STL container with features of both, a std::set and a std::list. More...
class  mrpt::containers::map_as_vector< KEY, VALUE, VECTOR_T >
 A STL-like container which looks and behaves (almost exactly) like a std::map<> but is implemented as a linear std::vector<> indexed by KEY. More...
class  mrpt::containers::Parameters
 Powerful YAML-like container for possibly-nested blocks of parameters. More...
class  mrpt::containers::vector_with_small_size_optimization< VAL, small_size, alignment >
 Container that transparently and dynamically switches between a std::array and std::vector. More...




template<typename T >
using mrpt::containers::poly_ptr = internal::generic_copier_ptr< T, internal::CopyCloner< T > >
 Smart pointer for polymorphic classes with a clone() method. More...
template<typename T >
using mrpt::containers::copy_ptr = internal::generic_copier_ptr< T, internal::CopyStatic< T > >
 Smart pointer for non-polymorphic classes. More...


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

Typedef Documentation

◆ copy_ptr

template<typename T >
using mrpt::containers::copy_ptr = typedef internal::generic_copier_ptr<T, internal::CopyStatic<T> >

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

Definition at line 161 of file deepcopy_ptr.h.

◆ poly_ptr

template<typename T >
using mrpt::containers::poly_ptr = typedef internal::generic_copier_ptr<T, internal::CopyCloner<T> >

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

Definition at line 153 of file deepcopy_ptr.h.

Function Documentation

◆ visit_each()

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

Definition at line 21 of file visit_each.h.

Referenced by TEST().

Here is the caller graph for this function:

Page generated by Doxygen 1.8.14 for MRPT 2.0.5 Git: ecc95703f Thu Jul 2 07:56:41 2020 +0200 at jue jul 2 08:00:14 CEST 2020