SeqAn3 3.1.0
The Modern C++ library for sequence analysis.
seqan3::function_traits< std::function< return_t(args_t...)> > Struct Template Reference

A traits class to provide a uniform interface to the properties of a function type. More...

#include <seqan3/utility/type_traits/function_traits.hpp>

Public Types

template<size_t index>
using argument_type_at = pack_traits::at< index, args_t... >
 The argument type at the given index. More...
 
using result_type = return_t
 The return type of the function target.
 

Static Public Attributes

static constexpr size_t argument_count = sizeof...(args_t)
 The number of arguments passed to the std::function target.
 

Detailed Description

template<typename return_t, typename ... args_t>
struct seqan3::function_traits< std::function< return_t(args_t...)> >

A traits class to provide a uniform interface to the properties of a function type.

Template Parameters
return_tThe return type of the function.
args_tA template parameter pack over the argument types of the function.

seqan3::function_traits is the type trait class that provides a uniform interface to the properties of a std::function type, a lambda type, a function type or a function pointer type. This makes it possible to access the return type and the argument types of the stored target function. The function types must be complete, i.e. all argument types and the return type must be known, otherwise this traits class is incomplete.

Example

#include <cassert>
#include <string>
std::function my_caller = [] (size_t position, std::string & sequence)
{
assert(position < sequence.size());
return sequence[position];
};
using my_function_t = decltype(my_caller);
static_assert(std::same_as<seqan3::function_traits<my_function_t>::result_type, char>);
static_assert(seqan3::function_traits<my_function_t>::argument_count == 2);
static_assert(std::same_as<seqan3::function_traits<my_function_t>::argument_type_at<0>, size_t>);
static_assert(std::same_as<seqan3::function_traits<my_function_t>::argument_type_at<1>, std::string &>);
Provides various type traits for use on functions.
The generic concept for a (biological) sequence.

Member Typedef Documentation

◆ argument_type_at

template<typename return_t , typename ... args_t>
template<size_t index>
using seqan3::function_traits< std::function< return_t(args_t...)> >::argument_type_at = pack_traits::at<index, args_t...>

The argument type at the given index.

Template Parameters
indexThe position of the argument to get the type for; must be smaller than argument_count.

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