Loading...
Searching...
No Matches
cxx Namespace Reference
Small C++ Template Library

Our C++ library. More...

## Namespaces

namespace | Bits
| Internal helpers for the cxx package.

## Data Structures

class | Avl_map
| AVL tree based associative container. More...
class | Avl_set
| AVL set for simple comparable items. More...
class | Avl_tree_node
| Node of an AVL tree. More...
class | Avl_tree
| A generic AVL tree. More...
class | Bitfield
| Definition for a member (part) of a bit field. More...
class | Bitmap_base
| Basic bitmap abstraction. More...
class | Bitmap
| A static bitmap. More...
class | H_list_item_t
| Basic element type for a double-linked H_list. More...
class | H_list
| General double-linked list of unspecified cxx::H_list_item elements. More...
struct | H_list_t
| Double-linked list of typed H_list_item_t elements. More...
class | List_item
| Basic list item. More...
class | List
| Doubly linked list, with internal allocation. More...
class | List_alloc
| Standard list-based allocator. More...
struct | Pair
| Pair of two values. More...
class | Pair_first_compare
| Comparison functor for Pair. More...
class | Ref_ptr
| A reference-counting pointer with automatic cleanup. More...
struct | Ref_obj_list_item
| Item for list linked via cxx::Ref_ptr with default refence counting. More...
class | Base_slab
| Basic slab allocator. More...
class | Slab
| Slab allocator for object of type Type. More...
class | Base_slab_static
| Merged slab allocator (allocators for objects of the same size are merged together). More...
class | Slab_static
| Merged slab allocator (allocators for objects of the same size are merged together). More...
class | S_list
| Simple single-linked list. More...
class | static_vector
| Simple encapsulation for a dynamically allocated array. More...
class | Nothrow
| Helper type to distinguish the `operator new` version that does not throw exceptions. More...
class | New_allocator
| Standard allocator based on `operator new ()` . More...
struct | Lt_functor
| Generic comparator class that defaults to the less-than operator. More...
class | String
| Allocation free string class with explicit length field. More...
class | Weak_ref_base
| Generic (base) weak reference to some object. More...
class | Weak_ref
| Typed weak reference to an object of type T. More...

## Typedefs

typedef H_list_item_t< void > | H_list_item
| Untyped list item.
template<typename T>
using | Ref_ptr_list_item = Bits::Smart_ptr_list_item<T, cxx::Ref_ptr<T> >
| Item for list linked with cxx::Ref_ptr.
template<typename T>
using | Ref_ptr_list = Bits::Smart_ptr_list<Ref_ptr_list_item<T> >
| Single-linked list where elements are connected via a cxx::Ref_ptr.
template<typename T>
using | Unique_ptr_list_item = Bits::Smart_ptr_list_item<T, cxx::unique_ptr<T> >
| Item for list linked with cxx::unique_ptr.
template<typename T>
using | Unique_ptr_list = Bits::Smart_ptr_list<Unique_ptr_list_item<T> >
| Single-linked list where elements are connected with a cxx::unique_ptr.

## Functions

template<typename A, typename ... ARGS>
constexpr A const & | min (A const &a1, A const &a2, ARGS const &...a)
| Get the minimum of a1 and a2 upt to aN.
template<typename A, typename ... ARGS>
constexpr A const & | min (cxx::identity_t< A > const &a1, cxx::identity_t< A > const &a2, ARGS const &...a)
| Get the minimum of a1 and a2 upt to aN.
template<typename A, typename ... ARGS>
constexpr A const & | max (A const &a1, A const &a2, ARGS const &...a)
| Get the maximum of a1 and a2 upt to aN.
template<typename A, typename ... ARGS>
constexpr A const & | max (cxx::identity_t< A > const &a1, cxx::identity_t< A > const &a2, ARGS const &...a)
| Get the maximum of a1 and a2 upt to aN.
template<typename T1>
T1 | clamp (T1 v, T1 lo, T1 hi)
| Limit v to the range given by lo and hi.
template<typename T>
constexpr T | gcd (T a, T b)
| Compute the greatest common divisor of two unsigned values.
template<typename T>
constexpr T | lcm (T a, T b)
| Compute the least common multiple of two unsigned values.
template<typename T>
T | access_once (T const *a)
| Read the value at an address at most once.
template<typename T, typename VAL>
void | write_now (T *a, VAL &&val)
| Write a value at an address exactly once.

## Detailed Description

Our C++ library.

Small Low-Level C++ Library.

Strings.

Various kinds of C++ utilities.

## Function Documentation

## access_once()

template<typename T>

T cxx::access_once | ( | T const * | a | ) |

inline

Read the value at an address at most once.

The read might be omitted if the result is not used by any code unless typename contains volatile. If the read operation has side effects and must not be omitted, use different means like L4drivers::Mmio_register_block or similar.

The compiler is disallowed to reuse a previous read at the same address, for example:

val1 = *a;
val2 = access_once(a); // compiler may not replace this by val2 = val1;
cxx::access_once
T access_once(T const *a)
Read the value at an address at most once.
Definition utils:40

The compiler is also disallowed to repeat the read, for example:

val1 = access_once(a);
val2 = val1; // compiler may not replace this by val2 = *a;

The above implies that the compiler is also disallowed to move the read out of or into loops.

Note
  The read might still be moved relative to other code.
  The value might be read from a hardware cache, not from RAM.

Definition at line 40 of file utils.

Referenced by L4virtio::Svr::Request_processor::next(), and L4virtio::Svr::Request_processor::start().

Here is the caller graph for this function:

## gcd()

template<typename T>

T cxx::gcd | ( | T | a,
|  | T | b )

constexpr

Compute the greatest common divisor of two unsigned values.

This uses the Euclidean modulo algorithm.

Note
  Contrary to the C++17 specification, this implementation requires the same unsigned type of both arguments and returns the same type (not a common type). This should be fine for most practical use cases.
  Contrary to the C++17 specification, this implementation does not accept signed arguments and negative literals.

Template Parameters

  T | Unsigned integer type of the values.

Parameters

  a | First input.
  b | Second input.

Returns
  Greatest common divisor of the input values.

Definition at line 34 of file numeric.

Referenced by lcm().

Here is the caller graph for this function:

## lcm()

template<typename T>

T cxx::lcm | ( | T | a,
|  | T | b )

constexpr

Compute the least common multiple of two unsigned values.

This uses the greatest common divisor to compute the least common multiple.

Note
  Contrary to the C++17 specification, this implementation requires the same unsigned type of both arguments and returns the same type (not a common type). This should be fine for most practical use cases.
  Contrary to the C++17 specification, this implementation does not accept signed arguments and negative literals.

Template Parameters

  T | Unsigned integer type of the values.

Parameters

  a | First input.
  b | Second input.

Returns
  Least common multiple of the input values.

Definition at line 68 of file numeric.

References gcd().

Here is the call graph for this function:

## write_now()

template<typename T, typename VAL>

void cxx::write_now | ( | T * | a,
|  | VAL && | val )

inline

Write a value at an address exactly once.

The compiler is disallowed to skip the write, for example:

*a = val;
write_now(a, val); // compiler may not skip this line
cxx::write_now
void write_now(T *a, VAL &&val)
Write a value at an address exactly once.
Definition utils:71

The compiler is also disallowed to repeat the write.

The above implies that the compiler is also disallowed to move the write out of or into loops.

Note
  The write might still be moved relative to other code.
  The value might be written just to a hardware cache for the moment, not immediately to RAM.

Definition at line 71 of file utils.