Main MRPT website > C++ reference
MRPT logo
Classes | Functions

mrpt::utils::metaprogramming Namespace Reference


Detailed Description

A set of utility objects for metaprogramming with STL algorithms.

Classes

struct  ObjectDelete
 An object for deleting pointers (intended for STL algorithms) More...
struct  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  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  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  ObjectConvert
 An object for transforming between types/classes, intended for being used in STL algorithms. More...
struct  ObjectMakeUnique
 An object for making smart pointers unique (ie, making copies if necessary), intended for being used in STL algorithms. More...
struct  ObjectPairMakeUnique
 An object for making smart pointers unique (ie, making copies if necessary), intended for being used in STL algorithms. More...
struct  ObjectClearUnique
 An object for making smart pointers unique (ie, making copies if necessary), intended for being used in STL algorithms. More...
struct  ObjectReadFromStream
 An object for reading objects from a stream, intended for being used in STL algorithms. More...
struct  ObjectWriteToStream
 An object for writing objects to a stream, intended for being used in STL algorithms. More...
class  MemoryBypasserIterator
 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  BinaryMemberFunctionWrapper
 This template encapsulates a binary member function and a single object into a function expecting the two parameters of the member function. More...
class  UnaryMemberFunctionWrapper
 This template encapsulates an unary member function and a single object into a function expecting the parameter of the member function. More...
class  MemberFunctionWrapper
 This template encapsulates a member function without arguments and a single object into a function. More...
class  NonConstBind1st
 Equivalent of std::bind1st for functions with non-const arguments. More...
class  NonConstBind2nd
 Equivalent of std::bind2nd for functions with non-const arguments. More...

Functions

template<typename T >
void DeleteContainer (T &container)
 A function which deletes a container of pointers.
template<typename it_src , typename it_dst >
void 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.
template<typename src_container , typename dst_container >
void 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.
template<typename U , typename T >
MemoryBypasserIterator< T, U > bypassPointer (const T &baseIterator)
 Sintactic sugar for MemoryBypasserIterator.
template<typename T , typename U1 , typename U2 , typename V >
BinaryMemberFunctionWrapper< T,
U1, U2, V > 
wrapMember (V &obj, T(V::*fun)(U1, U2))
 This function creates a function from an object and a member function.
template<typename T , typename U , typename V >
UnaryMemberFunctionWrapper< T,
U, V > 
wrapMember (V &obj, T(V::*fun)(U))
template<typename T , typename V >
MemberFunctionWrapper< T, V > wrapMember (V &obj, T(V::*fun)(void))
template<typename Op >
NonConstBind1st< Op > nonConstBind1st (Op &o, typename Op::first_argument_type &t)
 Use this function instead of directly calling NonConstBind1st.
template<typename Op >
NonConstBind2nd< Op > nonConstBind2nd (Op &o, typename Op::second_argument_type &t)
 Do not directly use the NonConstBind2nd class directly.

Function Documentation

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 268 of file metaprogramming.h.

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
   mrpt::utils::metaprogramming::copy_container_typecasting(v1,vf);  // Ok

Definition at line 181 of file metaprogramming.h.

Referenced by mrpt::opengl::CAngularObservationMesh::FTrace2D< T >::operator()().

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 164 of file metaprogramming.h.

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

A function which deletes a container of pointers.

Definition at line 50 of file metaprogramming.h.

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 352 of file metaprogramming.h.

References t().

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 371 of file metaprogramming.h.

References t().

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

Definition at line 332 of file metaprogramming.h.

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 326 of file metaprogramming.h.

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 329 of file metaprogramming.h.




Page generated by Doxygen 1.7.3 for MRPT 0.9.4 SVN: at Sat Mar 26 06:16:28 UTC 2011