Utopia  2
Framework for studying models of complex & adaptive systems.
Static Public Member Functions | Static Public Attributes | List of all members
Utopia::DataIO::is_callable< F, Args > Struct Template Reference

Test whether an object is callable. More...

#include <monitor.hh>

Static Public Member Functions

template<class U >
static auto test (U *p) -> decltype((*p)(std::declval< Args >()...), void(), std::true_type())
 
template<class U >
static auto test (...) -> decltype(std::false_type())
 

Static Public Attributes

static constexpr bool value = decltype(test< F >(0))::value
 

Detailed Description

template<class F, class... Args>
struct Utopia::DataIO::is_callable< F, Args >

Test whether an object is callable.

is_callable returns true for callable functions such as std::functions or lambdas. However, it returns false if an object only provides an operator(). This is necessary because otherwise types such as int or double would also return true (for this case use std::is_callable).

Template Parameters
FThe function
ArgsThe function arguments

Member Function Documentation

◆ test() [1/2]

template<class F , class... Args>
template<class U >
static auto Utopia::DataIO::is_callable< F, Args >::test (   ...) -> decltype(std::false_type())
static

◆ test() [2/2]

template<class F , class... Args>
template<class U >
static auto Utopia::DataIO::is_callable< F, Args >::test ( U *  p) -> decltype((*p)(std::declval< Args >()...), void(), std::true_type())
static

Member Data Documentation

◆ value

template<class F , class... Args>
constexpr bool Utopia::DataIO::is_callable< F, Args >::value = decltype(test< F >(0))::value
staticconstexpr

The documentation for this struct was generated from the following file: