SeqAn3  3.0.3
The Modern C++ library for sequence analysis.
Core

Provides core functionality used by multiple modules. More...

+ Collaboration diagram for Core:

Modules

 Algorithm
 Provides core functionality used to configure algorithms.
 
 Configuration
 Provides core functionality used to configure configurations.
 

Classes

interface  cereal_archive
 All archives of the Cereal library satisfy this. More...
 
interface  cereal_input_archive
 All input archives of the Cereal library satisfy this. More...
 
interface  cereal_output_archive
 All output archives of the Cereal library satisfy this. More...
 
interface  cereal_text_archive
 All text archives of the Cereal library satisfy this. More...
 
interface  cerealisable
 Specifies the requirements for types that are serialisable via Cereal. More...
 
class  seqan3::debug_stream_type< char_t >
 A "pretty printer" for most SeqAn data structures and related types. More...
 
interface  debug_streamable_tuple
 A helper concept to avoid ambiguous overloads with the debug stream operator for alignments. More...
 
struct  seqan3::detail::deferred_crtp_base< crtp_base, args_t >
 An invocable wrapper that defers the instantiation of a crtp_base class. More...
 
struct  seqan3::detail::deferred_crtp_base_vargs< crtp_base, args >
 An invocable wrapper that defers the instantiation of a crtp_base class. More...
 
interface  derived_from_strong_type
 Defines the requirements of a seqan::detail::strong_type specialisation. More...
 
struct  seqan3::detail::empty_type
 An empty class type used in meta programming. More...
 
struct  seqan3::detail::is_class_template_declarable_with< query_t, args_t >
 An unary type trait that tests whether a template class can be declared with the given template type parameters. More...
 
struct  seqan3::detail::is_type_specialisation_of< source_t, target_template >
 Determines whether a source_type is a specialisation of another template. More...
 
struct  seqan3::detail::is_value_specialisation_of< source_t, target_template >
 Determines whether a source_type is a specialisation of another template. More...
 
struct  seqan3::pod_tuple< type0 >
 Recursion anchor for pod_tuple. More...
 
interface  range_compatible
 Two types are "compatible" if their seqan3::range_dimension_v and their seqan3::range_innermost_value_t are the same. More...
 
struct  seqan3::range_innermost_value< t >
 Recursively determines the value_type on containers and/or iterators. More...
 
class  seqan3::detail::strong_type< value_t, derived_t, skills_ >
 CRTP base class to declare a strong typedef for a regular type to avoid ambiguous parameter settings in function calls. More...
 
struct  seqan3::detail::transfer_template_args_onto< source_template< source_arg_types... >, target_template >
 Extracts a type template's type arguments and specialises another template with them. More...
 
struct  seqan3::detail::transfer_template_vargs_onto< source_template< source_varg_types... >, target_template >
 Extracts a type template's non-type arguments and specialises another template with them. More...
 
struct  seqan3::detail::transfer_type_modifier_onto< source_t, target_t >
 Transfers the type modifier &, && and const (and any combination) to the target type. More...
 
struct  seqan3::detail::valid_template_spec_or< fallback_t, templ_t, spec_t >
 Exposes templ_t<spec_t...> if that is valid, otherwise fallback_t. More...
 

Macros

#define SEQAN3_WITH_CEREAL   0
 Whether CEREAL support is available or not.
 
#define SEQAN3_WITH_LEMON   0
 Whether Lemon support is available or not.
 

Typedefs

template<typename deferred_crtp_base_t , typename derived_t >
using seqan3::detail::invoke_deferred_crtp_base = typename deferred_crtp_base_t::template invoke< derived_t >
 Template alias to instantiate the deferred crtp base with the derived class. More...
 
template<bool const_range, typename range_t >
using seqan3::detail::maybe_const_iterator_t = std::ranges::iterator_t< maybe_const_range_t< const_range, range_t > >
 Returns the const iterator of range_t if const_range is true; otherwise the non-const iterator.
 
template<bool const_range, typename range_t >
using seqan3::detail::maybe_const_range_t = std::conditional_t< const_range, range_t const, range_t >
 Makes range_t const if const_range is true; otherwise keeps range_t as is.
 
template<bool const_v, typename range_t >
using seqan3::detail::maybe_const_sentinel_t = std::ranges::sentinel_t< maybe_const_range_t< const_v, range_t > >
 Returns the const sentinel of range_t if const_range is true; otherwise the non-const sentinel.
 
template<typename t >
using seqan3::range_innermost_value_t = typename range_innermost_value< t >::type
 Shortcut for seqan3::range_innermost_value (transformation_trait shortcut). More...
 
using seqan3::semiregular_box = ::ranges::semiregular_box
 Utility wrapper that behaves like std::optional but makes the type conform with the std::semiregular concept. Imported from ranges::semiregular_box. More...
 
using seqan3::semiregular_box_t = ::ranges::semiregular_box_t
 Utility transformation trait to get a wrapper type that models std::semiregular. Imported from ranges::semiregular_box_t. More...
 
template<typename type >
using seqan3::detail::strip_cereal_wrapper_t = type
 Removes type-mangling that Cereal does with certain types on loading. More...
 
template<typename source_type , template< typename ... > typename target_template>
using seqan3::detail::transfer_template_args_onto_t = typename transfer_template_args_onto< source_type, target_template >::type
 Shortcut for seqan3::detail::transfer_template_args_onto (transformation_trait shortcut). More...
 
