Main MRPT website > C++ reference for MRPT 1.9.9
Classes | Namespaces | Macros | Typedefs | Functions
STL extensions and metaprogramming

Detailed Description

Collaboration diagram for STL extensions and metaprogramming:

Classes

class  mrpt::utils::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...
 
struct  mrpt::utils::ci_less
 A case-insensitive comparator struct for usage within STL containers, eg: map<string,string,ci_less> More...
 
class  mrpt::utils::circular_buffer< T >
 A circular buffer of fixed size (defined at construction-time), implemented with a std::vector as the underlying storage. More...
 
struct  mrpt::utils::ContainerReadOnlyProxyAccessor< STLCONTAINER >
 A generic proxy accessor template that only allows read-only access to the original binded STL container object. More...
 
class  mrpt::utils::list_searchable< T >
 This class implements a STL container with features of both, a std::set and a std::list. More...
 
class  mrpt::utils::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...
 
struct  mrpt::utils::metaprogramming::ObjectDelete
 An object for deleting pointers (intended for STL algorithms) More...
 
struct  mrpt::utils::metaprogramming::ObjectClear
 An object for clearing an object (invokes its method "->clear()") given a pointer or smart-pointer, intended for being used in STL algorithms. More...
 
struct  mrpt::utils::metaprogramming::ObjectClear2
 An object for clearing an object (invokes its method ".clear()") given a pointer or smart-pointer, intended for being used in STL algorithms. More...
 
struct  mrpt::utils::metaprogramming::ObjectClearSecond
 An object for clearing an object->second (invokes its method "clear()") given a pointer or smart-pointer, intended for being used in STL algorithms. More...
 
struct  mrpt::utils::metaprogramming::ObjectConvert< TARGET_TYPE >
 An object for transforming between types/classes, intended for being used in STL algorithms. More...
 
struct  mrpt::utils::metaprogramming::ObjectMakeUnique
 An object for making smart pointers unique (ie, making copies if necessary), intended for being used in STL algorithms. More...
 
struct  mrpt::utils::metaprogramming::ObjectPairMakeUnique
 An object for making smart pointers unique (ie, making copies if necessary), intended for being used in STL algorithms. More...
 
struct  mrpt::utils::metaprogramming::ObjectClearUnique< T >
 An object for making smart pointers unique (ie, making copies if necessary), intended for being used in STL algorithms. More...
 
class  mrpt::utils::metaprogramming::MemoryBypasserIterator< T, U >
 This class bypasses pointer access in iterators to pointers, thus allowing the use of algorithms that expect an object of class T with containers of T*. More...
 
class  mrpt::utils::metaprogramming::BinaryMemberFunctionWrapper< T, U1, U2, V >
 This template encapsulates a binary member function and a single object into a function expecting the two parameters of the member function. More...
 
class  mrpt::utils::metaprogramming::UnaryMemberFunctionWrapper< T, U, V >
 This template encapsulates an unary member function and a single object into a function expecting the parameter of the member function. More...
 
class  mrpt::utils::metaprogramming::MemberFunctionWrapper< T, V >
 This template encapsulates a member function without arguments and a single object into a function. More...
 
class  mrpt::utils::metaprogramming::NonConstBind1st< Op >
 Equivalent of std::bind1st for functions with non-const arguments. More...
 
class  mrpt::utils::metaprogramming::NonConstBind2nd< Op >
 Equivalent of std::bind2nd for functions with non-const arguments. More...
 
struct  mrpt::utils::metaprogramming::ObjectReadFromStream
 An object for reading objects from a stream, intended for being used in STL algorithms. More...
 
struct  mrpt::utils::metaprogramming::ObjectReadFromStreamToPtrs< ptr_t >
 
struct  mrpt::utils::metaprogramming::ObjectWriteToStream
 An object for writing objects to a stream, intended for being used in STL algorithms. More...
 
class  mrpt::utils::poly_ptr_ptr< T >
 Wrapper to a clone smart pointer to polymorphic classes, capable of handling copy operator, etc. More...
 
struct  mrpt::utils::map_traits_stdmap
 Traits for using a std::map<> (sparse representation) More...
 
struct  mrpt::utils::map_traits_map_as_vector
 Traits for using a mrpt::utils::map_as_vector<> (dense, fastest representation) More...
 

Namespaces

 mrpt::utils::internal
 
 mrpt::utils::metaprogramming
 A set of utility objects for metaprogramming with STL algorithms.
 

Macros

