Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
Stroika::Foundation::Common::FunctionTraits< T > Struct Template Reference

Extract the number of arguments, return type, and each individual argument type from a lambda or simple function object. More...

#include <Concepts.h>

Detailed Description

template<typename T>
struct Stroika::Foundation::Common::FunctionTraits< T >

Extract the number of arguments, return type, and each individual argument type from a lambda or simple function object.

Example Usage
auto lambda = [](int i) { return long(i*10); };
using traits = FunctionTraits<decltype(lambda)>;
static_assert (traits::kArity == 1);
static_assert (same_as<long, traits::result_type>);
static_assert (same_as<int, traits::arg<0>::type>);
Extract the number of arguments, return type, and each individual argument type from a lambda or simp...
Definition Concepts.h:95

CREDITS: From https://stackoverflow.com/questions/7943525/is-it-possible-to-figure-out-the-parameter-type-and-return-type-of-a-lambda https://stackoverflow.com/users/224671/kennytm

For generic types, directly use the result of the signature of its 'operator()' Specialize for pointers to member function

Note
this doesn't work for function objects that have templated operator() - such as String::EqualsComparer, since there is no type to extract.

Definition at line 95 of file Concepts.h.


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