template<typename source_type , template< auto ... > typename target_template>
using seqan3::detail::transfer_template_vargs_onto_t = typename transfer_template_vargs_onto< source_type, target_template >::type
 Shortcut for seqan3::detail::transfer_template_vargs_onto (transformation_trait shortcut). More...
 
template<typename fallback_t , template< typename ... > typename templ_t, typename ... spec_t>
using seqan3::detail::valid_template_spec_or_t = typename valid_template_spec_or< fallback_t, templ_t, spec_t... >::type
 Helper for seqan3::detail::valid_template_spec_or (transformation_trait shortcut). More...
 

Enumerations

enum class  seqan3::detail::strong_type_skill {
  none = 0 , add = 1 << 0 , subtract = 1 << 1 , multiply = 1 << 2 ,
  divide = 1 << 3 , modulo = 1 << 4 , bitwise_and = 1 << 5 , bitwise_or = 1 << 6 ,
  bitwise_xor = 1 << 7 , bitwise_not = 1 << 8 , bitwise_lshift = 1 << 9 , bitwise_rshift = 1 << 10 ,
  logical_and = 1 << 11 , logical_or = 1 << 12 , logical_not = 1 << 13 , increment = 1 << 14 ,
  decrement = 1 << 15 , convert = 1 << 16 , comparable = 1 << 17 , additive = add | subtract ,
  multiplicative = multiply | divide | modulo , bitwise_logic = bitwise_and | bitwise_or | bitwise_xor | bitwise_not , bitwise_shift = bitwise_lshift | bitwise_rshift , logic = logical_and | logical_or | logical_not
}
 Enum class for all supported operations that can be added to a seqan3::detail::strong_type. More...
 

Functions

template<typename type_list_t , typename unary_predicate_t >
constexpr bool seqan3::detail::all_of (unary_predicate_t &&fn)
 Tests whether a given predicate evaluates to true for each type in a seqan3::type_list. More...
 
template<typename unary_predicate_t , typename ... pack_t>
constexpr bool seqan3::detail::all_of (unary_predicate_t &&fn, pack_t &&...args)
 Tests whether a given predicate evaluates to true for each element in the function parameter pack. More...
 
template<std::unsigned_integral unsigned_t>
constexpr unsigned_t seqan3::detail::ceil_log2 (unsigned_t const n) noexcept
 Computes the ceil of the logarithm to the base of two for unsigned integers. More...
 
template<std::unsigned_integral unsigned_t>
constexpr unsigned_t seqan3::detail::floor_log2 (unsigned_t const n) noexcept
 Computes the floor of the logarithm to the base of two for unsigned integers. More...
 
template<typename type_list_t , typename unary_function_t >
constexpr void seqan3::detail::for_each (unary_function_t &&fn)
 Applies a function element wise to all types of a type list. More...
 
template<typename unary_function_t , typename ... pack_t>
constexpr void seqan3::detail::for_each (unary_function_t &&fn, pack_t &&...args)
 Applies a function to each element of the given function parameter pack. More...
 
template<typename base_t , std::unsigned_integral exp_t>
base_t seqan3::pow (base_t base, exp_t exp)
 Computes the value of base raised to the power exp. More...
 

Variables

template<typename t >
constexpr bool seqan3::add_enum_bitwise_operators = false
 Set to true for a scoped enum to have binary operators overloaded. More...
 
template<typename rng_t >
SEQAN3_CONCEPT seqan3::detail::debug_stream_range_guard
 A helper concept definition for ranges that can be streamed to the seqan3::debug_stream. More...
 
template<template< typename ... > typename query_t, typename ... args_t>
constexpr bool is_class_template_declarable_with_v
 Helper variable template for seqan3::detail::is_class_template_declarable_with. More...
 
template<typename t >
constexpr bool seqan3::detail::is_type_list_of_alignment_file_input_formats_v = false
 Auxiliary value metafuncton that checks whether a type is a seqan3::type_list and all types meet seqan3::alignment_file_input_format [default is false]. More...
 
template<typename ... ts>
constexpr bool seqan3::detail::is_type_list_of_alignment_file_input_formats_v< type_list< ts... > >
 Auxiliary value metafuncton that checks whether a type is a seqan3::type_list and all types meet seqan3::alignment_file_input_format [overload]. More...
 
template<typename t >
constexpr bool seqan3::detail::is_type_list_of_alignment_file_output_formats_v = false
 Auxiliary value metafuncton that checks whether a type is a seqan3::type_list and all types meet seqan3::alignment_file_output_format [default is false]. More...
 
template<typename ... ts>
constexpr bool seqan3::detail::is_type_list_of_alignment_file_output_formats_v< type_list< ts... > > = (alignment_file_output_format<ts> && ...)
 Auxiliary value metafuncton that checks whether a type is a seqan3::type_list and all types meet seqan3::alignment_file_output_format [overload]. More...
 
template<typename t >
constexpr bool seqan3::detail::is_type_list_of_sequence_file_input_formats_v = false
 Auxiliary value metafuncton that checks whether a type is a seqan3::type_list and all types meet seqan3::sequence_file_input_format [default is false]. More...
 
template<typename ... ts>
constexpr bool seqan3::detail::is_type_list_of_sequence_file_input_formats_v< type_list< ts... > >
 Auxiliary value metafuncton that checks whether a type is a seqan3::type_list and all types meet seqan3::sequence_file_input_format [overload]. More...
 
