Generate an accompaniement for a given melody
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Traits.hpp File Reference

This file contains useful traits to check some properties of class (namely the implementation of static members and attributes). Some macro to help the user do that are defined here. More...

#include <type_traits>
#include <tuple>

Go to the source code of this file.

Classes

struct  function_traits::_implem::function_traits< F >
 
struct  function_traits::_implem::function_traits< R(*)(Args...)>
 
struct  function_traits::_implem::function_traits< R(T::*)(Args...) const >
 
struct  function_traits::_implem::function_traits< R(T::*)(Args...)>
 
struct  function_traits::_implem::function_traits< R(T::*)(Args...)>::get_arg< N >
 
struct  function_traits::_implem::check_signature< pos, T, Args >
 
struct  function_traits::_implem::check_signature< pos, T, Arg >
 
struct  function_traits::_implem::check_signature< pos, T, Head, Tail...>
 
struct  function_traits::_implem::static_and< b1, b2 >
 
struct  function_traits::_implem::static_and< true, true >
 

Macros

#define CREATE_MEMBER_DETECTOR(X)
 
#define CREATE_STATIC_MEMBER_DETECTOR(X)
 

Detailed Description

This file contains useful traits to check some properties of class (namely the implementation of static members and attributes). Some macro to help the user do that are defined here.

Date
Mon Oct 13 11:31:38 2014

Macro Definition Documentation

#define CREATE_MEMBER_DETECTOR (   X)
Value:
namespace function_traits{template<typename C,typename F> \
class has_##X; \
\
template<typename C, typename Ret, typename... Args> \
class has_##X<C,Ret(Args...)> { \
private: \
template<class U, class P = typename std::enable_if<function_traits::_implem::static_and< \
std::is_same< decltype( std::declval<U>().X( std::declval<Args>()... ) ), Ret >::value, \
function_traits::_implem::check_signature<0,decltype(&U::X),Args...>::value \
>::value>::type> \
static std::true_type check(int); \
template <class,class P = void> \
static std::false_type check(...); \
public: \
static constexpr bool value = decltype(check<C>(0))::value; \
};}
Definition: Traits.hpp:87

This macro creates a template that allows to check whether the public method X is implemented with a given signature.

For example, if we want to insure that a given class C has a public method foo with signature "bool foo(float,int)", we have to first call the macro "CREATE_MEMBER_DETECTOR(foo)" and then we can use the class in a static assert : "static_assert(has_foo<foo,bool(float,int)>::value,"error")

#define CREATE_STATIC_MEMBER_DETECTOR (   X)
Value:
namespace function_traits{template <class T> \
class has_##X \
{ \
template<class U, class = typename std::enable_if<!std::is_member_pointer<decltype(&U::X)>::value>::type> \
static std::true_type check(int); \
template <class> \
static std::false_type check(...); \
public: \
static constexpr bool value = decltype(check<T>(0))::value; \
};}

This macro creates a template that allows to check whether the class has a static member called X.