Files

51 lines
1.1 KiB
C++

/**
* @file include/ActivMiddleware/Misc/MetaFunctions.h
*
* @brief Header for miscellaneous meta functions.
*/
#if (!defined ACTIV_MISC_META_FUNCTIONS_H)
#define ACTIV_MISC_META_FUNCTIONS_H
#include "ActivMiddleware/ActivMiddleware.h"
//! Activ namespace.
namespace Activ
{
//! Simple wrapper for a type.
template<typename T>
class Identity
{
public:
typedef T type;
};
// ---------------------------------------------------------------------------------------------------------------------------------
/**
* @brief Make an Identity for a type.
*
* The intention for this is to prettify Boost::mpl::for_each usage:
*
* Boost::mpl::for_each<SomeTypeList, MakeIdentity<Boost::mpl::_1> >(someFunctor);
*
* someFunctor would have an operator() such as:
*
* template<typename T>
* void operator()(Identity<T>) { }
*
* This avoids any default construction cost of the types in SomeTypeList, or the use of Boost::add_pointer or similar
* (which can look confusing).
*/
template<typename T>
class MakeIdentity
{
public:
typedef Identity<T> type;
};
} // namespace Activ
#endif // (!defined ACTIV_MISC_META_FUNCTIONS_H)