template<typename t >
constexpr bool seqan3::detail::is_type_list_of_sequence_file_output_formats_v = false
 Auxiliary value metafuncton that checks whether a type is a seqan3::type_list and all types meet seqan3::sequence_file_output_format [default is false]. More...
 
template<typename ... ts>
constexpr bool seqan3::detail::is_type_list_of_sequence_file_output_formats_v< type_list< ts... > >
 Auxiliary value metafuncton that checks whether a type is a seqan3::type_list and all types meet seqan3::sequence_file_output_format [overload]. More...
 
template<typename t >
constexpr bool seqan3::detail::is_type_list_of_structure_file_input_formats_v = false
 Auxiliary value metafuncton that checks whether a type is a seqan3::type_list and all types meet seqan3::structure_file_input_format [default is false]. More...
 
template<typename ... ts>
constexpr bool seqan3::detail::is_type_list_of_structure_file_input_formats_v< type_list< ts... > > = (structure_file_input_format<ts> && ...)
 Auxiliary value metafuncton that checks whether a type is a seqan3::type_list and all types meet seqan3::structure_file_input_format [overload]. More...
 
template<typename t >
constexpr bool seqan3::detail::is_type_list_of_structure_file_output_formats_v = false
 Auxiliary value metafuncton that checks whether a type is a seqan3::type_list and all types meet seqan3::structure_file_output_format [default is false]. More...
 
template<typename ... ts>
constexpr bool seqan3::detail::is_type_list_of_structure_file_output_formats_v< type_list< ts... > > = (structure_file_output_format<ts> && ...)
 Auxiliary value metafuncton that checks whether a type is a seqan3::type_list and all types meet seqan3::structure_file_output_format [overload]. More...
 
template<typename t >
constexpr size_t seqan3::range_dimension_v = 1
 Returns the number of times you can call seqan3::value_type_t recursively on t (type trait). More...
 
template<std::ranges::range rng_t, typename char_t >
constexpr bool seqan3::detail::reference_type_is_streamable_v = false
 Helper template variable that checks if the reference type of a range can be streamed into an instance of seqan3::debug_stream_type . More...
 
template<typename t >
SEQAN3_CONCEPT seqan3::detail::type_list_of_alignment_file_input_formats = is_type_list_of_alignment_file_input_formats_v<t>
 Auxiliary concept that checks whether a type is a seqan3::type_list and all types meet seqan3::alignment_file_input_format. More...
 
template<typename t >
SEQAN3_CONCEPT seqan3::detail::type_list_of_alignment_file_output_formats = is_type_list_of_alignment_file_output_formats_v<t>
 Auxiliary concept that checks whether a type is a seqan3::type_list and all types meet seqan3::alignment_file_output_format. More...
 
template<typename t >
SEQAN3_CONCEPT seqan3::detail::type_list_of_sequence_file_input_formats = is_type_list_of_sequence_file_input_formats_v<t>
 Auxiliary concept that checks whether a type is a seqan3::type_list and all types meet seqan3::sequence_file_input_format. More...
 
template<typename t >
SEQAN3_CONCEPT seqan3::detail::type_list_of_sequence_file_output_formats = is_type_list_of_sequence_file_output_formats_v<t>
 Auxiliary concept that checks whether a type is a seqan3::type_list and all types meet seqan3::sequence_file_output_format. More...
 
template<typename t >
SEQAN3_CONCEPT seqan3::detail::type_list_of_structure_file_input_formats = is_type_list_of_structure_file_input_formats_v<t>
 Auxiliary concept that checks whether a type is a seqan3::type_list and all types meet seqan3::structure_file_input_format. More...
 
template<typename t >
SEQAN3_CONCEPT seqan3::detail::type_list_of_structure_file_output_formats = is_type_list_of_structure_file_output_formats_v<t>
 Auxiliary concept that checks whether a type is a seqan3::type_list and all types meet seqan3::structure_file_output_format. More...
 
template<typename type >
std::string const seqan3::detail::type_name_as_string
 Defines the human-readable name of the given type using the typeid operator. More...
 

Detailed Description

Provides core functionality used by multiple modules.

The core module contains concepts, functions and some classes that are used by multiple other modules, but that usually are not relevant to most users of the library.

Typedef Documentation

◆ invoke_deferred_crtp_base

template<typename deferred_crtp_base_t , typename derived_t >
using seqan3::detail::invoke_deferred_crtp_base = typedef typename deferred_crtp_base_t::template invoke<derived_t>

Template alias to instantiate the deferred crtp base with the derived class.

Template Parameters
deferred_crtp_base_tThe deferred crtp base class.
derived_tThe derived type to instantiate the crtp base class with.

Effectively declares the type resulting from deferred_crtp_base_t::template invoke<derived_t>.

See also
seqan3::detail::deferred_crtp_base

◆ range_innermost_value_t

template<typename t >
using seqan3::range_innermost_value_t = typedef typename range_innermost_value<t>::type

◆ semiregular_box

using seqan3::semiregular_box = typedef ::ranges::semiregular_box

Utility wrapper that behaves like std::optional but makes the type conform with the std::semiregular concept. Imported from ranges::semiregular_box.

See also
https://en.cppreference.com/w/cpp/ranges/semiregular_wrapper

◆ semiregular_box_t

using seqan3::semiregular_box_t = typedef ::ranges::semiregular_box_t

Utility transformation trait to get a wrapper type that models std::semiregular. Imported from ranges::semiregular_box_t.

