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

Provides additional utility functionality used by multiple modules. More...

+ Collaboration diagram for Utility:

Modules

 Concept
 
 Builtin Character Operations
 Provides various operations on character types.
 
 Parallel
 This module contains types and utilities for concurrent execution of algorithms in SeqAn.
 
 Simd
 The simd module contains a unified interface to provide simd types and functions used in seqan3.
 
 Tuple
 Additional helper utilities for "tuple" types like std::tuple, std::pair, seqan3::pod_tuple that are not specific to a SeqAn module.
 
 Type List
 Provides seqan3::type_list and metaprogramming utilities for working on type lists.
 
 Type Pack
 Provides metaprogramming utilities for working on template parameter packs.
 
 Type Traits
 Provides various type traits and their shortcuts.
 

Classes

struct  seqan3::detail::models_strict_totally_ordered< state_t, element_t >
 Helper type trait function to check for std::totally_ordered on all elements of the given tuple type. More...
 
interface  pair_like
 Whether a type behaves like a tuple with exactly two elements. More...
 
struct  seqan3::pod_tuple< type0, types... >
 Behaves like std::tuple but is an aggregate PODType. More...
 
interface  tuple_get
 Subconcept definition for seqan3::tuple_like to test for std::get-interface. More...
 
interface  tuple_like
 Whether a type behaves like a tuple. More...
 
interface  tuple_size
 Subconcept definition for seqan3::tuple_like to test for std::tuple_size-interface. More...
 
struct  seqan3::detail::tuple_type_list< tuple_t >
 Transformation trait to expose the tuple element types as seqan3::type_list. More...
 

Typedefs

template<detail::tuple_size tuple_t>
using seqan3::detail::tuple_type_list_t = typename tuple_type_list< tuple_t >::type
 Helper type for seqan3::detail::tuple_type_list. More...
 

Functions

template<std::integral type>
constexpr type seqan3::detail::to_little_endian (type const in) noexcept
 Convert the byte encoding of integer values to little-endian byte order. More...
 
template<size_t beg, template< typename ... > typename tuple_t, size_t ... Is, typename ... ts>
constexpr auto seqan3::detail::tuple_split (tuple_t< ts... > const &t, std::index_sequence< Is... > const &idx)
 Helper function for seqan3::tuple_split. More...
 

Variables

template<typename type_t >
constexpr auto seqan3::detail::bits_of = min_viable_uint_v<CHAR_BIT * sizeof(type_t)>
 How many bits has a type? More...
 

Tuple utility functions

Helper functions for tuple like objects.

template<size_t pivot_c, template< typename ... > typename tuple_t, typename ... ts>
constexpr auto seqan3::tuple_split (tuple_t< ts... > const &t)
 Splits a tuple like data structure at the given position. More...
 
template<typename pivot_t , tuple_like tuple_t>
constexpr auto seqan3::tuple_split (tuple_t &&t)
 Splits a tuple like data structure at the first position of the given type. More...
 
template<tuple_like tuple_t>
constexpr auto seqan3::tuple_pop_front (tuple_t &&t)
 Removes the first element of a tuple. More...
 
template<size_t pivot_c, template< typename ... > typename tuple_t, typename ... ts>
constexpr auto seqan3::tuple_split (tuple_t< ts... > &&t)
 Splits a tuple like data structure at the given position. More...
 

Detailed Description

Provides additional utility functionality used by multiple modules.

The utility module contains concepts, functions, traits and classes that are independent of the remaining modules in SeqAn. These implementations are considered external functionality, i.e. they could have been outsourced into their own libraries.

The utility module has no dependency to any other module except the Core module.

Typedef Documentation

◆ tuple_type_list_t

template<detail::tuple_size tuple_t>
using seqan3::detail::tuple_type_list_t = typedef typename tuple_type_list<tuple_t>::type

Function Documentation

◆ to_little_endian()

template<std::integral type>
constexpr type seqan3::detail::to_little_endian ( type const  in)
constexprnoexcept

Convert the byte encoding of integer values to little-endian byte order.

Template Parameters
typeThe type of the value to convert; must model std::integral.
Parameters
inThe input value to convert.
Returns
the converted value in little-endian byte-order.

This function swaps the bytes if the host system uses big endian. In this case only 1, 2, 4, or 8 byte big integral types are allowed as input. On host systems with little endian this function is a no-op and returns the unchanged input value. Other systems with mixed endianness are not supported.

◆ tuple_pop_front()

template<tuple_like tuple_t>
constexpr auto seqan3::tuple_pop_front ( tuple_t &&  t)
constexpr

Removes the first element of a tuple.

Parameters
[in]tThe original tuple.
Returns
A new tuple without the first element of t.

Note, that the tuple must contain at least one element and must support empty tuple types, i.e. std::pair cannot be used.

Complexity

Linear in the number of elements.

Thread safety

Concurrent invocations of this functions are thread safe.

◆ tuple_split() [1/4]

template<typename pivot_t , tuple_like tuple_t>
constexpr auto seqan3::tuple_split ( tuple_t &&  t)
constexpr

Splits a tuple like data structure at the first position of the given type.

