mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
Updates to documentation
This commit is contained in:
parent
cb7cb104d7
commit
657816da9a
4
docs/IO buffers/_index.md
Normal file
4
docs/IO buffers/_index.md
Normal file
@ -0,0 +1,4 @@
|
||||
---
|
||||
title: "IO buffers"
|
||||
weight: 100
|
||||
---
|
||||
@ -2,8 +2,6 @@
|
||||
title: "bip_buffer_spsc_atomic"
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
{{< callout >}}
|
||||
Header: `bip_buffer_spsc_atomic.h`
|
||||
Supported: tbc
|
||||
@ -24,7 +22,7 @@ The second region covers indices N to 2N-1, but maps to the same memory as the f
|
||||
|
||||
This means any contiguous slice of up to N bytes can always be read as a single, linear pointer — no wraparound, no copying, no splitting.
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::bip_buffer_spsc_atomic<typename T,
|
||||
size_t SIZE,
|
||||
size_t MEMORY_MODEL = etl::memory_model::MEMORY_MODEL_LARGE>
|
||||
@ -47,7 +45,7 @@ Inherits from `etl::ibip_buffer_spsc_atomic<T>`.
|
||||
`MAX_SIZE` The maximum size of the circular_buffer.
|
||||
|
||||
## Constructor
|
||||
```C++
|
||||
```cpp
|
||||
etl::bip_buffer_spsc_atomic<typename T,
|
||||
size_t SIZE,
|
||||
size_t MEMORY_MODEL = etl::memory_model::MEMORY_MODEL_LARGE>();
|
||||
@ -55,7 +53,7 @@ etl::bip_buffer_spsc_atomic<typename T,
|
||||
|
||||
## Capacity
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
bool empty() const
|
||||
```
|
||||
**Description**
|
||||
@ -63,7 +61,7 @@ Returns `true` if the size of the circular buffer is zero, otherwise `false`.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
bool full() const
|
||||
```
|
||||
**Description**
|
||||
@ -71,7 +69,7 @@ Returns `true` if the size of the circular buffer is `SIZE`, otherwise `false`.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
size_t size() const
|
||||
```
|
||||
**Description**
|
||||
@ -79,7 +77,7 @@ Returns the size of the circular buffer.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
size_t max_size() const
|
||||
```
|
||||
**Description**
|
||||
@ -87,7 +85,7 @@ Returns the maximum possible size of the circular buffer.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
size_t capacity() const
|
||||
```
|
||||
**Description**
|
||||
@ -95,7 +93,7 @@ Returns the maximum possible size of the circular buffer.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
size_t available() const
|
||||
```
|
||||
**Description**
|
||||
@ -103,13 +101,13 @@ Returns the remaining available capacity in the circular buffer.
|
||||
|
||||
## Modifiers
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::span<T> read_reserve(size_type max_reserve_size = numeric_limits<size_type>::max())
|
||||
```
|
||||
**Description**
|
||||
Reserves a memory area for reading (up to the `max_reserve_size`).
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
void read_commit(const etl::span<T> &reserve)
|
||||
```
|
||||
**Description**
|
||||
@ -119,7 +117,7 @@ Throws `bip_buffer_reserve_invalid`.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::span<T> write_reserve(size_type max_reserve_size)
|
||||
```
|
||||
**Description**
|
||||
@ -127,7 +125,7 @@ Reserves a memory area for writing up to the `max_reserve_size`.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::span<T> write_reserve_optimal(size_type min_reserve_size = 1U)
|
||||
```
|
||||
**Description**
|
||||
@ -136,7 +134,7 @@ around if the available forward space is less than `min_reserve_size`.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
void write_commit(const etl::span<T> &reserve)
|
||||
```
|
||||
**Description**
|
||||
@ -146,7 +144,7 @@ Throws `bip_buffer_reserve_invalid`
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
void clear()
|
||||
```
|
||||
**Description**
|
||||
@ -1,6 +1,5 @@
|
||||
---
|
||||
title: "buffer_descriptors"
|
||||
|
||||
---
|
||||
|
||||
{{< callout >}}
|
||||
@ -10,7 +9,7 @@ title: "buffer_descriptors"
|
||||
|
||||
A set of descriptors to a collection of buffers.
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
template <typename TBuffer, // The type to store in the buffer.
|
||||
TSize BUFFER_SIZE, // The size of each buffer.
|
||||
size_t N_BUFFERS, // The total number of buffers.
|
||||
@ -39,7 +38,7 @@ For interrupts and multi-threaded code, either the flag type must force a fence
|
||||
| BUFFER_SIZE | The number of elements in each buffer |
|
||||
|
||||
## Constructors
|
||||
```C++
|
||||
```cpp
|
||||
buffer_descriptors(pointer pbuffers)
|
||||
```
|
||||
**Description**
|
||||
@ -48,7 +47,7 @@ This storage should be contiguous and large enough to hold `N_BUFFERS`.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
buffer_descriptors(pointer pbuffers, const callback_type& callback)
|
||||
```
|
||||
**Description**
|
||||
@ -56,7 +55,7 @@ Construct with a pointer to the start of the buffers to control and the callback
|
||||
|
||||
## Member functions
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
void set_callback(const callback_type& callback)
|
||||
```
|
||||
**Description**
|
||||
@ -64,7 +63,7 @@ Set the callback for notification.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
bool is_valid() const
|
||||
```
|
||||
**Description**
|
||||
@ -72,7 +71,7 @@ Returns true if class contains valid buffers.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
void notify(notification n)
|
||||
```
|
||||
**Description**
|
||||
@ -81,7 +80,7 @@ Used when the buffer has been filled and is ready for processing via the callbac
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
descriptor allocate()
|
||||
```
|
||||
**Description**
|
||||
@ -90,7 +89,7 @@ If all descriptors are in use then the descriptor will be invalid.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
descriptor allocate(value_type fill)
|
||||
```
|
||||
**Description**
|
||||
@ -99,13 +98,13 @@ If all descriptors are in use then the descriptor will be invalid.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
void clear()
|
||||
```
|
||||
**Description**
|
||||
Clears by releasing all allocated descriptors.
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
descriptor
|
||||
```
|
||||
**Description**
|
||||
@ -113,7 +112,7 @@ A nested class that encapsulates the details of an individual buffer.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
const size_type MAX_SIZE
|
||||
```
|
||||
**Description**
|
||||
@ -121,7 +120,7 @@ The maximum size of the buffer.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
descriptor()
|
||||
```
|
||||
**Description**
|
||||
@ -129,7 +128,7 @@ Default constructor.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
ETL_CONSTEXPR pointer data() const
|
||||
```
|
||||
**Description**
|
||||
@ -137,7 +136,7 @@ Returns a pointer to the start of the buffer.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
ETL_CONSTEXPR size_type max_size() const
|
||||
```
|
||||
**Description**
|
||||
@ -145,7 +144,7 @@ Returns the maximum size of the buffer.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
bool is_valid() const
|
||||
```
|
||||
**Description**
|
||||
@ -153,7 +152,7 @@ Returns true if the descriptor points to a valid buffer.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
bool is_allocated() const
|
||||
```
|
||||
**Description**
|
||||
@ -161,7 +160,7 @@ Returns true if the descriptor has been allocated.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
bool is_released() const
|
||||
```
|
||||
**Description**
|
||||
@ -169,7 +168,7 @@ Returns true if the descriptor has been released.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
void release()
|
||||
```
|
||||
**Description**
|
||||
@ -177,7 +176,7 @@ Releases the descriptor.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
notification
|
||||
```
|
||||
**Description**
|
||||
@ -185,7 +184,7 @@ A nested class that is sent to the user defined callback function.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
notification()
|
||||
```
|
||||
**Description**
|
||||
@ -194,7 +193,7 @@ Initialises to a default constructed descriptor and a count of zero.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
notification(descriptor desc, size_t count)
|
||||
```
|
||||
**Description**
|
||||
@ -202,7 +201,7 @@ Construct with the supplied parameters.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
descriptor get_descriptor() const
|
||||
```
|
||||
**Description**
|
||||
@ -210,7 +209,7 @@ Gets the descriptor.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
size_t get_count() const
|
||||
```
|
||||
**Description**
|
||||
@ -222,7 +221,7 @@ Assumes that there is a DMA driver class called DMA.
|
||||
In the real world the descriptor would be queued in the callback and handled in a foreground thread.
|
||||
The handler in the thread would release the descriptor.
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
constexpr size_t BUFFER_SIZE = 256U;
|
||||
constexpr size_t N_BUFFERS = 8U;
|
||||
|
||||
@ -6,8 +6,6 @@ weight: 1
|
||||
toc: false
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
The ETL is free for you or your company to use, including in commercial applications.
|
||||
|
||||
*However, it is not free for me to create or maintain.*
|
||||
|
||||
@ -3,8 +3,6 @@ title: "delegate"
|
||||
weight: 1
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
{{< callout type="info">}}
|
||||
Header: `delegate.h`
|
||||
Supported: `20.45.0`
|
||||
@ -13,7 +11,7 @@ weight: 1
|
||||
|
||||
A small, in-place function wrapper that stores callable objects inside a fixed-size buffer (no dynamic allocation). It supports free functions, member functions, functors, and lambdas, with both runtime and compile-time bindings.
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
template <typename TSignature,
|
||||
size_t Object_Size = ETL_DEFAULT_INPLACE_FUNCTION_SIZE,
|
||||
size_t Object_Alignment = ETL_DEFAULT_INPLACE_FUNCTION_ALIGNMENT>
|
||||
@ -22,13 +20,13 @@ class inplace_function;
|
||||
|
||||
The defaults are defined as follows:-
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
#if !defined(ETL_DEFAULT_INPLACE_FUNCTION_SIZE)
|
||||
#define ETL_DEFAULT_INPLACE_FUNCTION_SIZE 32
|
||||
#endif
|
||||
```
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
#if !defined(ETL_DEFAULT_INPLACE_FUNCTION_ALIGNMENT)
|
||||
#define ETL_DEFAULT_INPLACE_FUNCTION_ALIGNMENT alignof(void*)
|
||||
#endif
|
||||
@ -38,14 +36,14 @@ Set your own definitions if you require different defaults.
|
||||
|
||||
## Template Parameters
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
TSignature
|
||||
```
|
||||
The function signature. e.g. `int(char, float)`
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
Object_Size
|
||||
```
|
||||
Size of the internal storage buffer.
|
||||
@ -53,7 +51,7 @@ Defaults to `ETL_DEFAULT_INPLACE_FUNCTION_SIZE`.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
Object_Alignment
|
||||
```
|
||||
Alignment of the internal storage buffer.
|
||||
@ -61,14 +59,14 @@ Defaults to `ETL_DEFAULT_INPLACE_FUNCTION_ALIGNMENT`.
|
||||
|
||||
## Exceptions
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::inplace_function_exception
|
||||
```
|
||||
Base exception.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::inplace_function_uninitialized
|
||||
```
|
||||
Thrown (via `ETL_ASSERT`) when invoked without a target.
|
||||
@ -77,15 +75,15 @@ Thrown (via `ETL_ASSERT`) when invoked without a target.
|
||||
|
||||
## Member Types
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
function_type
|
||||
```
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
return_type
|
||||
```
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
argument_types
|
||||
```
|
||||
|
||||
@ -122,7 +120,7 @@ Assignment from lambda/functor.
|
||||
|
||||
## Invocation
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
operator()
|
||||
```
|
||||
**Description**
|
||||
@ -134,7 +132,7 @@ Invokes the bound callable and asserts if uninitialised.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
call_if(...)
|
||||
```
|
||||
**Description**
|
||||
@ -150,7 +148,7 @@ For non-void returns `etl::optional<TReturn>`.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
call_or(...)
|
||||
```
|
||||
**Description**
|
||||
@ -158,7 +156,7 @@ Invokes the target or a fallback callable.
|
||||
|
||||
## Observers
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
bool is_valid() const
|
||||
```
|
||||
**Returns**
|
||||
@ -166,7 +164,7 @@ Returns `true` if there is a valid callable.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
explicit operator bool() const
|
||||
```
|
||||
**Description**
|
||||
@ -178,7 +176,7 @@ Returns the result of `is_valid()`
|
||||
|
||||
## Modifiers
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
void clear()
|
||||
```
|
||||
**Description**
|
||||
@ -186,7 +184,7 @@ Clears any stored callable.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
void swap(inplace_function& other)
|
||||
```
|
||||
**Description**
|
||||
@ -196,7 +194,7 @@ Swaps with another inplace_function.
|
||||
|
||||
## Storage Introspection
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
static constexpr size_t size()
|
||||
```
|
||||
**Returns**
|
||||
@ -204,7 +202,7 @@ Returns the size of the internal storage.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
static constexpr size_t alignment()
|
||||
```
|
||||
**Returns**
|
||||
@ -214,7 +212,7 @@ Returns the alignment of the internal storage.
|
||||
|
||||
### Free function
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
template <TReturn(*Function)(TArgs...)>
|
||||
void set()
|
||||
```
|
||||
@ -222,7 +220,7 @@ Sets the callable to `Function`.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
template <TReturn(*Function)(TArgs...)>
|
||||
inplace_function<TReturn(TArgs...),
|
||||
Object_Size,
|
||||
@ -233,7 +231,7 @@ Creates an `etl::inplace_function` using `Function`.
|
||||
|
||||
### Member function + instance (external linkage)
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
template <typename TObject, TReturn(TObject::*Method)(TArgs...), TObject& Instance>
|
||||
set<TObject, &TMethod, Instance>()
|
||||
```
|
||||
@ -242,53 +240,53 @@ Sets the callable to the member function `Method` for the object `Instance`.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
create<TObject, &TMethod, Instance>()
|
||||
```
|
||||
**Description**
|
||||
|
||||
### Callable object + instance (operator())
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
set<T, Instance>()
|
||||
```
|
||||
**Description**
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
create<T, Instance>()
|
||||
```
|
||||
**Description**
|
||||
|
||||
## Helper Aliases
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::inplace_function_for<TSignature, TStorage>
|
||||
```
|
||||
**Description**
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::inplace_function_for_any<TSignature, T0, ...>
|
||||
```
|
||||
**Description**
|
||||
|
||||
## Helper Factories
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
make_inplace_function(function_ptr)
|
||||
```
|
||||
**Description**
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
make_inplace_function(obj, &Type::Method)
|
||||
```
|
||||
**Description**
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
make_inplace_function(lambda_or_functor)
|
||||
```
|
||||
**Description**
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
make_inplace_function<TSignature>(function_like)
|
||||
```
|
||||
**Description**
|
||||
@ -297,7 +295,7 @@ C++17-only overloads also exist for compile-time binding.
|
||||
|
||||
## Example
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
#include "etl/inplace_function.h"
|
||||
|
||||
int add(int a, int b) { return a + b; }
|
||||
|
||||
@ -3,8 +3,6 @@ title: "inplace_function"
|
||||
weight: 1
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
{{< callout type="info">}}
|
||||
Header: `inplace_function.h`
|
||||
Supported: `20.45.0`
|
||||
@ -13,7 +11,7 @@ weight: 1
|
||||
|
||||
A small, in-place function wrapper that stores callable objects inside a fixed-size buffer (no dynamic allocation). It supports free functions, member functions, functors, and lambdas, with both runtime and compile-time bindings.
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
template <typename TSignature,
|
||||
size_t Object_Size = ETL_DEFAULT_INPLACE_FUNCTION_SIZE,
|
||||
size_t Object_Alignment = ETL_DEFAULT_INPLACE_FUNCTION_ALIGNMENT>
|
||||
@ -22,13 +20,13 @@ class inplace_function;
|
||||
|
||||
The defaults are defined as follows:-
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
#if !defined(ETL_DEFAULT_INPLACE_FUNCTION_SIZE)
|
||||
#define ETL_DEFAULT_INPLACE_FUNCTION_SIZE 32
|
||||
#endif
|
||||
```
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
#if !defined(ETL_DEFAULT_INPLACE_FUNCTION_ALIGNMENT)
|
||||
#define ETL_DEFAULT_INPLACE_FUNCTION_ALIGNMENT alignof(void*)
|
||||
#endif
|
||||
@ -38,7 +36,7 @@ Set your own definitions if you require different defaults.
|
||||
|
||||
## Template Parameters
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
TSignature
|
||||
```
|
||||
**Description**
|
||||
@ -46,7 +44,7 @@ The function signature. e.g. `int(char, float)`
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
Object_Size
|
||||
```
|
||||
**Description**
|
||||
@ -55,7 +53,7 @@ Defaults to `ETL_DEFAULT_INPLACE_FUNCTION_SIZE`.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
Object_Alignment
|
||||
```
|
||||
**Description**
|
||||
@ -64,7 +62,7 @@ Defaults to `ETL_DEFAULT_INPLACE_FUNCTION_ALIGNMENT`.
|
||||
|
||||
## Exceptions
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::inplace_function_exception
|
||||
```
|
||||
**Description**
|
||||
@ -72,7 +70,7 @@ Base exception.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::inplace_function_uninitialized
|
||||
```
|
||||
**Description**
|
||||
@ -80,21 +78,21 @@ Thrown (via `ETL_ASSERT`) when invoked without a target.
|
||||
|
||||
## Member Types
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
function_type
|
||||
```
|
||||
**Description**
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
return_type
|
||||
```
|
||||
**Description**
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
argument_types
|
||||
```
|
||||
**Description**
|
||||
@ -138,7 +136,7 @@ Assignment from lambda/functor.
|
||||
|
||||
## Invocation
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
operator()
|
||||
```
|
||||
**Description**
|
||||
@ -150,7 +148,7 @@ Invokes the bound callable and asserts if uninitialised.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
call_if(...)
|
||||
```
|
||||
**Description**
|
||||
@ -166,7 +164,7 @@ For non-void returns `etl::optional<TReturn>`.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
call_or(...)
|
||||
```
|
||||
**Description**
|
||||
@ -178,7 +176,7 @@ Invokes the target or a fallback callable.
|
||||
|
||||
## Observers
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
bool is_valid() const
|
||||
```
|
||||
**Returns**
|
||||
@ -186,7 +184,7 @@ bool is_valid() const
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
explicit operator bool() const
|
||||
```
|
||||
**Description**
|
||||
@ -198,7 +196,7 @@ The result of `is_valid()`
|
||||
|
||||
## Modifiers
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
void clear()
|
||||
```
|
||||
**Description**
|
||||
@ -212,7 +210,7 @@ None
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
void swap(inplace_function& other)
|
||||
```
|
||||
**Description**
|
||||
@ -227,7 +225,7 @@ None
|
||||
|
||||
## Storage Introspection
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
static constexpr size_t size()
|
||||
```
|
||||
**Description**
|
||||
@ -241,7 +239,7 @@ The size of the internal storage.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
static constexpr size_t alignment()
|
||||
```
|
||||
**Description**
|
||||
@ -257,7 +255,7 @@ The alignment of the internal storage.
|
||||
|
||||
### Free function
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
template <TReturn(*Function)(TArgs...)>
|
||||
void set()
|
||||
```
|
||||
@ -265,7 +263,7 @@ Sets the callable to `Function`.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
template <TReturn(*Function)(TArgs...)>
|
||||
inplace_function<TReturn(TArgs...),
|
||||
Object_Size,
|
||||
@ -276,7 +274,7 @@ Creates an `etl::inplace_function` using `Function`.
|
||||
|
||||
### Member function + instance (external linkage)
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
template <typename TObject, TReturn(TObject::*Method)(TArgs...), TObject& Instance>
|
||||
set<TObject, &TMethod, Instance>()
|
||||
```
|
||||
@ -285,7 +283,7 @@ Sets the callable to the member function `Method` for the object `Instance`.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
create<TObject, &TMethod, Instance>()
|
||||
```
|
||||
**Description**
|
||||
@ -296,7 +294,7 @@ create<TObject, &TMethod, Instance>()
|
||||
|
||||
### Callable object + instance (operator())
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
set<T, Instance>()
|
||||
```
|
||||
**Description**
|
||||
@ -305,7 +303,7 @@ set<T, Instance>()
|
||||
|
||||
**Returns**
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
create<T, Instance>()
|
||||
```
|
||||
**Description**
|
||||
@ -316,7 +314,7 @@ create<T, Instance>()
|
||||
|
||||
## Helper Aliases
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::inplace_function_for<TSignature, TStorage>
|
||||
```
|
||||
**Description**
|
||||
@ -327,7 +325,7 @@ etl::inplace_function_for<TSignature, TStorage>
|
||||
|
||||
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::inplace_function_for_any<TSignature, T0, ...>
|
||||
```
|
||||
**Description**
|
||||
@ -338,7 +336,7 @@ etl::inplace_function_for_any<TSignature, T0, ...>
|
||||
|
||||
## Helper Factories
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
make_inplace_function(function_ptr)
|
||||
```
|
||||
**Description**
|
||||
@ -347,7 +345,7 @@ make_inplace_function(function_ptr)
|
||||
|
||||
**Returns**
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
make_inplace_function(obj, &Type::Method)
|
||||
```
|
||||
**Description**
|
||||
@ -356,12 +354,12 @@ make_inplace_function(obj, &Type::Method)
|
||||
|
||||
**Returns**
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
make_inplace_function(lambda_or_functor)
|
||||
```
|
||||
**Description**
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
make_inplace_function<TSignature>(function_like)
|
||||
```
|
||||
**Description**
|
||||
@ -374,7 +372,7 @@ C++17-only overloads also exist for compile-time binding.
|
||||
|
||||
## Example
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
#include "etl/inplace_function.h"
|
||||
|
||||
int add(int a, int b) { return a + b; }
|
||||
|
||||
@ -3,8 +3,6 @@ title: Manchester encoding and decoding
|
||||
weight: 1
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
{{< callout type="info">}}
|
||||
Header: `manchester.h`
|
||||
Support: `20.45.0`
|
||||
|
||||
@ -4,16 +4,22 @@ weight: 100
|
||||
---
|
||||
|
||||
## Containers
|
||||
The library defines a set of containers that have been specially tailored for embedded systems.They have a maximum capacity fixed at compile time and make no calls to malloc/free or new/delete.They are completely deterministic.
|
||||
Most container types have been designed to mimic, as far as possible, those found in the STL. Some do not havedirect STL equivalents.
|
||||
The library defines a set of containers that have been specially tailored for embedded systems.They have a maximum capacity fixed at compile time and make no calls to `malloc`/`free` or `new`/`delete`. They are completely deterministic.
|
||||
|
||||
As the storage for all of the container types is allocated as a contiguous block, they are extremely cache friendly.
|
||||
Note: Unlike the STL, the ETL's vector<bool> really is a container and actually does contains bool.
|
||||
Most container types have been designed to mimic, as far as possible, those found in the STL. Some do not have direct STL equivalents.
|
||||
|
||||
If you require a compact Boolean container then etl::bitset may be more appropriate.
|
||||
Intrusive containersThere are intrusive versions of certain containers. These do not store copies of the inserted values, but link to theoriginal objects. Certain types of intrusive container require that the stored object derives from an intrusive link.
|
||||
As the storage for all of the container types is allocated as a contiguous block, they are extremely cache friendly.
|
||||
|
||||
**Note:**
|
||||
Unlike the STL, the ETL's `vector<bool>` really *is* a container and actually *does* contains `bool`.
|
||||
If you require a compact Boolean container then `etl::bitset` may be more appropriate.
|
||||
|
||||
## Intrusive containers
|
||||
There are intrusive versions of certain containers. These do not store copies of the inserted values, but link to the original objects. Certain types of intrusive container require that the stored object derives from an intrusive link.
|
||||
|
||||
Most intrusive containers do not have a maximum fixed capacity.
|
||||
See here for more information.
|
||||
|
||||
Most intrusive containers do not have a maximum fixed capacity.See here for more information.
|
||||
To eliminate code bloat, most container templates utilise 'hoisting' where functionality, independent of the sizeand/or type, is separated out in to base classes.
|
||||
|
||||
For example, `vector<int, 5>` and `vector<int, 10>` will share code from `ivector<int>`.
|
||||
@ -21,7 +27,7 @@ For example, `vector<int, 5>` and `vector<int, 10>` will share code from `ivecto
|
||||
|
||||
The `i` prefixed container types may be used as size independent pointer or reference types for all sizes of thederived type.
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::vector<int, 5> vector1;
|
||||
etl::vector<int, 10> vector2;
|
||||
|
||||
@ -46,15 +52,14 @@ The following containers support rvalue references and move semantics.
|
||||
*This list may be out of date*.
|
||||
|
||||
## Differences from the STL containers
|
||||
As the containers have a fixed capacity, most also implement full() and available() member functions.
|
||||
As the containers have a fixed capacity, most also implement `full()` and `available()` member functions.
|
||||
|
||||
Most of the containers allocate their storage from an internal instance of `etl::pool`.
|
||||
Because of this the containers have a certain set of attributes that differ from the standard library.
|
||||
- The storage for all containers is contiguous, thereby enhancing cache hits.
|
||||
- No heap memory is used; no OS or user supplied memory management is required.
|
||||
- Non-static containers declared locally within functions will store their contents on the stack.
|
||||
- Copying or swapping a container is not a low cost action, as all of the contents will be copied
|
||||
(except for externally buffered vectors which will use a simple pointer copy).
|
||||
- Copying or swapping a container is not a low cost action, as all of the contents will be copied.
|
||||
|
||||
## Notes
|
||||
Although the containers utilise inheritance, like the STL containers, they are not intended to be used
|
||||
|
||||
6
docs/containers/arrays/_index.md
Normal file
6
docs/containers/arrays/_index.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
title: "Arrays"
|
||||
weight: 100
|
||||
---
|
||||
|
||||
Array like containers.
|
||||
@ -3,8 +3,6 @@ title: "array"
|
||||
weight: 1
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
{{< callout >}}
|
||||
Header: `array.h`
|
||||
Supported: All versions
|
||||
@ -14,7 +12,7 @@ weight: 1
|
||||
A fixed capacity array.
|
||||
Adds additional members functions, `assign`, `insert` & `erase`.
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::array<typename T, const size_t SIZE>
|
||||
```
|
||||
|
||||
@ -24,13 +22,13 @@ See also
|
||||
## Template deduction guides
|
||||
**C++17 and above**
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
template <typename... T>
|
||||
etl::array(T...)
|
||||
```
|
||||
|
||||
### Example
|
||||
```C++
|
||||
```cpp
|
||||
etl::array data{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
```
|
||||
Defines data as an array of 'int', of length '10', containing the supplied data.
|
||||
@ -38,13 +36,13 @@ Defines data as an array of 'int', of length '10', containing the supplied data.
|
||||
## Make template
|
||||
**C++11 and above**
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
template <typename T, typename... TValues>
|
||||
constexpr auto make_array(TValues&&... values)
|
||||
```
|
||||
|
||||
### Example
|
||||
```C++
|
||||
```cpp
|
||||
auto data = etl::make_array<int>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
|
||||
```
|
||||
|
||||
@ -66,7 +64,7 @@ auto data = etl::make_array<int>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
|
||||
|
||||
## Static Constants
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
SIZE
|
||||
```
|
||||
**Description**
|
||||
@ -74,7 +72,7 @@ The size of the array.
|
||||
|
||||
## Constructor
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::array<int, 10> data = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
```
|
||||
**Description**
|
||||
@ -82,7 +80,7 @@ Default or copy constructs each element.
|
||||
Can be initialised like a C array.
|
||||
|
||||
## Element access
|
||||
```C++
|
||||
```cpp
|
||||
T& at(size_t i)
|
||||
const T& at(size_t i) const
|
||||
```
|
||||
@ -92,7 +90,7 @@ If asserts or exceptions are not enabled then an out of range index results in u
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
T& operator[](size_t i)
|
||||
const T& operator[](size_t i) const
|
||||
```
|
||||
@ -102,7 +100,7 @@ An out of range index results in undefined behaviour.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
T& front()
|
||||
const T& front() const
|
||||
```
|
||||
@ -111,7 +109,7 @@ Returns a reference or const reference to the first element.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
T& back()
|
||||
const T& back() const
|
||||
```
|
||||
@ -120,7 +118,7 @@ Returns a reference or const reference to the last element.
|
||||
|
||||
## Iterators
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
iterator begin()
|
||||
const_iterator begin() const
|
||||
const_iterator cbegin() const
|
||||
@ -130,7 +128,7 @@ Returns an iterator to the beginning of the array.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
iterator end()
|
||||
const_iterator end() const
|
||||
const_iterator cend() const
|
||||
@ -140,7 +138,7 @@ Returns an iterator to the end of the array.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
iterator rbegin()
|
||||
const_iterator rbegin() const
|
||||
const_iterator crbegin() const
|
||||
@ -150,7 +148,7 @@ Returns a reverse iterator to the beginning of the array.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
iterator rend()
|
||||
const_iterator rend() const
|
||||
const_iterator crend() const
|
||||
@ -160,7 +158,7 @@ Returns a reverse iterator to the end of the array.
|
||||
|
||||
## Capacity
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
bool empty() const
|
||||
```
|
||||
**Description**
|
||||
@ -168,7 +166,7 @@ Returns true if the size of the array is zero, otherwise false.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
size_t size() const
|
||||
```
|
||||
**Description**
|
||||
@ -176,7 +174,7 @@ Returns the size of the array.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
size_t max_size() const
|
||||
```
|
||||
**Description**
|
||||
@ -184,7 +182,7 @@ Returns the maximum possible size of the array.
|
||||
|
||||
## Modifiers
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
void fill(T value)
|
||||
```
|
||||
**Description**
|
||||
@ -192,12 +190,12 @@ Fills the array with value.
|
||||
|
||||
## ETL Extensions
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
template <typename TIterator>
|
||||
void assign(TIterator first, const TIterator last)
|
||||
```
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
template <typename TIterator>
|
||||
void assign(TIterator first, const TIterator last, parameter_t value)
|
||||
```
|
||||
@ -209,7 +207,7 @@ If the range is smaller than the array then the unused array elements are left u
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
iterator insert_at(size_t position, parameter_t value)
|
||||
iterator insert(const_iterator position, parameter_t value)
|
||||
```
|
||||
@ -220,7 +218,7 @@ Elements may be truncated if they are shifted off the end of the array.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
template <typename TIterator>
|
||||
iterator insert_at(size_t position, TIterator first, const TIterator last)
|
||||
```
|
||||
@ -230,7 +228,7 @@ iterator insert_at(size_t position, TIterator first, const TIterator last)
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
template <typename TIterator>
|
||||
iterator insert(const_iterator position, TIterator first, const TIterator last)
|
||||
```
|
||||
@ -242,7 +240,7 @@ The range may be larger than the capacity of the array. Excess elements will be
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
iterator erase_at(size_t position)
|
||||
iterator erase_at(size_t position, parameter_t value)
|
||||
iterator erase(const_iterator position)
|
||||
@ -256,7 +254,7 @@ position is not checked for valid range.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
iterator erase_range(size_t first, size_t last)
|
||||
iterator erase_range(size_t first, size_t last, parameter_t value)
|
||||
iterator erase(const_iterator first, const_iterator last)
|
||||
@ -2,8 +2,6 @@
|
||||
title: "array_view"
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
{{< callout >}}
|
||||
Header: `array_view.h`
|
||||
Supported: All versions
|
||||
@ -16,23 +14,23 @@ It will support construction from any class that supports data() and size() memb
|
||||
If `ETL_ARRAY_VIEW_IS_MUTABLE` is defined, then the contents of the view are mutable.
|
||||
The view is non-mutable by default, which is the opposite to the behaviour in 17.5.0 or earlier.
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::array_view<typename T>
|
||||
```
|
||||
|
||||
## Template deduction guides
|
||||
**C++17 and above**
|
||||
```C++
|
||||
```cpp
|
||||
template <typename TArray>
|
||||
etl::array_view(TArray& a)
|
||||
-> etl::array_view<typename TArray::value_type>;
|
||||
```
|
||||
```C++
|
||||
```cpp
|
||||
template <typename TIterator>
|
||||
etl::array_view(const TIterator begin_, const TIterator end_)
|
||||
-> etl::array_view<etl::remove_pointer_t<TIterator>>;
|
||||
```
|
||||
```C++
|
||||
```cpp
|
||||
template <typename TIterator, typename TSize>
|
||||
etl::array_view(const TIterator begin_, const TSize size_)
|
||||
-> etl::array_view<etl::remove_pointer_t<TIterator>>;
|
||||
@ -40,7 +38,7 @@ etl::array_view(const TIterator begin_, const TSize size_)
|
||||
|
||||
## Examples
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::array data{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||
|
||||
etl::array_view view1{ data };
|
||||
@ -64,7 +62,7 @@ etl::array_view view4{ view1 };
|
||||
|
||||
## Constructors
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
ETL_CONSTEXPR array_view()
|
||||
```
|
||||
**Description**
|
||||
@ -72,7 +70,7 @@ Default constructor.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
template <typename TArray>
|
||||
ETL_CONSTEXPR explicit array_view(TArray& a)
|
||||
```
|
||||
@ -81,7 +79,7 @@ Construct from array or vector like class.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
template <typename TIterator>
|
||||
ETL_CONSTEXPR array_view(TIterator begin_, TIterator end_)
|
||||
```
|
||||
@ -90,7 +88,7 @@ Construct from an iterator or pointer range.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
template <typename TIterator, typename TSize>
|
||||
ETL_CONSTEXPR array_view(TIterator begin_, TSize size_)
|
||||
```
|
||||
@ -99,7 +97,7 @@ Construct from a start and size
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
template<const size_t ARRAY_SIZE>
|
||||
ETL_CONSTEXPR explicit array_view(T(&begin_)[ARRAY_SIZE])
|
||||
```
|
||||
@ -108,7 +106,7 @@ Construct from a compile time sized C array.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
ETL_CONSTEXPR array_view(const array_view& other)
|
||||
```
|
||||
**Description**
|
||||
@ -116,7 +114,7 @@ Copy constructor.
|
||||
|
||||
## Modifiers
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
template <typename TIterator>
|
||||
void assign(TIterator begin_, TIterator end_)
|
||||
```
|
||||
@ -126,7 +124,7 @@ Does not copy the elements in the range.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
template <typename TIterator, typename TSize>
|
||||
void assign(TIterator begin_, TSize size_)
|
||||
```
|
||||
@ -136,7 +134,7 @@ Does not copy the elements in the range.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
void remove_prefix(size_type n)
|
||||
```
|
||||
**Description**
|
||||
@ -145,7 +143,7 @@ A value of `n` larger than the array will result in undefined behaviour.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
void remove_suffix(size_type n)
|
||||
```
|
||||
**Description**
|
||||
@ -153,7 +151,7 @@ Shrinks the view from the back.
|
||||
A value of `n` larger than the array will result in undefined behaviour.
|
||||
|
||||
---
|
||||
```C++
|
||||
```cpp
|
||||
void fill(value_type value)
|
||||
```
|
||||
*Introduced:* `20.24.0`
|
||||
@ -166,7 +164,7 @@ Fill the underlying array with value.
|
||||
Mutable access is only possible by defining the macro `ETL_ARRAY_VIEW_IS_MUTABLE`.
|
||||
In this case, `reference`, `pointer`, `iterator` and `reverse_iterator` are defined as their `const` counterparts.
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
reference at(size_t i)
|
||||
const_reference at(size_t i) const
|
||||
```
|
||||
@ -184,7 +182,7 @@ A reference or const reference to the indexed element
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
reference operator[](size_t i)
|
||||
const_reference operator[](size_t i) const
|
||||
```
|
||||
@ -197,7 +195,7 @@ Undefined behaviour if the `array_view` is empty.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
reference front()
|
||||
const_reference front() const
|
||||
```
|
||||
@ -210,7 +208,7 @@ Undefined behaviour if the `array_view` is empty.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
reference back()
|
||||
const_reference back() const
|
||||
```
|
||||
@ -223,7 +221,7 @@ Undefined behaviour if the `array_view` is empty.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
pointer data()
|
||||
const_pointer data() const
|
||||
```
|
||||
@ -235,7 +233,7 @@ A pointer or const pointer to the first element.
|
||||
Equal to `end()` if the array_view is empty.
|
||||
|
||||
## Iterators
|
||||
```C++
|
||||
```cpp
|
||||
iterator begin()
|
||||
const_iterator begin() const
|
||||
const_iterator cbegin() const
|
||||
@ -245,7 +243,7 @@ Returns an iterator to the beginning of the array view.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
iterator end()
|
||||
const_iterator end() const
|
||||
const_iterator cend() const
|
||||
@ -255,7 +253,7 @@ Returns an iterator to the end of the array view.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
iterator rbegin()
|
||||
const_iterator rbegin() const
|
||||
const_iterator crbegin() const
|
||||
@ -265,7 +263,7 @@ Gets a reverse iterator to the beginning of the array view.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
iterator rend()
|
||||
const_iterator rend() const
|
||||
const_iterator crend() const
|
||||
@ -277,7 +275,7 @@ Gets a reverse iterator to the end of the array view.
|
||||
|
||||
Capacity
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
bool empty() const
|
||||
```
|
||||
**Description**
|
||||
@ -285,7 +283,7 @@ Returns true if the size of the array view is zero, otherwise false.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
size_t size() const
|
||||
```
|
||||
**Description**
|
||||
@ -338,7 +336,7 @@ contents of the rhs, otherwise `false`.
|
||||
There are specialisations of `etl::hash` for `array_view`.
|
||||
|
||||
## Example
|
||||
```C++
|
||||
```cpp
|
||||
etl::array<int, 10> data = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
||||
|
||||
typedef etl::array_view<int> View;
|
||||
@ -2,8 +2,6 @@
|
||||
title: "array_wrapper"
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
{{< callout >}}
|
||||
Header: `array_wrapper.h`
|
||||
Supported: All versions
|
||||
@ -44,10 +42,10 @@ If C++11 or above is supported then most functions can be 'constexpr'.
|
||||
`REND = -1`
|
||||
|
||||
## Element access
|
||||
```C++
|
||||
```cpp
|
||||
T& at(size_t i)
|
||||
```
|
||||
```C++
|
||||
```cpp
|
||||
ETL_CONSTEXPR const T& at(size_t i) const
|
||||
```
|
||||
**Description**
|
||||
@ -56,10 +54,10 @@ Emits an `etl::array_wrapper_bounds` if the index isout of range of the array.
|
||||
If asserts or exceptions are not enabled then undefined behaviour occurs.
|
||||
|
||||
---
|
||||
```C++
|
||||
```cpp
|
||||
T& operator[](size_t i)
|
||||
```
|
||||
```C++
|
||||
```cpp
|
||||
ETL_CONSTEXPR const T& operator[](size_t i) const
|
||||
```
|
||||
**Description**
|
||||
@ -67,10 +65,10 @@ Returns a reference or const reference to the indexed element.if the index is ou
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
T& front()
|
||||
```
|
||||
```C++
|
||||
```cpp
|
||||
ETL_CONSTEXPR const T& front() const
|
||||
```
|
||||
**Description**
|
||||
@ -78,10 +76,10 @@ Returns a reference or const reference to the first element.---
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
T& back()
|
||||
```
|
||||
```C++
|
||||
```cpp
|
||||
ETL_CONSTEXPR const T& back() const
|
||||
```
|
||||
**Description**
|
||||
@ -89,17 +87,17 @@ Returns a reference or const reference to the last element.---
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
T* data()
|
||||
```
|
||||
```C++
|
||||
```cpp
|
||||
ETL_CONSTEXPR const T* data() const
|
||||
```
|
||||
**Description**
|
||||
Returns a pointer or const pointer to the array.---Modifiers
|
||||
|
||||
---
|
||||
```C++
|
||||
```cpp
|
||||
void fill(parameter_t value)
|
||||
```
|
||||
**Description**
|
||||
@ -107,7 +105,7 @@ Fill a non-cost array with the value.---
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
template <typename T, T(&ARRAYOTHER)[SIZE_]>
|
||||
void swap(etl::array_wrapper<T, SIZE_, ARRAYOTHER>& other)
|
||||
```
|
||||
@ -116,10 +114,10 @@ Swaps the array contents with another.---Iterators
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
ETL_CONSTEXPR iterator begin()
|
||||
```
|
||||
```C++
|
||||
```cpp
|
||||
ETL_CONSTEXPR const_iterator begin() constETL_CONSTEXPR const_iterator cbegin() const
|
||||
```
|
||||
**Description**
|
||||
@ -127,10 +125,10 @@ Returns an iterator to the beginning of the array.---
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
ETL_CONSTEXPR iterator end()
|
||||
```
|
||||
```C++
|
||||
```cpp
|
||||
ETL_CONSTEXPR const_iterator end() constETL_CONSTEXPR const_iterator cend() const
|
||||
```
|
||||
**Description**
|
||||
@ -138,13 +136,13 @@ Returns an iterator to the end of the array.---
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
ETL_CONSTEXPR iterator rbegin()
|
||||
```
|
||||
```C++
|
||||
```cpp
|
||||
ETL_CONSTEXPR const_reverse_iterator rbegin() const
|
||||
```
|
||||
```C++
|
||||
```cpp
|
||||
ETL_CONSTEXPR const_reverse_iterator crbegin() const
|
||||
```
|
||||
**Description**
|
||||
@ -152,10 +150,10 @@ Returns a reverse iterator to the beginning of the array.---
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
ETL_CONSTEXPR iterator rend()
|
||||
```
|
||||
```C++
|
||||
```cpp
|
||||
ETL_CONSTEXPR const_reverse_iterator rend() constETL_CONSTEXPR const_reverse_iterator crend() const
|
||||
```
|
||||
**Description**
|
||||
@ -163,7 +161,7 @@ Returns a reverse iterator to the end of the array.---Capacity
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
ETL_CONSTEXPR size_t size() const
|
||||
```
|
||||
**Description**
|
||||
@ -171,7 +169,7 @@ Returns the size of the view.---
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
ETL_CONSTEXPR size_t max_size() const
|
||||
```
|
||||
**Description**
|
||||
@ -208,7 +206,7 @@ contents of the rhs, otherwise `false`.
|
||||
contents of the rhs, otherwise `false`
|
||||
|
||||
## Swap
|
||||
```C++
|
||||
```cpp
|
||||
template <typename T, std::size_t SIZE, T(&ARRAYL)[SIZE], T(&ARRAYR)[SIZE]>
|
||||
void swap(etl::array_wrapper<T, SIZE, ARRAYL>& lhs,
|
||||
etl::array_wrapper<T, SIZE, ARRAYR>& rhs)
|
||||
@ -222,13 +220,13 @@ There is a specialisation for `etl::hash` for `array_wrapper`.
|
||||
## Macros
|
||||
A macro is defined to ease the use of the class.
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
ETL_ARRAY_WRAPPER(type, array);
|
||||
```
|
||||
|
||||
**Example**
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
// The address of the array MUST be deducible at compile time.
|
||||
int cdata = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
||||
|
||||
@ -2,8 +2,6 @@
|
||||
title: "bitset"
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
{{< callout >}}
|
||||
Header: `bitset.h`
|
||||
Supported: 20.33.0
|
||||
@ -17,13 +15,13 @@ A fixed capacity bitset.
|
||||
Has a number of extensions over std::bitset. Can be considered similar to an array of bool.
|
||||
|
||||
Internally defined buffers
|
||||
```C++
|
||||
```cpp
|
||||
etl::bitset<size_t N>
|
||||
etl::bitset<size_t N, typename TElement>
|
||||
```
|
||||
|
||||
Externally defined buffers from `20.34.0`
|
||||
```C++
|
||||
```cpp
|
||||
etl::bitset_ext<size_t N>
|
||||
etl::bitset_ext<size_t N, typename TElement>
|
||||
```
|
||||
@ -39,10 +37,10 @@ Note: `etl::ibitset` is no longer a reference type for any size `etl::bitset`.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::bitset<size_t N, typename TElement>
|
||||
```
|
||||
```C++
|
||||
```cpp
|
||||
etl::bitset_ext<size_t N, typename TElement>
|
||||
```
|
||||
Specifying a type for `TElement` will override the default element type and define it as the *unsigned* type of `TElement`.
|
||||
@ -52,7 +50,7 @@ Specifying a type for `TElement` will override the default element type and defi
|
||||
There are specialisations for when the required number of bits matches the number of bits in the element type.
|
||||
These specialisations are considerably faster and more efficient.
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::bitset<8, uint8_t>
|
||||
etl::bitset<16, uint16_t>
|
||||
etl::bitset<32, uint32_t>
|
||||
@ -61,7 +59,7 @@ etl::bitset<8, uint64_t>
|
||||
|
||||
`any()`, `none()` and `all()` are overloaded in these specialisations to allow a mask to be specified, so that a bitset that requires less bits than the element type may still use the most efficient implementation.
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::bitset<8, uint8_t> bst; // But only want to use 6 bits.
|
||||
bool any = bst.any(0x3F); // Check the lower 6 bits.
|
||||
```
|
||||
@ -78,13 +76,13 @@ bool any = bst.any(0x3F); // Check the lower 6 bits.
|
||||
## Constants
|
||||
|
||||
All `npos` values are equivalent.
|
||||
```C++
|
||||
```cpp
|
||||
etl::bitset_constants::npos
|
||||
```
|
||||
```C++
|
||||
```cpp
|
||||
etl::bitset<>::npos
|
||||
```
|
||||
```C++
|
||||
```cpp
|
||||
template <size_t Size, typename TElement>
|
||||
etl::bitset<Size, TElement>::npos
|
||||
```
|
||||
@ -101,7 +99,7 @@ From: 20.38.11
|
||||
|
||||
The initial state of the bitset is all clear (`false`).
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::bitset();
|
||||
etl::bitset(unsigned long value);
|
||||
etl::bitset(const char* str);
|
||||
@ -114,7 +112,7 @@ The bitset is either default constructed, initialised with a numeric value, or a
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::bitset_ext(element_type* pbuffer);
|
||||
etl::bitset_ext(unsigned long value, element_type* pbuffer);
|
||||
etl::bitset_ext(const char* str, element_type* pbuffer);
|
||||
@ -126,7 +124,7 @@ etl::bitset_ext(const char32_t* str, element_type* pbuffer);
|
||||
The bitset is either default constructed, initialised with a numeric value, or a text string of zeros and ones.
|
||||
A pointer to the external must b supplied that is large enough to hold the bitset.
|
||||
The buffer may be defined as follows:-
|
||||
```C++
|
||||
```cpp
|
||||
using Bitset = etl::bitset_ext<32>;
|
||||
|
||||
Bitset::element_type buffer[Bitset::Number_Of_Elements];
|
||||
@ -135,7 +133,7 @@ From: 20.34.0
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::bitset_ext(buffer_type& buffer);
|
||||
etl::bitset_ext(unsigned long value, buffer_type& buffer);
|
||||
etl::bitset_ext(const char* str, buffer_type& buffer);
|
||||
@ -147,7 +145,7 @@ etl::bitset_ext(const char32_t* str, buffer_type& buffer);
|
||||
The bitset is either default constructed, initialised with a numeric value, or a text string of zeros and ones.
|
||||
A n external must b supplied that is large enough to hold the bitset.
|
||||
The buffer may be defined as follows:-
|
||||
```C++
|
||||
```cpp
|
||||
using Bitset = etl::bitset_ext<32>;
|
||||
|
||||
Bitset::buffer_type buffer;
|
||||
@ -156,7 +154,7 @@ From: 20.34.0
|
||||
|
||||
## Modifiers
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::bitset& set();
|
||||
```
|
||||
**Description**
|
||||
@ -164,7 +162,7 @@ Set all bits.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::bitset& set(element_type value);
|
||||
```
|
||||
**Description**
|
||||
@ -174,7 +172,7 @@ Valid when the bitset width matches the element type width.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::bitset& set(const char* str);
|
||||
etl::bitset& set(const wchar_t* str);
|
||||
etl::bitset& set(const char16_t* str);
|
||||
@ -185,7 +183,7 @@ Set with a text string of `0` and `1` characters.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::bitset& set(size_t position, bool value = true);
|
||||
```
|
||||
**Description**
|
||||
@ -193,7 +191,7 @@ Set a position to a one or zero, default one.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::bitset& reset();
|
||||
```
|
||||
**Description**
|
||||
@ -201,7 +199,7 @@ Reset all bits.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::bitset& reset(size_t position);
|
||||
```
|
||||
**Description**
|
||||
@ -209,7 +207,7 @@ Set a position to a zero.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::bitset& from_string(const char*);
|
||||
etl::bitset& from_string(const wchar_t*);
|
||||
etl::bitset& from_string(const char16_t*);
|
||||
@ -221,7 +219,7 @@ The bitset is built from a string of `0` and `1` characters.
|
||||
|
||||
## Access
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
template <typename T>
|
||||
T value() const
|
||||
```
|
||||
@ -231,7 +229,7 @@ Returns the value corresponding to the bitset.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
unsigned long to_ulong() const
|
||||
unsigned long long to_ullong() const
|
||||
```
|
||||
@ -243,7 +241,7 @@ If the type is too small to contain the bitset size, a compile time error will r
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
template <typename TString>
|
||||
TString to_string(typename TString::value_type zero = typename TString::value_type('0'),
|
||||
typename TString::value_type one = typename TString::value_type('1')) const
|
||||
@ -253,7 +251,7 @@ If the string type is not large enough to contain the digits then an `etl::bitse
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
span_type span()
|
||||
const_span_type span() const
|
||||
```
|
||||
@ -263,7 +261,7 @@ The span is ordered LSB to MSB.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
template <typename T>
|
||||
ETL_CONSTEXPR14
|
||||
T extract(size_t position, size_t length = etl::integral_limits<T>::bits) const
|
||||
@ -274,7 +272,7 @@ Run time position and length.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
template <typename T, size_t Position, size_t Length = etl::integral_limits<T>::bits>
|
||||
ETL_CONSTEXPR14
|
||||
T extract() const
|
||||
@ -287,7 +285,7 @@ For C++11 and above
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
template <typename T, size_t Position, size_t Length>
|
||||
T extract() const
|
||||
```
|
||||
@ -299,7 +297,7 @@ For C++98/03
|
||||
|
||||
## Bit access
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
bool operator[](size_t position) const
|
||||
```
|
||||
**Description**
|
||||
@ -308,7 +306,7 @@ position is not checked for validity.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
size_t count() const
|
||||
```
|
||||
**Description**
|
||||
@ -316,7 +314,7 @@ Returns the number of set bits.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
size_t size() const
|
||||
```
|
||||
**Description**
|
||||
@ -324,7 +322,7 @@ Returns the number of bits supported by this bitset.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
bool test(size_t position) const
|
||||
```
|
||||
**Description**
|
||||
@ -333,13 +331,13 @@ position is not checked for validity.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
bool any() const
|
||||
```
|
||||
**Description**
|
||||
Returns true if any of the bits are set, otherwise false.
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
bool any(element_type mask) const
|
||||
```
|
||||
**Description**
|
||||
@ -350,13 +348,13 @@ Valid when the bitset width matches the element type width.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
bool none() const
|
||||
```
|
||||
**Description**
|
||||
Returns true if none of the bits are set, otherwise false.
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
bool none(element_type mask) const
|
||||
```
|
||||
**Description**
|
||||
@ -367,13 +365,13 @@ Valid when the bitset width matches the element type width.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
bool all() const
|
||||
```
|
||||
**Description**
|
||||
Returns true if al of the bits are set, otherwise false.
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
bool all(element_type mask) const
|
||||
```
|
||||
**Description**
|
||||
@ -384,7 +382,7 @@ Valid when the bitset width matches the element type width.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
size_t find_first(bool state) const
|
||||
```
|
||||
**Description**
|
||||
@ -392,7 +390,7 @@ Returns the position of the first bit in the specified state. If not found then
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
size_t find_next(bool state, size_t position) const
|
||||
```
|
||||
**Description**
|
||||
@ -401,7 +399,7 @@ position is not checked for validity.
|
||||
|
||||
## Bit operations
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
bitset<size_t Size>& operator &= (const bitset<size_t Size>& rhs);
|
||||
bitset<size_t Size>& operator |= (const bitset<size_t Size>& rhs);
|
||||
bitset<size_t Size>& operator ^= (const bitset<size_t Size>& rhs);
|
||||
@ -413,7 +411,7 @@ bool operator != (const bitset<size_t Size>& rhs);
|
||||
|
||||
## Non-member functions
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
void swap(etl::bitset<Size>& lhs, etl::bitset<Size>& rhs)
|
||||
```
|
||||
**Description**
|
||||
|
||||
@ -2,14 +2,12 @@
|
||||
title: "bloom_filter"
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
{{< callout >}}
|
||||
Header: `bloom_filter.h`
|
||||
Supported: All versions
|
||||
{{< /callout >}}
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::bloom_filter<size_t Width, typename THash1, typename THash2, typename THash3>
|
||||
```
|
||||
|
||||
@ -23,13 +21,13 @@ i.e. A bloom filter with a specified capacity of 195 bits will be rounded up to
|
||||
|
||||
The initial state of the Bloom filter is clear.
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
bloom_filter();
|
||||
```
|
||||
|
||||
## Operations
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
void clear()
|
||||
```
|
||||
**Description**
|
||||
@ -37,7 +35,7 @@ Clears the filter of all entries.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
void add(parameter_t key)
|
||||
```
|
||||
**Description**
|
||||
@ -45,7 +43,7 @@ Adds a key to the filter, where parameter_t is derived from the first hash argum
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
bool exists(parameter_t key) const
|
||||
```
|
||||
**Description**
|
||||
@ -53,7 +51,7 @@ Checks to see if a key may exist in the filter, where parameter_t is derived fro
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
size_t usage() const
|
||||
```
|
||||
**Description**
|
||||
@ -62,7 +60,7 @@ Equal to `100 * count() / width()`
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
bool count() const
|
||||
```
|
||||
**Description**
|
||||
@ -70,7 +68,7 @@ Returns the number of elements in use in the filter.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
bool width() const
|
||||
```
|
||||
**Description**
|
||||
@ -79,7 +77,7 @@ Equal to the template parameter WIDTH.
|
||||
|
||||
## Example
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
#include "bloom_filter.h"
|
||||
#include "fnv-1.h"
|
||||
#include "string.h"
|
||||
|
||||
@ -1,156 +0,0 @@
|
||||
---
|
||||
title: "const_map / _ext"
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
{{< callout >}}
|
||||
Header: `const_map.h`
|
||||
Supported: TBC
|
||||
Similar to: [std::map](https://en.cppreference.com/w/cpp/container/map.html)
|
||||
{{< /callout >}}
|
||||
|
||||
A fixed capacity read-only map based on a sorted array.
|
||||
The containers are designed to be able to be constexpr for C++14 and up.
|
||||
|
||||
The interface is most similar to std::map.
|
||||
Uses etl::less as the default key comparison method.
|
||||
etl::const_map<typename TKey, typename TMapped, size_t Size, TKeyCompare = etl::less>
|
||||
etl::const_map_ext<typename TKey, typename TMapped, TKeyCompare = etl::less>
|
||||
|
||||
Inherits from etl::iconst_map<TKey, TMapped, TKeyCompare>
|
||||
etl::iconst_map may be used as a Size independent pointer or reference type for any etl::const_map instance.
|
||||
Both the key type and mapped type must be default constructible.
|
||||
|
||||
---
|
||||
|
||||
Template deduction guides
|
||||
C++17 and above
|
||||
|
||||
template <typename... TPairs>
|
||||
etl::const_map(TPairs...)
|
||||
|
||||
Example
|
||||
constexpr etl::const_map data{ etl::pair{0, 1}, etl::pair{2, 3},
|
||||
etl::pair{4, 5}, etl::pair{6, 7} };
|
||||
Defines data as an const_map of int/int pairs, of length 4, containing the supplied data.
|
||||
---
|
||||
template <typename... TPairs>
|
||||
etl::const_map_ext(TPairs...)
|
||||
|
||||
Example
|
||||
constexpr etl::pair<int, int> values[]{ etl::pair{0, 1}, etl::pair{2, 3},
|
||||
etl::pair{4, 5}, etl::pair{6, 7} };
|
||||
constexpr etl::const_map_ext data{ values };
|
||||
Defines data as an const_map of int/int pairs, of length 4, containing the supplied data.
|
||||
|
||||
constexpr values[]{ etl::pair{0, 1}, etl::pair{2, 3},
|
||||
etl::pair{4, 5}, etl::pair{6, 7} };
|
||||
constexpr etl::span<const etl::pair<int, int>, 4> span{ values };
|
||||
constexpr etl::const_map_ext data{ span };
|
||||
Defines data as an const_map of int/int pairs, of length 4, containing the supplied data.
|
||||
---
|
||||
Member types
|
||||
|
||||
key_type TKey Must be default constructible.
|
||||
mapped_type TMapped Must be default constructible.
|
||||
value_type pair<const key_type, mapped_type>
|
||||
The type is either std::pair (default) or etl::pair (ETL_NO_STL)
|
||||
size_type std::size_t
|
||||
difference_type std::ptrdiff_t
|
||||
const_reference const T&
|
||||
const_pointer const T*
|
||||
const_iterator Constant random access iterator
|
||||
---
|
||||
Constructor
|
||||
|
||||
template <typename... TElements>
|
||||
ETL_CONSTEXPR14 explicit const_map(TElements&&... elements) ETL_NOEXCEPT
|
||||
Construct a const_map from a variadic list of elements.
|
||||
Static asserts if the elements are not of type value_type.
|
||||
Static asserts if the number of elements is greater than the capacity of the const_map.
|
||||
---
|
||||
Element access
|
||||
|
||||
ETL_CONSTEXPR14 const TMapped& at(key_parameter_t key) const ETL_NOEXCEPT
|
||||
Returns a const reference to the indexed element.
|
||||
---
|
||||
ETL_CONSTEXPR14 const TMapped& operator[](key_parameter_t key) const ETL_NOEXCEPT
|
||||
Returns a const reference to the indexed element.
|
||||
---
|
||||
Iterators
|
||||
|
||||
const_iterator begin() const ETL_NOEXCEPT
|
||||
const_iterator cbegin() const ETL_NOEXCEPT
|
||||
Returns an iterator to the beginning of the map.
|
||||
---
|
||||
const_iterator end() const ETL_NOEXCEPT
|
||||
const_iterator cend() const ETL_NOEXCEPT
|
||||
Returns an iterator to the end of the map.
|
||||
---
|
||||
Capacity
|
||||
|
||||
ETL_CONSTEXPR14 bool empty() const ETL_NOEXCEPT
|
||||
Returns true if the size of the map is zero, otherwise false.
|
||||
---
|
||||
ETL_CONSTEXPR14 bool full() const ETL_NOEXCEPT
|
||||
Returns true if the size of the lookup is size, otherwise false.
|
||||
---
|
||||
ETL_CONSTEXPR14 size_t size() const ETL_NOEXCEPT
|
||||
Returns the size of the lookup.
|
||||
---
|
||||
ETL_CONSTEXPR14 size_t max_size() const ETL_NOEXCEPT
|
||||
Returns the maximum possible Size of the map.
|
||||
---
|
||||
Status
|
||||
|
||||
ETL_CONSTEXPR14 bool is_valid() const ETL_NOEXCEPT
|
||||
Check that the elements are valid for a map.
|
||||
The elements must be sorted and contain no duplicates.
|
||||
---
|
||||
Search
|
||||
|
||||
ETL_CONSTEXPR14 const_iterator find(const key_type& key) const ETL_NOEXCEPT
|
||||
|
||||
ETL_CONSTEXPR14 const_iterator lower_bound(const key_type& key) const ETL_NOEXCEPT
|
||||
|
||||
ETL_CONSTEXPR14 const_iterator upper_bound(const key_type& key) const ETL_NOEXCEPT
|
||||
|
||||
ETL_CONSTEXPR14 pair<const_iterator, const_iterator> equal_range(const key_type& key) const ETL_NOEXCEPT
|
||||
The return type is either std::pair (default) or etl::pair (ETL_NO_STL)
|
||||
|
||||
ETL_CONSTEXPR14 bool contains(const key_type& k) const ETL_NOEXCEPT
|
||||
Check if the container contains the key.
|
||||
---
|
||||
For comparators that define is_transparent.
|
||||
|
||||
template <typename K>
|
||||
ETL_CONSTEXPR14 const_iterator find(const K& key) const ETL_NOEXCEPT
|
||||
|
||||
template <typename K>
|
||||
ETL_CONSTEXPR14 const_iterator lower_bound(const K& key) const ETL_NOEXCEPT
|
||||
|
||||
template <typename K>
|
||||
ETL_CONSTEXPR14 const_iterator upper_bound(const K& key) const ETL_NOEXCEPT
|
||||
|
||||
template <typename K>
|
||||
ETL_CONSTEXPR14 pair<const_iterator, const_iterator> equal_range(const K& key) const ETL_NOEXCEPT
|
||||
|
||||
template <typename K>
|
||||
ETL_CONSTEXPR14 bool contains(const K& k) const ETL_NOEXCEPT
|
||||
Check if the container contains the key.
|
||||
---
|
||||
Non-member functions
|
||||
|
||||
Lexicographically comparisons
|
||||
== true if the contents of the maps are equal, otherwise false.
|
||||
!= true if the contents of the maps are not equal, otherwise false.
|
||||
< true if the contents of the lhs is less-than the rhs, otherwise false.
|
||||
<= true if the contents of the lhs is less-than-equal the rhs, otherwise false.
|
||||
> true if the contents of the lhs is greater-than the rhs, otherwise false.
|
||||
>= true if the contents of the lhs is greater-than-equal the rhs, otherwise false.
|
||||
___________________________________________________________________________________________________
|
||||
Technical stuff
|
||||
|
||||
The const map is implemented as a sorted array key/value pairs.
|
||||
|
||||
@ -2,8 +2,6 @@
|
||||
title: "indirect_vector"
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
{{< callout >}}
|
||||
Header: `vector.h`
|
||||
Supported: All versions
|
||||
|
||||
6
docs/containers/maps/_index.md
Normal file
6
docs/containers/maps/_index.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
title: "Maps"
|
||||
weight: 100
|
||||
---
|
||||
|
||||
Map like containers.
|
||||
211
docs/containers/maps/const_map.md
Normal file
211
docs/containers/maps/const_map.md
Normal file
@ -0,0 +1,211 @@
|
||||
---
|
||||
title: "const_map / const_map_ext"
|
||||
---
|
||||
|
||||
{{< callout >}}
|
||||
Header: `const_map.h`
|
||||
Supported: TBC
|
||||
Similar to: [std::map](https://en.cppreference.com/w/cpp/container/map.html)
|
||||
{{< /callout >}}
|
||||
|
||||
A fixed capacity read-only map based on a sorted array.
|
||||
The containers are designed to be able to be constexpr for C++14 and up.
|
||||
|
||||
The interface is most similar to `std::map`.
|
||||
Uses etl::less as the default key comparison method.
|
||||
```cpp
|
||||
etl::const_map<typename TKey, typename TMapped, size_t Size, TKeyCompare = etl::less>
|
||||
etl::const_map_ext<typename TKey, typename TMapped, TKeyCompare = etl::less>
|
||||
```
|
||||
|
||||
Inherits from `etl::iconst_map<TKey, TMapped, TKeyCompare>`
|
||||
`etl::iconst_map` may be used as a Size independent pointer or reference type for any `etl::const_map` instance.
|
||||
Both the key type and mapped type must be default constructible.
|
||||
|
||||
## Template deduction guides
|
||||
**C++17 and above**
|
||||
|
||||
```cpp
|
||||
template <typename... TPairs>
|
||||
etl::const_map(TPairs...)
|
||||
```
|
||||
|
||||
**Example**
|
||||
```cpp
|
||||
constexpr etl::const_map data{ etl::pair{0, 1}, etl::pair{2, 3},
|
||||
etl::pair{4, 5}, etl::pair{6, 7} };
|
||||
```
|
||||
Defines data as an `const_map` of `int`/`int` pairs, of length 4, containing the supplied data.
|
||||
|
||||
---
|
||||
|
||||
```cpp
|
||||
template <typename... TPairs>
|
||||
etl::const_map_ext(TPairs...)
|
||||
```
|
||||
|
||||
**Example**
|
||||
```cpp
|
||||
constexpr etl::pair<int, int> values[]{ etl::pair{0, 1}, etl::pair{2, 3},
|
||||
etl::pair{4, 5}, etl::pair{6, 7} };
|
||||
|
||||
constexpr etl::const_map_ext data{ values };
|
||||
```
|
||||
Defines data as an `const_map` of `int`/`int` pairs, of length 4, containing the supplied data.
|
||||
|
||||
```cpp
|
||||
constexpr values[]{ etl::pair{0, 1}, etl::pair{2, 3},
|
||||
etl::pair{4, 5}, etl::pair{6, 7} };
|
||||
constexpr etl::span<const etl::pair<int, int>, 4> span{ values };
|
||||
constexpr etl::const_map_ext data{ span };
|
||||
```
|
||||
Defines data as an `const_map` of `int`/`int` pairs, of length 4, containing the supplied data.
|
||||
|
||||
## Member types
|
||||
|
||||
| Type | Maps to | Description |
|
||||
| ----------------- | --------------------------------- | ---------------------------------------------------------------- |
|
||||
| `key_type` | TKey | Must be default constructible. |
|
||||
| `mapped_type` | TMapped | Must be default constructible. |
|
||||
| `value_type` | pair<const key_type, mapped_type> | The type is either std::pair (default) or etl::pair (ETL_NO_STL) |
|
||||
| `size_type` | std::size_t | |
|
||||
| `difference_type` | std::ptrdiff_t | |
|
||||
| `const_reference` | const T& | |
|
||||
| `const_pointer` | const T* | |
|
||||
|` const_iterator` | | Constant random access iterator |
|
||||
|
||||
## Constructor
|
||||
```cpp
|
||||
template <typename... TElements>
|
||||
ETL_CONSTEXPR14 explicit const_map(TElements&&... elements) ETL_NOEXCEPT
|
||||
```
|
||||
Construct a const_map from a variadic list of elements.
|
||||
Static asserts if the elements are not of type `value_type`.
|
||||
Static asserts if the number of elements is greater than the capacity of the `const_map`.
|
||||
|
||||
## Element access
|
||||
```cpp
|
||||
ETL_CONSTEXPR14 const TMapped& at(key_parameter_t key) const ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Returns a const reference to the indexed element.
|
||||
|
||||
```cpp
|
||||
ETL_CONSTEXPR14 const TMapped& operator[](key_parameter_t key) const ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Returns a const reference to the indexed element.
|
||||
|
||||
## Iterators
|
||||
```cpp
|
||||
const_iterator begin() const ETL_NOEXCEPT
|
||||
const_iterator cbegin() const ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Returns an iterator to the beginning of the map.
|
||||
|
||||
```cpp
|
||||
const_iterator end() const ETL_NOEXCEPT
|
||||
const_iterator cend() const ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Returns an iterator to the end of the map.
|
||||
|
||||
## Capacity
|
||||
```cpp
|
||||
ETL_CONSTEXPR14 bool empty() const ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Returns `true` if the size of the map is zero, otherwise `false`.
|
||||
|
||||
```cpp
|
||||
ETL_CONSTEXPR14 bool full() const ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Returns `true` if the size of the lookup is size, otherwise `false`.
|
||||
|
||||
```cpp
|
||||
ETL_CONSTEXPR14 size_t size() const ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Returns the size of the lookup.
|
||||
|
||||
```cpp
|
||||
ETL_CONSTEXPR14 size_t max_size() const ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Returns the maximum possible Size of the map.
|
||||
|
||||
## Status
|
||||
```cpp
|
||||
ETL_CONSTEXPR14 bool is_valid() const ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Check that the elements are valid for a map.
|
||||
The elements must be sorted and contain no duplicates.
|
||||
|
||||
## Search
|
||||
```cpp
|
||||
ETL_CONSTEXPR14 const_iterator find(const key_type& key) const ETL_NOEXCEPT
|
||||
```
|
||||
```cpp
|
||||
ETL_CONSTEXPR14 const_iterator lower_bound(const key_type& key) const ETL_NOEXCEPT
|
||||
```
|
||||
```cpp
|
||||
ETL_CONSTEXPR14 const_iterator upper_bound(const key_type& key) const ETL_NOEXCEPT
|
||||
```
|
||||
```cpp
|
||||
ETL_CONSTEXPR14 pair<const_iterator, const_iterator> equal_range(const key_type& key) const ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
The return type is either std::pair (default) or etl::pair (ETL_NO_STL)
|
||||
|
||||
```cpp
|
||||
ETL_CONSTEXPR14 bool contains(const key_type& k) const ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Check if the container contains the key.
|
||||
|
||||
---
|
||||
|
||||
**For comparators that define is_transparent.**
|
||||
|
||||
```cpp
|
||||
template <typename K>
|
||||
ETL_CONSTEXPR14 const_iterator find(const K& key) const ETL_NOEXCEPT
|
||||
```
|
||||
```cpp
|
||||
template <typename K>
|
||||
ETL_CONSTEXPR14 const_iterator lower_bound(const K& key) const ETL_NOEXCEPT
|
||||
```
|
||||
```cpp
|
||||
template <typename K>
|
||||
ETL_CONSTEXPR14 const_iterator upper_bound(const K& key) const ETL_NOEXCEPT
|
||||
```
|
||||
```cpp
|
||||
template <typename K>
|
||||
ETL_CONSTEXPR14 pair<const_iterator, const_iterator> equal_range(const K& key) const ETL_NOEXCEPT
|
||||
```
|
||||
```cpp
|
||||
template <typename K>
|
||||
ETL_CONSTEXPR14 bool contains(const K& k) const ETL_NOEXCEPT
|
||||
```
|
||||
**Description**
|
||||
Check if the container contains the key.
|
||||
|
||||
## Non-member functions
|
||||
|
||||
**Lexicographically comparisons**
|
||||
| Operator | Description |
|
||||
| -------- | ----------------------------------------------------------------------------------- |
|
||||
| `==` | `true` if the contents of the maps are equal, otherwise `false`. |
|
||||
| `!=` | `true` if the contents of the maps are not equal, otherwise `false`. |
|
||||
| `<` | `true` if the contents of the lhs is less-than the rhs, otherwise `false`. |
|
||||
| `<=` | `true` if the contents of the lhs is less-than-equal the rhs, otherwise `false`. |
|
||||
| `>` | `true` if the contents of the lhs is greater-than the rhs, otherwise `false`. |
|
||||
| `>=` | `true` if the contents of the lhs is greater-than-equal the rhs, otherwise `false`. |
|
||||
|
||||
## Technical stuff
|
||||
|
||||
The const map is implemented as a sorted array key/value pairs.
|
||||
|
||||
@ -2,8 +2,6 @@
|
||||
title: "vector"
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
{{< callout >}}
|
||||
Header: `vector.h`
|
||||
Supported: All versions
|
||||
|
||||
@ -3,8 +3,6 @@ title: "Arduino"
|
||||
weight: 5
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
This page describes the issue specific to using the ETL with the Arduino platform.
|
||||
|
||||
The Arduino version of the ETL may be downloaded either through the Arduino IDE's library manager, or the ZIP fileavailable from the GitHub repository.
|
||||
@ -17,7 +15,7 @@ If you wish to identify the Arduino board then `Embedded_Template_Library.h` wil
|
||||
|
||||
You must also define `ETL_NO_STL` if you are not using the STL.
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
#define ETL_NO_STL
|
||||
|
||||
#include <Arduino>
|
||||
|
||||
@ -3,8 +3,6 @@ title: "Compilers"
|
||||
weight: 3
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
The library is intended to be used on multiple platforms and devices. Not every single combination ofcompiler/IDE/device/library template have been, or can realistically be, checked. A set of profiles have been created for the most popular setups.
|
||||
If you have issues porting the library to your platform then contact me, and I will do my best to resolve anyincompatibilities.
|
||||
If you have no issues, or have solved it by yourself then please [let me know](https://github.com/ETLCPP/etl/issues) so that I may add information about it to this page.
|
||||
@ -82,7 +80,7 @@ If `ArduinoSTL.h` is removed, then fails with printf has not been declared.
|
||||
|
||||
**General**
|
||||
It may be necessary to add the following lines to the beginning of the file.
|
||||
```C++
|
||||
```cpp
|
||||
#undef min
|
||||
#undef max
|
||||
```
|
||||
|
||||
@ -3,8 +3,6 @@ title: "Contributing to the ETL"
|
||||
weight: 6
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
Thanks for considering a contribution! Here’s what you need to know before opening a pull request:
|
||||
|
||||
If you are thinking of adding a new feature then raise this on the GitHub Issues page for discussion as the maintainers and users of the ETL may have questions or suggestions.
|
||||
@ -67,7 +65,7 @@ If a feature is only implementable for a certain C++ standard or above, wrap the
|
||||
`ETL_USING_CPP23` For C++23 or above
|
||||
|
||||
i.e.
|
||||
```C++
|
||||
```cpp
|
||||
#if ETL_USING_CPP11
|
||||
...
|
||||
#endif
|
||||
@ -85,7 +83,7 @@ All ETL classes are to be within the `etl` namespace.
|
||||
### Private functionality
|
||||
All classes private to the ETL should reside in a nested namespace prefixed with `private_`
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
namespace etl
|
||||
{
|
||||
namespace private_funky_container
|
||||
@ -113,7 +111,7 @@ Use comments to summarise or explain blocks of code that may be difficult to qui
|
||||
Avoid using `int8_t` or `uint8_t`.
|
||||
Some processors such as DSPs do not support 8 bit values. Use `int_least_8_t` and `uint_least8_t` in their place.
|
||||
If `int8_t` or `uint8_t` must be used then surround the code with
|
||||
```C++
|
||||
```cpp
|
||||
#if ETL_USING_8BIT_TYPES
|
||||
#endif
|
||||
```
|
||||
@ -121,7 +119,7 @@ If `int8_t` or `uint8_t` must be used then surround the code with
|
||||
### 64 bit types
|
||||
If `int64_t` or `uint64_t` must be used
|
||||
Then surround the code with
|
||||
```C++
|
||||
```cpp
|
||||
#if ETL_USING_64BIT_TYPES
|
||||
#endif
|
||||
```
|
||||
@ -146,7 +144,7 @@ This will ensure that the correct code is generated for the user selected error
|
||||
### Constructors
|
||||
Align the initialisation of member variables in constructors as below.
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
class my_new_class
|
||||
{
|
||||
public:
|
||||
@ -164,7 +162,7 @@ class my_new_class
|
||||
When possible, try to tabluate the initialisation of multiple variables. It's a lot easier to read.
|
||||
Don't be too strict about it, if it would result in giant amounts of whitespace.
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
int count = 0;
|
||||
double divisor = 1.234;
|
||||
etl::string<10> name = "Default";
|
||||
@ -175,7 +173,7 @@ etl::intrusive_forward_list<data_link_type> quite_long_variable_name(data1, data
|
||||
### ETL errors
|
||||
ETL errors are packaged in exception structures. Do not get confused with this terminology, it does not mean that it will *always* be thrown as an exception. It may just be passed as a parameter to an error handler.
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
class stack_exception : public exception
|
||||
{
|
||||
public:
|
||||
|
||||
@ -3,8 +3,6 @@ title: "Header guards"
|
||||
weight: 6
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
The ETL as a default uses `#include` headers guards.
|
||||
If you wish, you can convert them to using `#pragma once`.
|
||||
|
||||
|
||||
@ -3,8 +3,6 @@ title: "No STL"
|
||||
weight: 2
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
It is possible to use the ETL without any reliance on the STL —
|
||||
This can be achieved by defining the project wide macro `ETL_NO_STL`.
|
||||
|
||||
|
||||
@ -3,8 +3,6 @@ title: "Setup"
|
||||
weight: 1
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
This page describes the steps needed to integrate the ETL with your project.
|
||||
|
||||
## CMake
|
||||
@ -75,7 +73,7 @@ work with default values.
|
||||
|
||||
## Example
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
#ifndef __ETL_PROFILE_H__
|
||||
#define __ETL_PROFILE_H__
|
||||
|
||||
@ -107,7 +105,7 @@ used, due to project specifics:
|
||||
|
||||
### Example
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
#include <etl/chrono.h>
|
||||
#include <etl/print.h>
|
||||
|
||||
@ -165,7 +163,7 @@ This header is included from ETL's `platform.h`
|
||||
|
||||
An example of `etl_profile.h` could be:-
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
#ifndef ETL_PROFILE_H
|
||||
#define ETL_PROFILE_H
|
||||
|
||||
@ -187,7 +185,7 @@ The user does not need to modify this file.
|
||||
## Additional include directories
|
||||
The compiler will normally expect paths to additional include directories to be specified
|
||||
A path to `etl/include` would normally be set, allowing header files to be specified as follows:-
|
||||
```C++
|
||||
```cpp
|
||||
#include "etl/vector.h"
|
||||
#include "etl/fsm.h"
|
||||
```
|
||||
|
||||
@ -4,8 +4,6 @@ draft: true
|
||||
weight: 1
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
{{< callout type="info">}}
|
||||
Header: `my_class.h`
|
||||
Supported: `xx.yy.zz`
|
||||
@ -14,13 +12,13 @@ weight: 1
|
||||
|
||||
A short description of the code this document is about.
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
The signature of the class, struct, or function
|
||||
```
|
||||
|
||||
## Template Parameters
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
TParameter1
|
||||
```
|
||||
**Description**
|
||||
@ -28,7 +26,7 @@ A description the the TParameter1 template parameter.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
TParameter1
|
||||
```
|
||||
**Description**
|
||||
@ -36,7 +34,7 @@ A description the the TParameter1 template parameter.
|
||||
|
||||
## Exceptions
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::your_firt_exception_type
|
||||
```
|
||||
**Description**
|
||||
@ -44,19 +42,19 @@ Description of what the exception indicates.
|
||||
|
||||
## Member Types
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
`first_member_type`
|
||||
```
|
||||
**Description**
|
||||
The first member type
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
return_type
|
||||
```
|
||||
**Description**
|
||||
`The second class member type`
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
argument_types
|
||||
```
|
||||
**Description**
|
||||
@ -93,7 +91,7 @@ rvalue reference to etl::my_class.
|
||||
|
||||
## Invocation
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
int operator(float f)
|
||||
```
|
||||
**Description**
|
||||
@ -107,7 +105,7 @@ An integer calculated from the float.
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
int calculate(float f)
|
||||
```
|
||||
**Description**
|
||||
@ -121,7 +119,7 @@ An integer calculated from the float.
|
||||
|
||||
## Observers
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
bool is_valid() const
|
||||
```
|
||||
**Returns**
|
||||
@ -129,7 +127,7 @@ bool is_valid() const
|
||||
|
||||
## Modifiers
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
void clear()
|
||||
```
|
||||
**Description**
|
||||
@ -143,7 +141,7 @@ None
|
||||
|
||||
---
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
void swap(my_class& other)
|
||||
```
|
||||
**Description**
|
||||
@ -157,7 +155,7 @@ A reference to another my_class object.
|
||||
|
||||
## Example
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
#include "etl/my_class.h"
|
||||
|
||||
etl::my_class my_object1;
|
||||
|
||||
@ -2,8 +2,6 @@
|
||||
title: "Containers"
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
## Overview
|
||||
The containers in the ETL are designed to complement those found in the STL. The main difference is that their capacity is defined at compile time and they contain their own storage. They do not allocate any storage from the heap at any time.
|
||||
This is an advantage on an embedded device as all of the memory required by the application will be defined upfront. Also due to the storage's contiguous nature, the containers are cache friendly.
|
||||
@ -11,14 +9,14 @@ This is an advantage on an embedded device as all of the memory required by the
|
||||
Containers in the ETL library are mostly based around a common design theme of three classes.
|
||||
(Where container is the name of the relevant container).
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
container<type, size>
|
||||
icontainer<type>
|
||||
container_base
|
||||
```
|
||||
|
||||
**i.e.**
|
||||
```C++
|
||||
```cpp
|
||||
etl::vector<type, size>
|
||||
etl::ivector<type>
|
||||
etl::vector_base
|
||||
@ -33,7 +31,7 @@ The classes do not implement any virtual functions and, like STL containers, are
|
||||
Code using containers of a specific type can be written to be independent of the storage size through use of icontainer class references.
|
||||
|
||||
## Example
|
||||
```C++
|
||||
```cpp
|
||||
#include "etl/vector.h"
|
||||
#include "etl/numeric.h"
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ For example, a message source may pass messages to a message bus. The message bu
|
||||
|
||||
## Messages
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::message
|
||||
```
|
||||
|
||||
@ -21,7 +21,7 @@ All messages are untimately derived from `etl::imessage`.
|
||||
They are directly derived from the template `etl::message<const etl::message_id_t ID>`.
|
||||
Each message must have an id that is at least unique to the receiver, though normally ids would be unique across the application.
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
enum class MessageId : etl::message_id_t
|
||||
{
|
||||
StartMotorId,
|
||||
@ -45,7 +45,7 @@ By default the message id is a `uint_least8_t`. This may be changed by defining
|
||||
|
||||
## Message Routers
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::message_router
|
||||
```
|
||||
Messages routers are defined to handle a specified set of messages. Defining a message router will mandate that a specific set of `on_receive` functions to handle each message type be defined, along with an 'unknown' handler.
|
||||
@ -57,7 +57,7 @@ See the `QueuedMessageRouter` project in the `examples` directory.
|
||||
|
||||
## Message Buses
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::message_bus
|
||||
```
|
||||
Message buses are a type of message router.
|
||||
@ -67,14 +67,14 @@ Messages sent to the bus may either be broadcast or directed only to routers wit
|
||||
|
||||
## Message Timer
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::message_timer
|
||||
```
|
||||
The message timer is a generator of messages. Up to 254 timers may be defined that can be configured to send a message to a router, bus or FSM at periodic intervals.
|
||||
|
||||
## Finite State Machines (FSM & HFSM)
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
etl::fsm
|
||||
etl::hfsm
|
||||
```
|
||||
|
||||
@ -5,14 +5,14 @@ title: "Observer"
|
||||
A tutorial on how the ETL's observer pattern can be used.
|
||||
|
||||
## The Classes
|
||||
```C++
|
||||
```cpp
|
||||
etl::observer
|
||||
etl::observable
|
||||
```
|
||||
## Example
|
||||
This example shows an observable mouse driver that is observed by two event handlers.
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
#include <iostream>
|
||||
|
||||
#include "observer.h"
|
||||
|
||||
@ -16,13 +16,13 @@ A shared message encapsulates a pointer to a reference counted message. Each tim
|
||||
The shared message assumes that the owner pool implements a function or function template that will allocate a reference counted message from the supplied message type.
|
||||
|
||||
**Example**
|
||||
```C++
|
||||
```cpp
|
||||
template <typename TMessage>
|
||||
etl::ireference_counted_message* allocate(const TMessage& message)
|
||||
```
|
||||
|
||||
## Reference Counted Messages
|
||||
```C++
|
||||
```cpp
|
||||
reference_counted_message
|
||||
reference_counted_message_pool
|
||||
```
|
||||
@ -44,7 +44,7 @@ If the pool is being used in a multi-threaded environment or with interrupts the
|
||||
An `etl::persistent_message` is a special type of reference counted message that does not belong to a pool. It will always have a reference count of 1. These may be used for messages that are fixed in value; i.e. their members do not change during the lifetime of the application.
|
||||
|
||||
## Memory block allocators
|
||||
```c++
|
||||
```cpp
|
||||
imemory_block_allocator
|
||||
fixed_sized_memory_block_allocator
|
||||
```
|
||||
@ -61,7 +61,7 @@ The ETL defines a simple, fixed sized, memory block allocator, `etl::fixed_sized
|
||||
|
||||
The code below may be found in `examples/SharedMessage`
|
||||
|
||||
```c++
|
||||
```cpp
|
||||
//*****************************************************************************
|
||||
// Shared message example
|
||||
//*****************************************************************************
|
||||
|
||||
@ -2,12 +2,10 @@
|
||||
title: "unique_ptr with pool"
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
This example shows objects being created from an `etl::pool`, stored in an `etl::unique_ptr`, and released back
|
||||
to the pool when the `etl::unique_ptr` goes out of scope.
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
#include <iostream>
|
||||
|
||||
#include "etl/memory.h"
|
||||
|
||||
@ -5,7 +5,7 @@ title: "Visitor"
|
||||
A tutorial on how the ETL's visitor pattern can be used.
|
||||
|
||||
## The Classes
|
||||
```C++
|
||||
```cpp
|
||||
etl::visitor
|
||||
etl::visitable
|
||||
```
|
||||
@ -15,7 +15,7 @@ I'll use the familiar 'Shape' example.
|
||||
|
||||
First, you create the base for your 'Shape' visitor.
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
//*****************************************************************
|
||||
// Pre-declare the shapes.
|
||||
//*****************************************************************
|
||||
@ -35,7 +35,7 @@ class Shape_Visitor : public etl:visitor<Square, Circle, Triangle>
|
||||
|
||||
Then, you define the Shape base class. It derives from the `etl::visitable` class that defines a pure virtual accept function that accepts a `Shape_Visitor`.
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
//*****************************************************************
|
||||
// The shape base class.
|
||||
//*****************************************************************
|
||||
@ -46,7 +46,7 @@ class Shape : public etl::visitable<Shape_Visitor>
|
||||
|
||||
Next, you define the shapes `Square`, `Circle`, and `Triangle`. Each overrides the accept function that calls the visitor with itself as a parameter.
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
//*****************************************************************
|
||||
// The square class
|
||||
//*****************************************************************
|
||||
@ -83,7 +83,7 @@ class Triangle : public Shape
|
||||
|
||||
Now that you have the framework in place, you can do something with it. Here's an example that creates `Draw` and `Serialise` visitors and applies them to a vector of `Shape` objects.
|
||||
|
||||
```C++
|
||||
```cpp
|
||||
//*****************************************************************
|
||||
// The 'draw' visitor.
|
||||
//*****************************************************************
|
||||
|
||||
4
docs/utilities/_index.md
Normal file
4
docs/utilities/_index.md
Normal file
@ -0,0 +1,4 @@
|
||||
---
|
||||
title: "Utilities"
|
||||
weight: 100
|
||||
---
|
||||
107
docs/utilities/type_id.md
Normal file
107
docs/utilities/type_id.md
Normal file
@ -0,0 +1,107 @@
|
||||
---
|
||||
title: "type_id"
|
||||
---
|
||||
|
||||
Below is a concise, technical overview of the `etl::type_id` facility, suitable for design documentation or code review context.
|
||||
|
||||
## Overview:
|
||||
`etl::type_id` is a lightweight, RTTI-free mechanism for uniquely identifying C++ types at runtime. It is designed for environments where standard RTTI (`typeid`, `std::type_info`) is unavailable, undesirable, or too costly—such as embedded systems or performance-constrained platforms.
|
||||
|
||||
The implementation guarantees uniqueness per type within a program image while remaining constexpr-friendly and requiring no dynamic allocation.
|
||||
|
||||
## Design Concept
|
||||
|
||||
The core idea is to associate each distinct type `T` with the address of a unique static object. That address serves as the type’s identifier.
|
||||
|
||||
This is achieved through:
|
||||
|
||||
```cpp
|
||||
template <typename T>
|
||||
struct type_id_anchor
|
||||
{
|
||||
static char value;
|
||||
};
|
||||
```
|
||||
|
||||
Each instantiation of `type_id_anchor<T>` owns its own `static char value`, and the address of that variable is guaranteed to be unique for each distinct `T`. The address is stable for the lifetime of the program.
|
||||
|
||||
## Key Components
|
||||
|
||||
### Type Normalization
|
||||
|
||||
When requesting a type ID via `type_id::get<T>()`, the type is first normalised:
|
||||
|
||||
```cpp
|
||||
using type = typename etl::remove_cvref<T>::type;
|
||||
```
|
||||
|
||||
This ensures that:
|
||||
|
||||
* `T`, `const T`, `T&`, and `T&&` all map to the same `type_id`
|
||||
* Only the underlying type identity matters
|
||||
|
||||
### Type ID Generation
|
||||
|
||||
```cpp
|
||||
template <typename T>
|
||||
static ETL_CONSTEXPR type_id get() ETL_NOEXCEPT;
|
||||
```
|
||||
|
||||
* Returns a `type_id` that uniquely represents `T`
|
||||
* Internally stores the address of `type_id_anchor<T>::value`
|
||||
* Requires no RTTI, no dynamic memory, and no runtime registration
|
||||
|
||||
### Invalid Type ID
|
||||
|
||||
```cpp
|
||||
static ETL_CONSTEXPR type_id invalid_id() ETL_NOEXCEPT;
|
||||
```
|
||||
|
||||
* Represents an invalid or uninitialised type ID
|
||||
* Implemented as a null pointer (`id == nullptr`)
|
||||
* Default constructor produces this state
|
||||
|
||||
## `type_id` Class Semantics
|
||||
|
||||
### Storage
|
||||
|
||||
```cpp
|
||||
const void* id;
|
||||
```
|
||||
|
||||
* The identifier is stored as a pointer
|
||||
* Comparison is purely pointer comparison (fast and deterministic)
|
||||
|
||||
### Supported Operations
|
||||
|
||||
| Operation | Behavior |
|
||||
| ------------------ | -------------------------------------------------- |
|
||||
| Equality (`==`) | True if both type IDs refer to the same type |
|
||||
| Inequality (`!=`) | Logical negation of equality |
|
||||
| Ordering (`<`) | Pointer comparison (useful for ordered containers) |
|
||||
| Boolean conversion | `true` if valid, `false` if invalid |
|
||||
| Integer conversion | Explicit conversion to `intptr_t` / `uintptr_t` |
|
||||
|
||||
### Copy and Assignment
|
||||
|
||||
* Copyable and assignable
|
||||
* Copy semantics preserve identity (pointer value)
|
||||
|
||||
## Guarantees and Properties
|
||||
|
||||
* **Uniqueness**: Each distinct type has exactly one unique `type_id`
|
||||
* **Stability**: Type IDs remain valid for the entire program lifetime
|
||||
* **Zero overhead**: No dynamic allocation, no lookup tables
|
||||
* **RTTI-free**: Suitable for builds with RTTI disabled
|
||||
* **Comparable**: Can be used as keys in associative containers
|
||||
|
||||
## Typical Use Cases
|
||||
|
||||
* Type-safe containers (e.g., variant, any, message buses)
|
||||
* Plugin or component systems
|
||||
* Compile-time / runtime type discrimination in embedded systems
|
||||
* Replacement for `std::type_index` in restricted environments
|
||||
|
||||
## Summary
|
||||
|
||||
`etl::type_id` provides a robust, minimal, and efficient alternative to C++ RTTI by encoding type identity as the address of a unique static object. Its design is particularly well-suited to embedded and low-level systems where determinism, performance, and binary size are critical.
|
||||
@ -10,7 +10,10 @@ html:not(.dark) .highlight .chroma .cpf {
|
||||
}
|
||||
|
||||
html:not(.dark) h1 {
|
||||
color: coral !important;
|
||||
color: coral !important;
|
||||
width: 100%;
|
||||
border-bottom: 3px solid black !important;
|
||||
padding-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
html:not(.dark) h2 {
|
||||
@ -22,7 +25,6 @@ html:not(.dark) h3,
|
||||
html:not(.dark) h4
|
||||
{
|
||||
color: rgb(29, 172, 29) !important;
|
||||
border-bottom: 1px solid darkgrey !important;
|
||||
}
|
||||
|
||||
html:not(.dark) p {
|
||||
@ -115,17 +117,18 @@ html.dark .hx\:dark\:bg-dark {
|
||||
html.dark h1
|
||||
{
|
||||
color: coral !important;
|
||||
border-bottom: 2px solid #c0c0c0 !important;
|
||||
padding-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
html.dark h2 {
|
||||
color: #7099c7 !important;
|
||||
border-bottom: 3px solid #f0f0f0 !important;
|
||||
border-bottom: 2px solid #c0c0c0 !important;
|
||||
}
|
||||
|
||||
html.dark h3,
|
||||
html.dark h4 {
|
||||
color: lightgreen !important;
|
||||
border-bottom: 1px solid rgb(76, 76, 76) !important;
|
||||
}
|
||||
|
||||
html.dark p {
|
||||
@ -219,10 +222,16 @@ html.dark .hextra-sidebar-item[data-active="true"] a:hover span {
|
||||
.highlight .chroma .kt,
|
||||
.highlight .chroma .nc,
|
||||
.highlight .chroma .nf,
|
||||
.highlight .chroma .o,
|
||||
.highlight .chroma .cp,
|
||||
.highlight .chroma .cpf {
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
font-weight: normal !important;
|
||||
font-style: normal !important;
|
||||
}
|
||||
|
||||
.hx\:mb-0 {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* .highlight .chroma .c1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user