See also
https://en.cppreference.com/w/cpp/ranges/semiregular_wrapper

◆ strip_cereal_wrapper_t

template<typename type >
using seqan3::detail::strip_cereal_wrapper_t = typedef type

Removes type-mangling that Cereal does with certain types on loading.

Helpful when defining templatised save/load/serialize functions.

◆ transfer_template_args_onto_t

template<typename source_type , template< typename ... > typename target_template>
using seqan3::detail::transfer_template_args_onto_t = typedef typename transfer_template_args_onto<source_type, target_template>::type

Shortcut for seqan3::detail::transfer_template_args_onto (transformation_trait shortcut).

See also
seqan3::detail::transfer_template_args_onto

◆ transfer_template_vargs_onto_t

template<typename source_type , template< auto ... > typename target_template>
using seqan3::detail::transfer_template_vargs_onto_t = typedef typename transfer_template_vargs_onto<source_type, target_template>::type

Shortcut for seqan3::detail::transfer_template_vargs_onto (transformation_trait shortcut).

See also
seqan3::detail::transfer_template_vargs_onto

◆ valid_template_spec_or_t

template<typename fallback_t , template< typename ... > typename templ_t, typename ... spec_t>
using seqan3::detail::valid_template_spec_or_t = typedef typename valid_template_spec_or<fallback_t, templ_t, spec_t...>::type

Helper for seqan3::detail::valid_template_spec_or (transformation_trait shortcut).

See also
seqan3::detail::valid_template_spec_or
Template Parameters
fallback_tThe fallback type.
templ_tThe type template that should be specialised.
spec_tThe specialisation for the type template.

Enumeration Type Documentation

◆ strong_type_skill

Enum class for all supported operations that can be added to a seqan3::detail::strong_type.

See also
seqan3::enum_bitwise_operators enables combining enum values.

Function Documentation

◆ all_of() [1/2]

template<typename type_list_t , typename unary_predicate_t >
constexpr bool seqan3::detail::all_of ( unary_predicate_t &&  fn)
constexpr

Tests whether a given predicate evaluates to true for each type in a seqan3::type_list.

Template Parameters
list_tA type list; must model seqan3::detail::template_specialisation_of a seqan3::type_list
unary_predicate_tThe function type, like function pointers, functors and lambdas; must model std::predicate expanded on each argument type wrapped in std::type_identity.
Parameters
[in]fnThe predicate called for every type in the seqan3::type_list.
Returns
true if the predicate returns true for each type in the type list, false otherwise.

This function operates on types instead of values. The following steps are performed to call the passed predicate on the types contained in the type list:

Note that wrapping the types in std::type_identity is a technical trick to make a type representable as a value. Instantiating a type might not work because they might not be std::default_initializable. In addition it is possible, to invoke the predicate on incomplete types.

Example

#include <type_traits>
namespace incomplete
{
struct type;
} // namespace incomplete
// With c++20 you could also write it like this
// auto fn = []<typename type>(std::type_identity<type>)
// {
// ...
// };
auto fn = [](auto id)
{
// id is of type std::type_identity<type>
using id_t = decltype(id);
using type = typename id_t::type;
static_assert(std::is_same_v<id_t, std::type_identity<type>>, "id is of type std::type_identity<type>");
if constexpr(std::is_same_v<type, bool>)
return true;
else if constexpr(std::is_same_v<type, int>)
return true;
else if constexpr(std::is_same_v<type, float>)
return true;
else if constexpr(std::is_same_v<type, incomplete::type>)
return false;
};
static_assert(seqan3::detail::all_of<seqan3::type_list<int, float, bool>>(fn)); // evalates to true
Provides seqan3::debug_stream and related types.
constexpr bool all_of(unary_predicate_t &&fn, pack_t &&...args)
Tests whether a given predicate evaluates to true for each element in the function parameter pack.
Definition: pack_algorithm.hpp:109
@ id
The identifier, usually a string.
meta::list< types... > type_list
Type that contains multiple types, an alias for meta::list.
Definition: type_list.hpp:31
T is_same_v
Provides algorithms for meta programming, parameter packs and seqan3::type_list.
Provides seqan3::type_list.

Complexity

Linear in the number of types in the seqan3::type_list.

[Compile-time complexity: Linear number of template instantiations.]

◆ all_of() [2/2]

template<typename unary_predicate_t , typename ... pack_t>
constexpr bool seqan3::detail::all_of ( unary_predicate_t &&  fn,
pack_t &&...  args 
)
constexpr

Tests whether a given predicate evaluates to true for each element in the function parameter pack.

Template Parameters
unary_predicate_tThe function type, like function pointers, functors and lambdas; must model std::predicate expanded on each argument type.
pack_tThe parameter pack of the arguments (each argument type can be different).
Parameters
[in]fnThe predicate to evaluate for every argument.
[in]argsThe parameter pack.
Returns
true if the predicate returns true for each type in the type list, false otherwise.

This function behaves like std::all_of but on parameter packs. The invocation(s) will be done without any loop.

Example

#include <type_traits>
// With c++20 you could also write it like this
// auto fn = []<typename value_t>(value_t && value)
// {
// ...
// };
auto fn = [](auto value)
{
// id is the original type not wrapped in std::type_identity.
using value_t = decltype(value);
if constexpr(std::is_same_v<value_t, bool>)
return value == false;
else if constexpr(std::is_same_v<value_t, int>)
return value == 3;
else if constexpr(std::is_same_v<value_t, double>)
return std::abs(value - 1.2) < 0.00001;
else
return false;
};
static_assert(seqan3::detail::all_of(fn, 3, 1.2, false)); // evalates to true
static_assert(!seqan3::detail::all_of(fn, 3, 1.2, false, "something else")); // evalates to false