Template Parameters
pivot_tA template type specifying the split position.
Parameters
[in]tThe original tuple to split.
Returns
A new tuple of tuples with the left side of the split and the right side of the split.

Splits a tuple into two tuples, while the element at the split position will be contained in the second tuple. Note, that the returned tuples can be empty. For this reason it is not possible to use tuple like objects, that cannot be empty, i.e. std::pair. Using such an object will emit an compiler error.

example

int main()
{
// Split at position 2.
auto [left, right] = seqan3::tuple_split<2>(t);
// decltype(left) -> std::tuple<int, char>; decltype(right) -> std::tuple<float, std::string>;
// Split at position 0.
auto [left1, right1] = seqan3::tuple_split<0>(t);
// decltype(left1) -> std::tuple<>; decltype(right1) -> std::tuple<int, char, float, std::string>;
// Split at position 4.
auto [left2, right2] = seqan3::tuple_split<4>(t);
// decltype(left2) -> std::tuple<int, char, float, std::string>; decltype(right2) -> std::tuple<>;
}
T left(T... args)
Provides utility functions for tuple like interfaces.

Complexity

Linear in the number of elements.

Thread safety

Concurrent invocations of this functions are thread safe.

◆ tuple_split() [2/4]

template<size_t pivot_c, template< typename ... > typename tuple_t, typename ... ts>
constexpr auto seqan3::tuple_split ( tuple_t< ts... > &&  t)
constexpr

Splits a tuple like data structure at the given position.

Template Parameters
pivot_cA template value specifying the split position.
tuple_tA template alias for a tuple like object.
...tsTypes tuple_t is specified with.
Parameters
[in]tThe original tuple to split.
Returns
A new tuple of tuples with the left side of the split and the right side of the split.

Splits a tuple into two tuples, while the element at the split position will be contained in the second tuple. Note, that the returned tuples can be empty. For this reason it is not possible to use tuple like objects, that cannot be empty, i.e. std::pair. Using such an object will emit an compiler error.

example

int main()
{
// Split at position 2.
auto [left, right] = seqan3::tuple_split<2>(t);
// decltype(left) -> std::tuple<int, char>; decltype(right) -> std::tuple<float, std::string>;
// Split at position 0.
auto [left1, right1] = seqan3::tuple_split<0>(t);
// decltype(left1) -> std::tuple<>; decltype(right1) -> std::tuple<int, char, float, std::string>;
// Split at position 4.
auto [left2, right2] = seqan3::tuple_split<4>(t);
// decltype(left2) -> std::tuple<int, char, float, std::string>; decltype(right2) -> std::tuple<>;
}

Complexity

Linear in the number of elements.

Thread safety

Concurrent invocations of this functions are thread safe.

◆ tuple_split() [3/4]

template<size_t pivot_c, template< typename ... > typename tuple_t, typename ... ts>
constexpr auto seqan3::tuple_split ( tuple_t< ts... > const &  t)
constexpr

Splits a tuple like data structure at the given position.

Template Parameters
pivot_cA template value specifying the split position.
tuple_tA template alias for a tuple like object.
...tsTypes tuple_t is specified with.
Parameters
[in]tThe original tuple to split.
Returns
A new tuple of tuples with the left side of the split and the right side of the split.

Splits a tuple into two tuples, while the element at the split position will be contained in the second tuple. Note, that the returned tuples can be empty. For this reason it is not possible to use tuple like objects, that cannot be empty, i.e. std::pair. Using such an object will emit an compiler error.

example

int main()
{
// Split at position 2.
auto [left, right] = seqan3::tuple_split<2>(t);
// decltype(left) -> std::tuple<int, char>; decltype(right) -> std::tuple<float, std::string>;
// Split at position 0.
auto [left1, right1] = seqan3::tuple_split<0>(t);
// decltype(left1) -> std::tuple<>; decltype(right1) -> std::tuple<int, char, float, std::string>;
// Split at position 4.
auto [left2, right2] = seqan3::tuple_split<4>(t);
// decltype(left2) -> std::tuple<int, char, float, std::string>; decltype(right2) -> std::tuple<>;
}

Complexity

Linear in the number of elements.

Thread safety

Concurrent invocations of this functions are thread safe.

◆ tuple_split() [4/4]

template<size_t beg, template< typename ... > typename tuple_t, size_t ... Is, typename ... ts>
constexpr auto seqan3::detail::tuple_split ( tuple_t< ts... > const &  t,
std::index_sequence< Is... > const &  idx 
)
constexpr

Helper function for seqan3::tuple_split.

Template Parameters
begA template value containing the start position from where to extract the values.
tuple_tA template alias for a tuple like object.
...tsTypes tuple_t is specified with.
...IsIndices of the tuple elements that should be extracted.
Parameters
[in]tThe original tuple to split.
[in]idxAn std::index_sequence with all indices that should be extracted beginning at beg.
Returns
A new tuple with the extracted elements.

Variable Documentation

◆ bits_of

template<typename type_t >
constexpr auto seqan3::detail::bits_of = min_viable_uint_v<CHAR_BIT * sizeof(type_t)>
constexpr

How many bits has a type?

Template Parameters
type_tThe type to determine the number of bits.