guanaqo 1.0.0-alpha.27
Utilities for scientific software
Loading...
Searching...
No Matches
Core Utilities

Detailed Description

Core helpers such as lookup tables, chunked loops, and assertion/assumption macros.

Collaboration diagram for Core Utilities:

Topics

 Strings & Parsing
 String utilities and portable parsing helpers.
 Macros & Build Helpers
 Public-facing preprocessor utilities.

Files

file  demangled-typename.hpp
 Pretty-print type names.
file  loop.hpp
 Chunked iteration helpers.
file  lut.hpp
 Compile-time lookup table generators.
file  max-history.hpp
 Sliding-window maximum tracker.
file  not-implemented.hpp
 Exception type for unimplemented functionality.
file  possible-alias.hpp
 Utility to guard against accidental template aliases.
file  ringbuffer.hpp
 Circular index utilities and iterators.
file  type-traits.hpp
 Lightweight type-trait helpers.

Concepts

concept  guanaqo::no_leading_allocator

Classes

class  guanaqo::MaxHistory< T >
 Keep track of the maximum value over a specified horizon length. More...
struct  guanaqo::not_implemented_error
struct  guanaqo::CircularIndices< IndexT >
struct  guanaqo::CircularIndexIterator< IndexT >
struct  guanaqo::ReverseCircularIndexIterator< IndexT >
class  guanaqo::CircularRange< IndexT >
class  guanaqo::ReverseCircularRange< IndexT >
struct  guanaqo::last_type< First, Pack >
struct  guanaqo::last_type< Only >
struct  guanaqo::first_type_or_void< Pack >
struct  guanaqo::first_type_or_void< First, Pack... >
struct  guanaqo::first_type_or_void<>

Typedefs

template<class NewAlias, class... PossibleAliases>
using guanaqo::possible_alias_t
 If NewAlias is not the same type as any of PossibleAliases, the result is NewAlias.
template<auto M>
using guanaqo::class_from_member_ptr_t = class_from_member_ptr_impl_t<decltype(M)>
template<class... Pack>
using guanaqo::last_type_t = typename last_type<Pack...>::type
template<class... Pack>
using guanaqo::first_type_or_void_t = typename first_type_or_void<Pack...>::type

Enumerations

enum class  guanaqo::LoopDir : bool { guanaqo::LoopDir::Forward , guanaqo::LoopDir::Backward }
 Direction for chunked iteration. More...

Functions

std::string guanaqo::demangled_typename (const std::type_info &t)
 Get the pretty name of the given type as a string.
template<class I>
void guanaqo::foreach_chunked (I i_begin, I i_end, auto chunk_size, auto func_chunk, auto func_rem, LoopDir dir=LoopDir::Forward)
template<class I>
void guanaqo::foreach_chunked_merged (I i_begin, I i_end, auto chunk_size, auto func_chunk, LoopDir dir=LoopDir::Forward)
template<class I, I R, I C, class F>
consteval auto guanaqo::make_2d_lut (F f)
 Returns a 2D array of the form:
template<class I, I N, class F>
consteval auto guanaqo::make_1d_lut (F f)
 Returns an array of the form:
template<auto... Ranges, class F>
consteval auto guanaqo::make_lut (F f)
 Generalization of make_1d_lut and make_2d_lut.

Class Documentation

◆ guanaqo::last_type

struct guanaqo::last_type
Collaboration diagram for guanaqo::last_type< First, Pack >:
Class Members
typedef typename type type typename last_type<Pack...>::type

◆ guanaqo::last_type< Only >

struct guanaqo::last_type< Only >
Collaboration diagram for guanaqo::last_type< Only >:
Class Members
typedef Only type Only

◆ guanaqo::first_type_or_void

struct guanaqo::first_type_or_void
Collaboration diagram for guanaqo::first_type_or_void< Pack >:

◆ guanaqo::first_type_or_void< First, Pack... >

struct guanaqo::first_type_or_void< First, Pack... >
Collaboration diagram for guanaqo::first_type_or_void< First, Pack... >:
Class Members
typedef First type First

◆ guanaqo::first_type_or_void<>

struct guanaqo::first_type_or_void<>
Collaboration diagram for guanaqo::first_type_or_void<>:
Class Members
typedef void type void

Typedef Documentation

◆ possible_alias_t

template<class NewAlias, class... PossibleAliases>
using guanaqo::possible_alias_t

#include <guanaqo/possible-alias.hpp>

Initial value:
std::conditional_t<detail::any_is_same<NewAlias, PossibleAliases...>(),
constexpr bool any_is_same()
Check if A is equal to any of Bs.
Unused unique type tag for template specializations that were rejected because some types were not di...

If NewAlias is not the same type as any of PossibleAliases, the result is NewAlias.

If NewAlias is not distinct from PossibleAliases, the result is a dummy type, uniquely determined by NewAlias and PossibleAliases.

Definition at line 31 of file possible-alias.hpp.

◆ class_from_member_ptr_t

template<auto M>
using guanaqo::class_from_member_ptr_t = class_from_member_ptr_impl_t<decltype(M)>

#include <guanaqo/type-traits.hpp>

Definition at line 34 of file type-traits.hpp.

◆ last_type_t

template<class... Pack>
using guanaqo::last_type_t = typename last_type<Pack...>::type

#include <guanaqo/type-traits.hpp>

Definition at line 45 of file type-traits.hpp.

◆ first_type_or_void_t

template<class... Pack>
using guanaqo::first_type_or_void_t = typename first_type_or_void<Pack...>::type

#include <guanaqo/type-traits.hpp>

