SeqAn3 3.1.0
The Modern C++ library for sequence analysis.

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

+ Collaboration diagram for Utility:


 Builtin Character Operations
 Provides various operations on character types.
 Provides various general purpose concepts.
 Provides various general purpose container and concepts.
 The range module provides general purpose range concepts.
 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.
 Views are "lazy range combinators" that offer modified views onto other ranges.


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

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.

Function Documentation

◆ 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.

[in]baseThe base to compute the power for.
[in]expThe power to raise base to.
$ base^{exp} $.
std::overflow_errorif an overflow occurs (Only in Debug build).
std::underflow_errorif an underflow occurs (Only in Debug build).
See also

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.


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!)
Provides seqan3::debug_stream and related types.
debug_stream_type debug_stream
A global instance of seqan3::debug_stream_type.
Definition: debug_stream.hpp:37
base_t pow(base_t base, exp_t exp)
Computes the value of base raised to the power exp.
Definition: math.hpp:124
Provides math related functionality.
T pow(T... args)