Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
is_supported< T, C > Struct Template Reference

#include <elm/meta.h>

Public Types

enum  { _ = decltype(c<T>(0))::_ }
 

Static Public Member Functions

template<class U >
static _true c (C< U > *)
 
template<class U >
static _false c (...)
 

Detailed Description

template<typename T, template< typename X > class C>
struct elm::meta::is_supported< T, C >

Type containing a value "_" which value is 1 if the template C can be applied to T, 0 else.

This type is useful to test if some property is available on a type T. It is commonly used, but not limited to, to test if a function is member of a type T

In the example below, the condition has_f tests if T contains a function named f taking an integer as first parameter:

template <class T>
using has_f = decltype(declval<T>().f(int(0)));
int main() {
MyClass o;
if(meta::is_supported<MyClass, has_f>())
o.f(666);
}
Parameters
TType to test.
CCondition to test (template supporting one parameter).

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator

Member Function Documentation

◆ c() [1/2]

static _false c (   ...)
static

◆ c() [2/2]

static _true c ( C< U > *  )
static

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