Definition at line 58 of file type-traits.hpp.

Enumeration Type Documentation

◆ LoopDir

enum class guanaqo::LoopDir : bool
strong

#include <guanaqo/loop.hpp>

Direction for chunked iteration.

Enumerator
Forward 
Backward 

Definition at line 11 of file loop.hpp.

Function Documentation

◆ demangled_typename()

std::string guanaqo::demangled_typename ( const std::type_info & t)

#include <guanaqo/demangled-typename.hpp>

Get the pretty name of the given type as a string.

Definition at line 11 of file demangled-typename.cpp.

Here is the caller graph for this function:

◆ foreach_chunked()

template<class I>
void guanaqo::foreach_chunked ( I i_begin,
I i_end,
auto chunk_size,
auto func_chunk,
auto func_rem,
LoopDir dir = LoopDir::Forward )
inline

#include <guanaqo/loop.hpp>

Definition at line 19 of file loop.hpp.

◆ foreach_chunked_merged()

template<class I>
void guanaqo::foreach_chunked_merged ( I i_begin,
I i_end,
auto chunk_size,
auto func_chunk,
LoopDir dir = LoopDir::Forward )
inline

#include <guanaqo/loop.hpp>

Definition at line 41 of file loop.hpp.

◆ make_2d_lut()

template<class I, I R, I C, class F>
auto guanaqo::make_2d_lut ( F f)
consteval

#include <guanaqo/lut.hpp>

Returns a 2D array of the form:

{{ f(0, 0), f(0, 1), ..., f(0, C - 1) },
{ f(1, 0), f(1, 1), ..., f(1, C - 1) },
{ ..., ..., ..., ... },
{ f(R - 1, 0), f(R - 1, 1)}, ..., f(R - 1, C - 1) }}

The argument f should be a function (or callable) that accepts two arguments of type std::integral_constant.

Example 1: compile-time arguments

[]<int R, int C>(std::integral_constant<int, R>,
std::integral_constant<int, C>) {
return std::pair{R, C};
});
for (const auto &row : lut) {
for (const auto &el : row)
std::cout << "(" << el.first << ", " << el.second << ")\t";
std::cout << "\n";
}
consteval auto make_2d_lut(F f)
Returns a 2D array of the form:
Definition lut.hpp:57
(0, 0) (0, 1) (0, 2) (0, 3)
(1, 0) (1, 1) (1, 2) (1, 3)
(2, 0) (2, 1) (2, 2) (2, 3)

Example 2: run-time arguments

auto lut = guanaqo::make_2d_lut<int, 3, 4>([](int r, int c) {
return std::pair{r, c};
});
for (const auto &row : lut) {
for (const auto &el : row)
std::cout << "(" << el.first << ", " << el.second << ")\t";
std::cout << "\n";
}

Definition at line 57 of file lut.hpp.

◆ make_1d_lut()

template<class I, I N, class F>
auto guanaqo::make_1d_lut ( F f)
consteval

#include <guanaqo/lut.hpp>

Returns an array of the form:

{ f(0), f(1), ..., f(N - 1) }

The argument f should be a function (or callable) that accepts an argument of type std::integral_constant.

Definition at line 87 of file lut.hpp.

◆ make_lut()

template<auto... Ranges, class F>
auto guanaqo::make_lut ( F f)
consteval

#include <guanaqo/lut.hpp>

Generalization of make_1d_lut and make_2d_lut.

Generates an n-dimensional array of the given function f applied point-wise to the cartesian product of the ranges given as template parameters.

Template Parameters
RangesIntegers or arrays of structural types: an integer N results in the half-open range [0, N), and arrays result in all array elements being passed to the given function.

Example:

auto lut = guanaqo::make_lut<3, 4, std::array{10, 20, 30, 40, 50}>([](int i, int j, int k) {
return std::tuple{i, j, k};
});
for (const auto &slice : lut) {
for (const auto &row : slice) {
for (const auto [i, j, k] : row)
std::cout << "(" << i << ", " << j << ", " << k << ")\t";
std::cout << "\n";
}
std::cout << "\n";
}
consteval auto make_lut(F f)
Generalization of make_1d_lut and make_2d_lut.
Definition lut.hpp:180
(0, 0, 10) (0, 0, 20) (0, 0, 30) (0, 0, 40) (0, 0, 50)
(0, 1, 10) (0, 1, 20) (0, 1, 30) (0, 1, 40) (0, 1, 50)
(0, 2, 10) (0, 2, 20) (0, 2, 30) (0, 2, 40) (0, 2, 50)
(0, 3, 10) (0, 3, 20) (0, 3, 30) (0, 3, 40) (0, 3, 50)
(1, 0, 10) (1, 0, 20) (1, 0, 30) (1, 0, 40) (1, 0, 50)
(1, 1, 10) (1, 1, 20) (1, 1, 30) (1, 1, 40) (1, 1, 50)
(1, 2, 10) (1, 2, 20) (1, 2, 30) (1, 2, 40) (1, 2, 50)
(1, 3, 10) (1, 3, 20) (1, 3, 30) (1, 3, 40) (1, 3, 50)
(2, 0, 10) (2, 0, 20) (2, 0, 30) (2, 0, 40) (2, 0, 50)
(2, 1, 10) (2, 1, 20) (2, 1, 30) (2, 1, 40) (2, 1, 50)
(2, 2, 10) (2, 2, 20) (2, 2, 30) (2, 2, 40) (2, 2, 50)
(2, 3, 10) (2, 3, 20) (2, 3, 30) (2, 3, 40) (2, 3, 50)

Definition at line 180 of file lut.hpp.