#define MRPTSTL_SERIALIZABLE_SEQ_CONTAINER(CONTAINER)
 
#define MRPTSTL_SERIALIZABLE_ASSOC_CONTAINER(CONTAINER)
 

Typedefs

template<typename T >
using mrpt::utils::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::utils::copy_ptr = internal::generic_copier_ptr< T, internal::CopyStatic< T > >
 Smart pointer for non-polymorphic classes. More...
 

Functions

template<typename T >
void mrpt::utils::metaprogramming::DeleteContainer (T &container)
 A function which deletes a container of pointers. More...
 
template<typename it_src , typename it_dst >
void mrpt::utils::metaprogramming::copy_typecasting (it_src first, it_src last, it_dst target)
 Behaves like std::copy but allows the source and target iterators to be of different types through static typecasting. More...
 
template<typename src_container , typename dst_container >
void mrpt::utils::metaprogramming::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. More...
 
template<typename U , typename T >
MemoryBypasserIterator< T, U > mrpt::utils::metaprogramming::bypassPointer (const T &baseIterator)
 Sintactic sugar for MemoryBypasserIterator. More...
 
template<typename T , typename U1 , typename U2 , typename V >
BinaryMemberFunctionWrapper< T, U1, U2, V > mrpt::utils::metaprogramming::wrapMember (V &obj, T(V::*fun)(U1, U2))
 This function creates a function from an object and a member function. More...
 
template<typename T , typename U , typename V >
UnaryMemberFunctionWrapper< T, U, V > mrpt::utils::metaprogramming::wrapMember (V &obj, T(V::*fun)(U))
 
template<typename T , typename V >
MemberFunctionWrapper< T, V > mrpt::utils::metaprogramming::wrapMember (V &obj, T(V::*fun)(void))
 
template<typename Op >
NonConstBind1st< Op > mrpt::utils::metaprogramming::nonConstBind1st (Op &o, typename Op::first_argument_type &t)
 Use this function instead of directly calling NonConstBind1st. More...
 
template<typename Op >
NonConstBind2nd< Op > mrpt::utils::metaprogramming::nonConstBind2nd (Op &o, typename Op::second_argument_type &t)
 Do not directly use the NonConstBind2nd class directly. More...
 
template<class T , class CONTAINER >
size_t mrpt::utils::find_in_vector (const T &value, const CONTAINER &vect)
 Returns the index of the value "T" in the container "vect" (std::vector,std::deque,etc), or string::npos if not found. More...
 
template<class T >
std::list< T >::iterator mrpt::utils::erase_return_next (std::list< T > &cont, typename std::list< T >::iterator &it)
 Calls the standard "erase" method of a STL container, but also returns an iterator to the next element in the container (or end if none) More...
 
template<class K , class V >
std::map< K, V >::iterator mrpt::utils::erase_return_next (std::map< K, V > &cont, typename std::map< K, V >::iterator &it)
 
template<class K , class V >
std::multimap< K, V >::iterator mrpt::utils::erase_return_next (std::multimap< K, V > &cont, typename std::multimap< K, V >::iterator &it)
 
template<class T >
std::set< T >::iterator mrpt::utils::erase_return_next (std::set< T > &cont, typename std::set< T >::iterator &it)
 
template<class T >
std::string mrpt::utils::getSTLContainerAsString (const T &t)
 Return a STL container in std::string form. More...
 
template<class T >
void mrpt::utils::printSTLContainer (const T &t)
 Print the given vector t. More...
 
template<class T >
void mrpt::utils::printSTLContainerOfContainers (const T &t)
 Print the given STL container of containers t. More...
 
template<class T1 , class T2 >
std::string mrpt::utils::getMapAsString (const std::map< T1, T2 > &m, const std::string &sep=" => ")
 Return contents of map in a string representation. More...
 
