Loading...
Searching...
No Matches
seqan3::function_traits< std::function< return_t(args_t...)> > Struct Template Reference
Utility » Type Traits

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.
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_t | The return type of the function.
  args_t | A 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

// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
#include <cassert>
#include <string>
#include <seqan3/utility/type_traits/function_traits.hpp>
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 &>);
std::string
cassert
function_traits.hpp
Provides various type traits for use on functions.
std::function
sequence
The generic concept for a (biological) sequence.
string

## 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

  index | The 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:

- function_traits.hpp

Hide me