Complexity

Linear in the number of elements in the pack.

Attention
Opposed to the std::all_of the argument order is changed, such that the first argument is the unary predicate to invoke on each argument followed by the arguments. This is due to a constraint in the c++ language regarding parameter packs.
See also
https://en.cppreference.com/w/cpp/language/parameter_pack

◆ ceil_log2()

template<std::unsigned_integral unsigned_t>
constexpr unsigned_t seqan3::detail::ceil_log2 ( unsigned_t const  n)
constexprnoexcept

Computes the ceil of the logarithm to the base of two for unsigned integers.

Parameters
[in]nAn unsigned integer.
Attention
n = 0 is a special case and is undefined.
Returns
$ \lceil log_2(n) \rceil $.

The difference to std::ceil(std::log2(n)) is that everything is computed exactly (without precision loss due to promoting to double)

Example

int main()
{
// the same as std::ceil(std::log2(x)), but exact for unsigned integers
seqan3::debug_stream << "ceil_log2(2^0 + 0): " << seqan3::detail::ceil_log2(1u) << '\n'; // 0u
seqan3::debug_stream << "ceil_log2(2^1 + 0): " << seqan3::detail::ceil_log2(2u) << '\n'; // 1u
seqan3::debug_stream << "ceil_log2(2^1 + 1): " << seqan3::detail::ceil_log2(3u) << '\n'; // 2u
seqan3::debug_stream << "ceil_log2(2^2 + 0): " << seqan3::detail::ceil_log2(4u) << '\n'; // 2u
seqan3::debug_stream << "ceil_log2(2^2 + 1): " << seqan3::detail::ceil_log2(5u) << '\n'; // 3u
seqan3::debug_stream << "ceil_log2(2^2 + 2): " << seqan3::detail::ceil_log2(6u) << '\n'; // 3u
seqan3::debug_stream << "ceil_log2(2^2 + 3): " << seqan3::detail::ceil_log2(7u) << '\n'; // 3u
seqan3::debug_stream << "ceil_log2(2^3 + 0): " << seqan3::detail::ceil_log2(8u) << '\n'; // 3u
seqan3::debug_stream << "ceil_log2(2^3 + 1): " << seqan3::detail::ceil_log2(9u) << '\n'; // 4u
return 0;
}
constexpr unsigned_t ceil_log2(unsigned_t const n) noexcept
Computes the ceil of the logarithm to the base of two for unsigned integers.
Definition: math.hpp:88
debug_stream_type debug_stream
A global instance of seqan3::debug_stream_type.
Definition: debug_stream.hpp:42
Provides math related functionality.

Exception

No-throw guarantee.

Thread-safety

Thread safe.

Complexity

Constant.

◆ floor_log2()

template<std::unsigned_integral unsigned_t>
constexpr unsigned_t seqan3::detail::floor_log2 ( unsigned_t const  n)
constexprnoexcept

Computes the floor of the logarithm to the base of two for unsigned integers.

Parameters
[in]nAn unsigned integer.
Attention
n = 0 is a special case and is undefined.
Returns
$ \lfloor log_2(n) \rfloor $.

The difference to std::floor(std::log2(n)) is that everything is computed exactly (without precision loss due to promoting to double)

Example

int main()
{
// the same as std::floor(std::log2(x)), but exact for unsigned integers
seqan3::debug_stream << "floor_log2(2^0 + 0): " << seqan3::detail::floor_log2(1u) << '\n'; // 0u
seqan3::debug_stream << "floor_log2(2^1 + 0): " << seqan3::detail::floor_log2(2u) << '\n'; // 1u
seqan3::debug_stream << "floor_log2(2^1 + 1): " << seqan3::detail::floor_log2(3u) << '\n'; // 1u
seqan3::debug_stream << "floor_log2(2^2 + 0): " << seqan3::detail::floor_log2(4u) << '\n'; // 2u
seqan3::debug_stream << "floor_log2(2^2 + 1): " << seqan3::detail::floor_log2(5u) << '\n'; // 2u
seqan3::debug_stream << "floor_log2(2^2 + 2): " << seqan3::detail::floor_log2(6u) << '\n'; // 2u
seqan3::debug_stream << "floor_log2(2^2 + 3): " << seqan3::detail::floor_log2(7u) << '\n'; // 2u
seqan3::debug_stream << "floor_log2(2^3 + 0): " << seqan3::detail::floor_log2(8u) << '\n'; // 3u
seqan3::debug_stream << "floor_log2(2^3 + 1): " << seqan3::detail::floor_log2(9u) << '\n'; // 3u
return 0;
}
constexpr unsigned_t floor_log2(unsigned_t const n) noexcept
Computes the floor of the logarithm to the base of two for unsigned integers.
Definition: math.hpp:54

Exception

No-throw guarantee.

Thread-safety

Thread safe.

Complexity

Constant.

◆ for_each() [1/2]

template<typename type_list_t , typename unary_function_t >
constexpr void seqan3::detail::for_each ( unary_function_t &&  fn)
constexpr

Applies a function element wise to all types of a type list.