template<class T1 , class T2 >
void mrpt::utils::printMap (const std::map< T1, T2 > &m)
 Print the given map m. More...
 
 mrpt::utils::MRPTSTL_SERIALIZABLE_SEQ_CONTAINER (std::vector) MRPTSTL_SERIALIZABLE_SEQ_CONTAINER(std
 Template method to serialize a STL pair. More...
 
template<class T1 , class T2 >
CStreammrpt::utils::operator>> (mrpt::utils::CStream &in, std::pair< T1, T2 > &obj)
 Template method to deserialize a STL pair. More...
 

Macro Definition Documentation

◆ MRPTSTL_SERIALIZABLE_ASSOC_CONTAINER

#define MRPTSTL_SERIALIZABLE_ASSOC_CONTAINER (   CONTAINER)

Definition at line 67 of file stl_serialization.h.

◆ MRPTSTL_SERIALIZABLE_SEQ_CONTAINER

#define MRPTSTL_SERIALIZABLE_SEQ_CONTAINER (   CONTAINER)

Definition at line 28 of file stl_serialization.h.

Typedef Documentation

◆ copy_ptr

template<typename T >
using mrpt::utils::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
poly_ptr<T>

Definition at line 165 of file generic_copier_ptr.h.

◆ poly_ptr

template<typename T >
using mrpt::utils::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
copy_ptr<T>

Definition at line 157 of file generic_copier_ptr.h.

Function Documentation

◆ bypassPointer()

template<typename U , typename T >
MemoryBypasserIterator<T, U> mrpt::utils::metaprogramming::bypassPointer ( const T &  baseIterator)
inline

Sintactic sugar for MemoryBypasserIterator.

For example, having the following declarations: vector<double *> vec; void modifyVal(double &v); The following sentence is not legal: for_each(vec.begin(),vec.end(),&modifyVal) But this one is: for_each(bypassPointer(vec.begin()),bypassPointer(vec.end()),&modifyVal)

Definition at line 274 of file metaprogramming.h.

◆ copy_container_typecasting()

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

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

Definition at line 169 of file metaprogramming.h.

Referenced by mrpt::nav::CAbstractPTGBasedReactive::build_movement_candidate().

Here is the caller graph for this function:

◆ copy_typecasting()

template<typename it_src , typename it_dst >
void mrpt::utils::metaprogramming::copy_typecasting ( it_src  first,
it_src  last,
it_dst  target 
)
inline

Behaves like std::copy but allows the source and target iterators to be of different types through static typecasting.

Note
As in std::copy, the target iterator must point to the first "slot" where to put the first transformed element, and sufficient space must be allocated in advance.
See also
copy_container_typecasting

Definition at line 150 of file metaprogramming.h.

◆ DeleteContainer()

template<typename T >
void mrpt::utils::metaprogramming::DeleteContainer ( T &  container)
inline

A function which deletes a container of pointers.

Definition at line 41 of file metaprogramming.h.

◆ erase_return_next() [1/4]

template<class T >
std::list<T>::iterator mrpt::utils::erase_return_next ( std::list< T > &  cont,
typename std::list< T >::iterator it 
)
inline

Calls the standard "erase" method of a STL container, but also returns an iterator to the next element in the container (or end if none)

Definition at line 38 of file stl_containers_utils.h.

Referenced by mrpt::vision::TSequenceFeatureObservations::decimateCameraFrames(), and mrpt::hmtslam::CHMTSLAM::LSLAM_process_message_from_AA().

Here is the caller graph for this function:

◆ erase_return_next() [2/4]

template<class K , class V >
std::map<K, V>::iterator mrpt::utils::erase_return_next ( std::map< K, V > &  cont,
typename std::map< K, V >::iterator it 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 45 of file stl_containers_utils.h.

◆ erase_return_next() [3/4]

template<class K , class V >
std::multimap<K, V>::iterator mrpt::utils::erase_return_next ( std::multimap< K, V > &  cont,
typename std::multimap< K, V >::iterator it 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 55 of file stl_containers_utils.h.

◆ erase_return_next() [4/4]

template<class T >
std::set<T>::iterator mrpt::utils::erase_return_next ( std::set< T > &  cont,
typename std::set< T >::iterator it 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 65 of file stl_containers_utils.h.

◆ find_in_vector()

template<class T , class CONTAINER >
size_t mrpt::utils::find_in_vector ( const T &  value,
const CONTAINER &  vect 
)

Returns the index of the value "T" in the container "vect" (std::vector,std::deque,etc), or string::npos if not found.

Definition at line 27 of file stl_containers_utils.h.

References mrpt::math::distance().

Referenced by mrpt::slam::CRangeBearingKFSLAM2D::OnGetObservationsAndDataAssociation(), mrpt::graphslam::optimize_graph_spa_levmarq(), and mrpt::bayes::CKalmanFilterCapable< 7, 3, 3, 7 >::runOneKalmanIteration().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getMapAsString()

template<class T1 , class T2 >
std::string mrpt::utils::getMapAsString ( const std::map< T1, T2 > &  m,
const std::string sep = " => " 
)

Return contents of map in a string representation.

Parameters
[in]mTemplate map
[in]sepString that seperates visually each key and its value. Defaults to " => "
Returns
std::string representation of map

Definition at line 124 of file stl_containers_utils.h.

Referenced by mrpt::utils::printMap().

Here is the caller graph for this function:

◆ getSTLContainerAsString()

template<class T >
std::string mrpt::utils::getSTLContainerAsString ( const T &  t)

Return a STL container in std::string form.

Parameters
[in]tTemplate STL container (e.g. vector)
Returns
String form of given STL container

Definition at line 80 of file stl_containers_utils.h.

Referenced by mrpt::graphslam::deciders::CLoopCloserERD< GRAPH_T >::checkPartitionsForLC(), mrpt::graphslam::deciders::CLoopCloserERD< GRAPH_T >::generateHypotsPool(), mrpt::graphslam::deciders::CLoopCloserERD< GRAPH_T >::generatePWConsistenciesMatrix(), mrpt::graphslam::TUncertaintyPath< GRAPH_T >::getAsString(), and mrpt::utils::printSTLContainer().

Here is the caller graph for this function:

◆ MRPTSTL_SERIALIZABLE_SEQ_CONTAINER()

mrpt::utils::MRPTSTL_SERIALIZABLE_SEQ_CONTAINER ( std::vector  )

Template method to serialize a STL pair.

Definition at line 126 of file stl_serialization.h.

References mrpt::utils::TTypeName< T >::get().

Here is the call graph for this function:

◆ nonConstBind1st()

template<typename Op >
NonConstBind1st<Op> mrpt::utils::metaprogramming::nonConstBind1st ( Op &  o,
typename Op::first_argument_type &  t 
)
inline

Use this function instead of directly calling NonConstBind1st.

Definition at line 379 of file metaprogramming.h.

◆ nonConstBind2nd()

template<typename Op >
NonConstBind2nd<Op> mrpt::utils::metaprogramming::nonConstBind2nd ( Op &  o,
typename Op::second_argument_type &  t 
)
inline

Do not directly use the NonConstBind2nd class directly.

Use this function.

Definition at line 404 of file metaprogramming.h.

◆ operator>>()

template<class T1 , class T2 >
CStream& mrpt::utils::operator>> ( mrpt::utils::CStream in,
std::pair< T1, T2 > &  obj 
)

Template method to deserialize a STL pair.

Definition at line 197 of file stl_serialization.h.

References mrpt::format(), mrpt::utils::TTypeName< T >::get(), and THROW_EXCEPTION.

Here is the call graph for this function:

◆ printMap()

template<class T1 , class T2 >
void mrpt::utils::printMap ( const std::map< T1, T2 > &  m)

Print the given map m.

Parameters
[in]mTemplate map

Definition at line 143 of file stl_containers_utils.h.

References mrpt::utils::getMapAsString().

Here is the call graph for this function:

◆ printSTLContainer()

template<class T >
void mrpt::utils::printSTLContainer ( const T &  t)

Print the given vector t.

Parameters
[in]tTemplate vector

Definition at line 95 of file stl_containers_utils.h.

References mrpt::utils::getSTLContainerAsString().

Referenced by mrpt::utils::printSTLContainerOfContainers().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ printSTLContainerOfContainers()

template<class T >
void mrpt::utils::printSTLContainerOfContainers ( const T &  t)

Print the given STL container of containers t.

Parameters
[in]tTemplate STL container (containing other containers)

Definition at line 105 of file stl_containers_utils.h.

References mrpt::utils::printSTLContainer().

Here is the call graph for this function:

◆ wrapMember() [1/3]

template<typename T , typename U1 , typename U2 , typename V >
BinaryMemberFunctionWrapper<T, U1, U2, V> mrpt::utils::metaprogramming::wrapMember ( V &  obj,
T(V::*)(U1, U2)  fun 
)
inline

This function creates a function from an object and a member function.

It has three overloads, for zero, one and two parameters in the function.

Definition at line 343 of file metaprogramming.h.

◆ wrapMember() [2/3]

template<typename T , typename U , typename V >
UnaryMemberFunctionWrapper<T, U, V> mrpt::utils::metaprogramming::wrapMember ( V &  obj,
T(V::*)(U)  fun 
)
inline

Definition at line 349 of file metaprogramming.h.

◆ wrapMember() [3/3]

template<typename T , typename V >
MemberFunctionWrapper<T, V> mrpt::utils::metaprogramming::wrapMember ( V &  obj,
T(V::*)(void fun 
)
inline

Definition at line 354 of file metaprogramming.h.




Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019