Template Parameters
list_tA type list; must model seqan3::detail::template_specialisation_of a seqan3::type_list.
unary_function_tThe function type, like function pointers, functors and lambdas; must model std::invocable on each type of the type list wrapped in std::type_identity.
Parameters
[in]fnThe function to call on every type contained in the list.

This function operates on types instead of values. The following steps are performed to call the passed unary function on the types contained in the type list:

Note that wrapping the types in std::type_identity is a technical trick to make a type representable as a value. Instantiating a type might not work because they might not be std::default_initializable. In addition, it is possible to invoke the unary function on incomplete types.

Example

#include <string>
namespace incomplete
{
struct type;
} // namespace incomplete
int main()
{
// With c++20 you could also write it like this
// auto fn = []<typename type>(std::type_identity<type>)
// {
// ...
// };
auto fn = [](auto id)
{
// id is of type std::type_identity<type>
using id_t = decltype(id);
using type = typename id_t::type;
static_assert(std::is_same_v<id_t, std::type_identity<type>>, "id is of type std::type_identity<type>");
if constexpr(std::is_same_v<type, bool>)
else if constexpr(std::is_same_v<type, int>)
else if constexpr(std::is_same_v<type, float>)
else if constexpr(std::is_same_v<type, incomplete::type>)
seqan3::debug_stream << "incomplete::type";
};
// prints each type name, i.e. "int, float, bool, incomplete::type, \n"
seqan3::detail::for_each<types>(fn);
// is the same as explicitly writing
return 0;
}

Complexity

Linear in the number of types in the seqan3::type_list.

[Compile-time complexity: Linear number of template instantiations.]

See also
seqan3::detail::for_each

◆ for_each() [2/2]

template<typename unary_function_t , typename ... pack_t>
constexpr void seqan3::detail::for_each ( unary_function_t &&  fn,
pack_t &&...  args 
)
constexpr

Applies a function to each element of the given function parameter pack.

Template Parameters
unary_function_tThe function type, like function pointers, functors and lambdas.
pack_tThe parameter pack of the arguments (each argument type can be different).
Parameters
[in]fnThe function to call on every argument.
[in]argsThe parameter pack.

This function behaves like std::for_each but on parameter packs. The invocation(s) will be done without any loop.

Example

#include <string>
int main()
{
auto fn = [](auto && a)
{
};
// prints each argument, i.e. "0, 1, 2, 3\n"
seqan3::detail::for_each(fn, 0, ", ", 1.0, ", ", std::string{"2, 3"}, '\n');
// is the same as explicitly writing
fn(0);
fn(", ");
fn(1.0);
fn(", ");
fn(std::string{"2, 3"});
fn('\n');
return 0;
}
constexpr void for_each(unary_function_t &&fn, pack_t &&...args)
Applies a function to each element of the given function parameter pack.
Definition: pack_algorithm.hpp:195

Complexity

Linear in the number of elements in the pack.

Attention
Opposed to the std::for_each the argument order is changed, such that the first argument is the unary function to invoke on each argument followed by the arguments. This is due to a constraint in the c++ language regarding parameter packs.
See also
https://en.cppreference.com/w/cpp/language/parameter_pack

◆ pow()

template<typename base_t , std::unsigned_integral exp_t>
base_t seqan3::pow ( base_t  base,
exp_t  exp 
)

Computes the value of base raised to the power exp.

Parameters
[in]baseThe base to compute the power for.
[in]expThe power to raise base to.
Returns
$ base^{exp} $.
Exceptions
std::overflow_errorif an overflow occurs (Only in Debug build).
std::underflow_errorif an underflow occurs (Only in Debug build).
See also
https://en.cppreference.com/w/cpp/numeric/math/pow

The difference to std::pow is that the powers of an integer base are computed exact (without precision loss due to promoting to double) iff exp_t models std::unsigned_integral and

  • base_t models std::unsigned_integral (returns uint64_t)
  • base_t models std::integral, but not std::unsigned_integral (returns int64_t)

In all other cases the return value and type is equivalent to that of std::pow.

Example

int main()
{
// Uses specialisation for signed integers.
seqan3::debug_stream << seqan3::pow(2, 3u) << '\n'; // Prints 8
seqan3::debug_stream << seqan3::pow(-2, 3u) << '\n'; // Prints -8
// Uses specialisation for unsigned integers.
seqan3::debug_stream << seqan3::pow(2u, 3u) << '\n'; // Prints 8
// Uses `std::pow`.
seqan3::debug_stream << seqan3::pow(2, 3) << '\n'; // Prints 8
seqan3::debug_stream << seqan3::pow(2u, 3) << '\n'; // Prints 8
seqan3::debug_stream << seqan3::pow(2.0, 3) << '\n'; // Prints 8
// 5^25 should be 298023223876953125.
seqan3::debug_stream << seqan3::pow(5u, 25u) << '\n'; // Prints 298023223876953125
seqan3::debug_stream << static_cast<uint64_t>(std::pow(5u, 25u)) << '\n'; // Prints 298023223876953152 (wrong!)
}
base_t pow(base_t base, exp_t exp)
Computes the value of base raised to the power exp.
Definition: math.hpp:124
T pow(T... args)

Variable Documentation

◆ add_enum_bitwise_operators

template<typename t >
constexpr bool seqan3::add_enum_bitwise_operators = false
constexpr

Set to true for a scoped enum to have binary operators overloaded.

If this type trait is specialised for an enum, the binary operators &, |, ^, ~, &=, |=, ^= will be added and behave just like for ints or unscoped enums.

Example

enum class my_enum
{
VAL1 = 1,
VAL2 = 2,
COMB = 3
};
template <>
constexpr bool seqan3::add_enum_bitwise_operators<my_enum> = true;
int main()
{
using seqan3::operator|;
my_enum e = my_enum::VAL1;
my_enum e2 = e | my_enum::VAL2;
// e2 == my_enum::COMB;
}
Provides seqan3::add_enum_bitwise_operators.

◆ debug_stream_range_guard

template<typename rng_t >
SEQAN3_CONCEPT seqan3::detail::debug_stream_range_guard
Initial value:
=
!std::same_as<std::remove_cvref_t<std::ranges::range_reference_t<rng_t>>,
!(std::is_pointer_v<std::decay_t<rng_t>> &&
std::same_as<std::remove_cvref_t<std::ranges::range_reference_t<rng_t>>, char>)

A helper concept definition for ranges that can be streamed to the seqan3::debug_stream.

Template Parameters
rng_tThe range type to check.

This concept refines the std::ranges::input_range concept to allow streaming the range object to the debug stream, with the following requirements:

  • rng_t is not the same type as std::ranges::range_reference_t<rng_t>,
  • rng_t is not a pointer or c-style array,
  • std::ranges::range_reference_t<rng_t> is not char.

◆ is_class_template_declarable_with_v

template<template< typename ... > typename query_t, typename ... args_t>
template<template< typename ... > typename query_t, typename ... args_t>
constexpr bool is_class_template_declarable_with_v
related
Initial value:
=
is_class_template_declarable_with<query_t, args_t...>::value

Helper variable template for seqan3::detail::is_class_template_declarable_with.

Template Parameters
query_tThe type of the template class to test.
args_tThe template parameter pack to instantiate the template class with.

◆ is_type_list_of_alignment_file_input_formats_v

template<typename t >
constexpr bool seqan3::detail::is_type_list_of_alignment_file_input_formats_v = false
constexpr

Auxiliary value metafuncton that checks whether a type is a seqan3::type_list and all types meet seqan3::alignment_file_input_format [default is false].

See also
seqan3::type_list_specialisationOfalignment_file_input_formats

◆ is_type_list_of_alignment_file_input_formats_v< type_list< ts... > >

template<typename ... ts>
constexpr bool seqan3::detail::is_type_list_of_alignment_file_input_formats_v< type_list< ts... > >
constexpr
Initial value:
=
The generic concept for alignment file input formats.

Auxiliary value metafuncton that checks whether a type is a seqan3::type_list and all types meet seqan3::alignment_file_input_format [overload].

See also
seqan3::type_list_specialisationOfalignment_file_input_formats

◆ is_type_list_of_alignment_file_output_formats_v

template<typename t >
constexpr bool seqan3::detail::is_type_list_of_alignment_file_output_formats_v = false
constexpr

Auxiliary value metafuncton that checks whether a type is a seqan3::type_list and all types meet seqan3::alignment_file_output_format [default is false].

See also
seqan3::type_list_specialisationOfalignment_file_output_formats

◆ is_type_list_of_alignment_file_output_formats_v< type_list< ts... > >

template<typename ... ts>
constexpr bool seqan3::detail::is_type_list_of_alignment_file_output_formats_v< type_list< ts... > > = (alignment_file_output_format<ts> && ...)
constexpr

Auxiliary value metafuncton that checks whether a type is a seqan3::type_list and all types meet seqan3::alignment_file_output_format [overload].

See also
seqan3::type_list_specialisationOfalignment_file_output_formats

◆ is_type_list_of_sequence_file_input_formats_v

template<typename t >
constexpr bool seqan3::detail::is_type_list_of_sequence_file_input_formats_v = false
constexpr

Auxiliary value metafuncton that checks whether a type is a seqan3::type_list and all types meet seqan3::sequence_file_input_format [default is false].

See also
seqan3::type_list_specialisationOfsequence_file_input_formats

◆ is_type_list_of_sequence_file_input_formats_v< type_list< ts... > >

template<typename ... ts>
constexpr bool seqan3::detail::is_type_list_of_sequence_file_input_formats_v< type_list< ts... > >
constexpr
Initial value:
=
The generic concept for sequence file in formats.

Auxiliary value metafuncton that checks whether a type is a seqan3::type_list and all types meet seqan3::sequence_file_input_format [overload].

See also
seqan3::type_list_specialisationOfsequence_file_input_formats

◆ is_type_list_of_sequence_file_output_formats_v

template<typename t >
constexpr bool seqan3::detail::is_type_list_of_sequence_file_output_formats_v = false
constexpr

Auxiliary value metafuncton that checks whether a type is a seqan3::type_list and all types meet seqan3::sequence_file_output_format [default is false].

See also
seqan3::type_list_specialisationOfsequence_file_output_formats

◆ is_type_list_of_sequence_file_output_formats_v< type_list< ts... > >

template<typename ... ts>
constexpr bool seqan3::detail::is_type_list_of_sequence_file_output_formats_v< type_list< ts... > >
constexpr
Initial value:
=
The generic concept for sequence file out formats.

Auxiliary value metafuncton that checks whether a type is a seqan3::type_list and all types meet seqan3::sequence_file_output_format [overload].

See also
seqan3::type_list_specialisationOfsequence_file_output_formats

◆ is_type_list_of_structure_file_input_formats_v

template<typename t >
constexpr bool seqan3::detail::is_type_list_of_structure_file_input_formats_v = false
constexpr

Auxiliary value metafuncton that checks whether a type is a seqan3::type_list and all types meet seqan3::structure_file_input_format [default is false].

See also
seqan3::type_list_specialisationOfstructure_file_input_formats

◆ is_type_list_of_structure_file_input_formats_v< type_list< ts... > >

template<typename ... ts>
constexpr bool seqan3::detail::is_type_list_of_structure_file_input_formats_v< type_list< ts... > > = (structure_file_input_format<ts> && ...)
constexpr

Auxiliary value metafuncton that checks whether a type is a seqan3::type_list and all types meet seqan3::structure_file_input_format [overload].

See also
seqan3::type_list_specialisationOfstructure_file_input_formats

◆ is_type_list_of_structure_file_output_formats_v

template<typename t >
constexpr bool seqan3::detail::is_type_list_of_structure_file_output_formats_v = false
constexpr

Auxiliary value metafuncton that checks whether a type is a seqan3::type_list and all types meet seqan3::structure_file_output_format [default is false].

See also
seqan3::type_list_specialisationOfstructure_file_output_formats

◆ is_type_list_of_structure_file_output_formats_v< type_list< ts... > >

template<typename ... ts>
constexpr bool seqan3::detail::is_type_list_of_structure_file_output_formats_v< type_list< ts... > > = (structure_file_output_format<ts> && ...)
constexpr

Auxiliary value metafuncton that checks whether a type is a seqan3::type_list and all types meet seqan3::structure_file_output_format [overload].

See also
seqan3::type_list_specialisationOfstructure_file_output_formats

◆ range_dimension_v

template<typename t >
constexpr size_t seqan3::range_dimension_v = 1
constexpr

Returns the number of times you can call seqan3::value_type_t recursively on t (type trait).

Template Parameters
tThe type to be queried; must resolve seqan3::value_type_t at least once.

Attention, this type trait implicitly removes cv-qualifiers and reference from the types it recurses on and returns.

◆ reference_type_is_streamable_v

template<std::ranges::range rng_t, typename char_t >
constexpr bool seqan3::detail::reference_type_is_streamable_v = false
constexpr

Helper template variable that checks if the reference type of a range can be streamed into an instance of seqan3::debug_stream_type .

Template Parameters
rng_tThe range type to check.
char_tThe char type of the stream.

Evaluates to true if the following expression is valid: debug_stream << *rng.begin();, where rng is of type rng_t. Otherwise false.

◆ type_list_of_alignment_file_input_formats

template<typename t >
SEQAN3_CONCEPT seqan3::detail::type_list_of_alignment_file_input_formats = is_type_list_of_alignment_file_input_formats_v<t>

Auxiliary concept that checks whether a type is a seqan3::type_list and all types meet seqan3::alignment_file_input_format.

See also
seqan3::is_type_list_of_alignment_file_formats_v

◆ type_list_of_alignment_file_output_formats

template<typename t >
SEQAN3_CONCEPT seqan3::detail::type_list_of_alignment_file_output_formats = is_type_list_of_alignment_file_output_formats_v<t>

Auxiliary concept that checks whether a type is a seqan3::type_list and all types meet seqan3::alignment_file_output_format.

See also
seqan3::is_type_list_of_alignment_file_formats_v

◆ type_list_of_sequence_file_input_formats

template<typename t >
SEQAN3_CONCEPT seqan3::detail::type_list_of_sequence_file_input_formats = is_type_list_of_sequence_file_input_formats_v<t>

Auxiliary concept that checks whether a type is a seqan3::type_list and all types meet seqan3::sequence_file_input_format.

See also
seqan3::is_type_list_of_sequence_file_formats_v

◆ type_list_of_sequence_file_output_formats

template<typename t >
SEQAN3_CONCEPT seqan3::detail::type_list_of_sequence_file_output_formats = is_type_list_of_sequence_file_output_formats_v<t>

Auxiliary concept that checks whether a type is a seqan3::type_list and all types meet seqan3::sequence_file_output_format.

See also
seqan3::is_type_list_of_sequence_file_formats_v

◆ type_list_of_structure_file_input_formats

template<typename t >
SEQAN3_CONCEPT seqan3::detail::type_list_of_structure_file_input_formats = is_type_list_of_structure_file_input_formats_v<t>

Auxiliary concept that checks whether a type is a seqan3::type_list and all types meet seqan3::structure_file_input_format.

See also
seqan3::is_type_list_of_structure_file_formats_v

◆ type_list_of_structure_file_output_formats

template<typename t >
SEQAN3_CONCEPT seqan3::detail::type_list_of_structure_file_output_formats = is_type_list_of_structure_file_output_formats_v<t>

Auxiliary concept that checks whether a type is a seqan3::type_list and all types meet seqan3::structure_file_output_format.

See also
seqan3::is_type_list_of_structure_file_formats_v

◆ type_name_as_string

template<typename type >
std::string const seqan3::detail::type_name_as_string
inline

Defines the human-readable name of the given type using the typeid operator.

Template Parameters
typeThe type to get the human-readable name for.

On gcc and clang std::type_info only returns a mangled name. The mangled name can be converted to human-readable form using implementation-specific API such as abi::__cxa_demangle. In other implementations the name returned is already human-readable.

Note
The returned name is implementation defined and might change between different tool chains.