mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-15 08:26:04 +08:00
Merge branch 'development' into bugfixes
This commit is contained in:
commit
0f67a63da0
@ -41,7 +41,7 @@ elif [ "$2" = "inside_container" ] ; then
|
||||
cd build-$ARCH
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE=../.devcontainer/$ARCH/toolchain-$ARCH.cmake \
|
||||
-DBUILD_TESTS=ON -DNO_STL=ON -DETL_CXX_STANDARD=23 \
|
||||
-DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_OPTIMISATION=-O0 -DETL_ENABLE_SANITIZER=Off -DETL_MESSAGES_ARE_NOT_VIRTUAL=OFF \
|
||||
-DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_OPTIMISATION=-O0 -DETL_ENABLE_SANITIZER=OFF -DETL_MESSAGES_ARE_NOT_VIRTUAL=OFF \
|
||||
../test
|
||||
export CMAKE_BUILD_PARALLEL_LEVEL=$(nproc)
|
||||
cmake --build .
|
||||
|
||||
31
.github/workflows/meson-gcc-c++23-no-stl.yml
vendored
Normal file
31
.github/workflows/meson-gcc-c++23-no-stl.yml
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
name: meson-gcc-c++23-no-stl
|
||||
on:
|
||||
push:
|
||||
branches: [ master, development, pull-request/* ]
|
||||
pull_request:
|
||||
branches: [ master, development, pull-request/* ]
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
jobs:
|
||||
|
||||
build-meson-gcc-cpp23-no-stl:
|
||||
name: Meson GCC C++23 Linux - No STL
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Install Meson
|
||||
run: sudo apt-get install -y meson
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
export CC=gcc
|
||||
export CXX=g++
|
||||
meson setup builddir -Duse_stl=false -Dcpp_std=c++23
|
||||
|
||||
- name: Build
|
||||
run: meson compile -C builddir
|
||||
|
||||
- name: Run tests
|
||||
run: meson test -C builddir -v
|
||||
@ -365,8 +365,15 @@ etl::format_to(s, "a}b"); // unescaped }
|
||||
etl::format_to(s, "{:d}", sv); // invalid type for string_view
|
||||
```
|
||||
|
||||
> **Note:** On C++20 and later, compile-time format string validation through
|
||||
> `consteval` is planned but not yet fully implemented.
|
||||
> **Note:** On C++20 and later, format strings are validated at compile time
|
||||
> via `consteval`. The checks cover syntax (balanced braces, valid format spec
|
||||
> grammar, index bounds, no mixing of automatic and manual indexing) as well as
|
||||
> type/specifier compatibility (e.g. `{:d}` is rejected for string arguments).
|
||||
> A malformed format string produces a compile error whose diagnostic mentions
|
||||
> `please_note_this_is_error_message_format_string_syntax_error`.
|
||||
>
|
||||
> On C++11–C++17, the same checks run at runtime and throw
|
||||
> `etl::bad_format_string_exception`.
|
||||
|
||||
## 10. Differences from `std::format`
|
||||
|
||||
@ -378,5 +385,5 @@ etl::format_to(s, "{:d}", sv); // invalid type for string_view
|
||||
| **Floating-point support** | Always available | Opt-in via `ETL_USING_FORMAT_FLOATING_POINT`. |
|
||||
| **User-defined formatters** | `std::formatter<T>` specialisations | Not yet supported. |
|
||||
| **Locale** | `L` flag uses `std::locale` | `L` flag is parsed but has no effect. |
|
||||
| **Compile-time validation** | Enforced via `consteval` on C++20 | Planned; currently validates at run time and throws `etl::bad_format_string_exception`. |
|
||||
| **Compile-time validation** | Enforced via `consteval` on C++20 | Enforced via `consteval` on C++20 (syntax and type/specifier compatibility); validates at run time and throws `etl::bad_format_string_exception` on C++11–C++17. |
|
||||
| **`format_to_n` return type** | `std::format_to_n_result` | Returns the underlying `OutputIt` directly. |
|
||||
|
||||
116
docs/meson.md
Normal file
116
docs/meson.md
Normal file
@ -0,0 +1,116 @@
|
||||
# Building ETL with Meson
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- [Meson](https://mesonbuild.com/) >= 0.57.0
|
||||
- A C++17 compiler (GCC, Clang, or MSVC)
|
||||
- [Ninja](https://ninja-build.org/) (default Meson backend)
|
||||
|
||||
UnitTest++ is fetched automatically as a Meson subproject — no manual dependency installation is needed.
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# Configure (from the project root)
|
||||
meson setup builddir
|
||||
|
||||
# Build
|
||||
meson compile -C builddir
|
||||
|
||||
# Run tests
|
||||
meson test -C builddir
|
||||
```
|
||||
|
||||
## Build Options
|
||||
|
||||
### ETL project options
|
||||
|
||||
| Option | Type | Default | Description |
|
||||
|---------------------|------|---------|-------------------------------------------------------------------|
|
||||
| `use_stl` | bool | `true` | Build with STL support. When `false`, defines `ETL_NO_STL`. |
|
||||
| `enable_sanitizer` | bool | `false` | Enable AddressSanitizer and UndefinedBehaviorSanitizer (GCC/Clang only). |
|
||||
|
||||
### Meson built-in options
|
||||
|
||||
| Option | Type | Default | Description |
|
||||
|-------------|--------|----------|----------------------------------------------------------|
|
||||
| `cpp_std` | string | `c++17` | C++ standard to compile with (e.g. `c++20`, `c++23`). |
|
||||
| `buildtype` | string | `debug` | Build type: `plain`, `debug`, `debugoptimized`, `release`, `minsize`. |
|
||||
| `werror` | bool | `false` | Treat compiler warnings as errors. |
|
||||
|
||||
These are handled by Meson directly — no `get_option()` call is needed in the build files.
|
||||
|
||||
### Examples
|
||||
|
||||
```bash
|
||||
# No STL, C++23
|
||||
meson setup builddir -Duse_stl=false -Dcpp_std=c++23
|
||||
|
||||
# Release build with sanitizers
|
||||
meson setup builddir -Dbuildtype=release -Denable_sanitizer=true
|
||||
|
||||
# Override the C++ standard on an existing build directory
|
||||
meson configure builddir -Dcpp_std=c++20
|
||||
```
|
||||
|
||||
## Selecting a Compiler
|
||||
|
||||
The compiler is chosen at configure time via environment variables:
|
||||
|
||||
```bash
|
||||
# GCC
|
||||
CC=gcc CXX=g++ meson setup builddir
|
||||
|
||||
# Clang
|
||||
CC=clang CXX=clang++ meson setup builddir
|
||||
|
||||
# Specific versions
|
||||
CC=gcc-14 CXX=g++-14 meson setup builddir
|
||||
CC=clang-18 CXX=clang++-18 meson setup builddir
|
||||
```
|
||||
|
||||
To switch compilers on an existing build directory, wipe it first:
|
||||
|
||||
```bash
|
||||
CC=clang CXX=clang++ meson setup --wipe builddir
|
||||
```
|
||||
|
||||
Or use separate directories per compiler:
|
||||
|
||||
```bash
|
||||
CC=gcc CXX=g++ meson setup build-gcc
|
||||
CC=clang CXX=clang++ meson setup build-clang
|
||||
```
|
||||
|
||||
## Running Tests
|
||||
|
||||
```bash
|
||||
# Run all tests
|
||||
meson test -C builddir
|
||||
|
||||
# Verbose output (shows individual test results)
|
||||
meson test -C builddir -v
|
||||
|
||||
# Run the test binary directly
|
||||
./builddir/test/etl_unit_tests
|
||||
```
|
||||
|
||||
## Sanitizers
|
||||
|
||||
On GCC and Clang, AddressSanitizer and UndefinedBehaviorSanitizer can be enabled via the `enable_sanitizer` option:
|
||||
|
||||
```bash
|
||||
meson setup builddir -Denable_sanitizer=true
|
||||
```
|
||||
|
||||
Note: UBSan may prevent certain `constexpr` evaluations involving function pointers from compiling (e.g. in the closure tests). This matches the CMake build, where sanitizers are also opt-in via `ETL_ENABLE_SANITIZER=ON`.
|
||||
|
||||
## Using ETL as a Subproject
|
||||
|
||||
ETL can be consumed as a Meson subproject. In your project's `subprojects/` directory, create an `etl.wrap` file, then use:
|
||||
|
||||
```meson
|
||||
etl_dep = dependency('etl', fallback: ['etl', 'etl_dep'])
|
||||
```
|
||||
|
||||
When built as a subproject, the ETL test suite is not compiled.
|
||||
@ -51,7 +51,7 @@ SOFTWARE.
|
||||
#include "type_traits.h"
|
||||
#include "utility.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "private/minmax_push.h"
|
||||
|
||||
@ -35,10 +35,7 @@ SOFTWARE.
|
||||
#include "algorithm.h"
|
||||
#include "error_handler.h"
|
||||
#include "exception.h"
|
||||
#include "functional.h"
|
||||
#include "initializer_list.h"
|
||||
#include "iterator.h"
|
||||
#include "nth_type.h"
|
||||
#include "parameter_type.h"
|
||||
#include "static_assert.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
@ -31,11 +31,8 @@ SOFTWARE.
|
||||
#include "error_handler.h"
|
||||
#include "exception.h"
|
||||
#include "integral_limits.h"
|
||||
#include "static_assert.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**************************************************************************************************************************************************************************
|
||||
* See https://en.wikipedia.org/wiki/Base64
|
||||
*
|
||||
|
||||
@ -34,7 +34,6 @@ SOFTWARE.
|
||||
///\ingroup string
|
||||
|
||||
#include "platform.h"
|
||||
#include "static_assert.h"
|
||||
#include "type_traits.h"
|
||||
#include "utility.h"
|
||||
|
||||
|
||||
@ -39,7 +39,6 @@ SOFTWARE.
|
||||
#include "error_handler.h"
|
||||
#include "exception.h"
|
||||
#include "flags.h"
|
||||
#include "functional.h"
|
||||
#include "integral_limits.h"
|
||||
#include "iterator.h"
|
||||
#include "memory.h"
|
||||
|
||||
@ -51,7 +51,6 @@ SOFTWARE.
|
||||
#include "utility.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if ETL_HAS_ATOMIC
|
||||
|
||||
|
||||
@ -33,10 +33,10 @@ SOFTWARE.
|
||||
|
||||
#include "platform.h"
|
||||
#include "iterator.h"
|
||||
#include "static_assert.h"
|
||||
#include "type_traits.h"
|
||||
#include "utility.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace etl
|
||||
|
||||
@ -36,10 +36,9 @@ SOFTWARE.
|
||||
#include "array.h"
|
||||
#include "cyclic_value.h"
|
||||
#include "delegate.h"
|
||||
#include "static_assert.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <stddef.h>
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
|
||||
|
||||
@ -40,13 +40,11 @@ SOFTWARE.
|
||||
#include "integral_limits.h"
|
||||
#include "iterator.h"
|
||||
#include "memory.h"
|
||||
#include "nullptr.h"
|
||||
#include "optional.h"
|
||||
#include "span.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
namespace etl
|
||||
{
|
||||
|
||||
@ -33,8 +33,6 @@ SOFTWARE.
|
||||
#include "algorithm.h"
|
||||
#include "delegate.h"
|
||||
#include "error_handler.h"
|
||||
#include "function.h"
|
||||
#include "nullptr.h"
|
||||
#include "placement_new.h"
|
||||
#include "static_assert.h"
|
||||
#include "timer.h"
|
||||
|
||||
@ -33,7 +33,6 @@ SOFTWARE.
|
||||
#include "algorithm.h"
|
||||
#include "delegate.h"
|
||||
#include "error_handler.h"
|
||||
#include "nullptr.h"
|
||||
#include "placement_new.h"
|
||||
#include "static_assert.h"
|
||||
#include "timer.h"
|
||||
|
||||
@ -33,7 +33,6 @@ SOFTWARE.
|
||||
#include "algorithm.h"
|
||||
#include "delegate.h"
|
||||
#include "error_handler.h"
|
||||
#include "nullptr.h"
|
||||
#include "placement_new.h"
|
||||
#include "static_assert.h"
|
||||
#include "timer.h"
|
||||
|
||||
@ -34,6 +34,4 @@ SOFTWARE.
|
||||
#include "platform.h"
|
||||
#include "iterator.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#endif
|
||||
|
||||
@ -38,11 +38,8 @@ SOFTWARE.
|
||||
#include "platform.h"
|
||||
#include "algorithm.h"
|
||||
#include "exception.h"
|
||||
#include "static_assert.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
namespace etl
|
||||
{
|
||||
//***************************************************************************
|
||||
|
||||
@ -32,9 +32,6 @@ SOFTWARE.
|
||||
#define ETL_DEBOUNCE_INCLUDED
|
||||
|
||||
#include "platform.h"
|
||||
#include "static_assert.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace etl
|
||||
{
|
||||
|
||||
@ -34,9 +34,10 @@ SOFTWARE.
|
||||
#include "platform.h"
|
||||
#include "array.h"
|
||||
#include "delegate.h"
|
||||
#include "nullptr.h"
|
||||
#include "static_assert.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
namespace etl
|
||||
{
|
||||
//***************************************************************************
|
||||
|
||||
@ -44,7 +44,6 @@ SOFTWARE.
|
||||
#include "utility.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "private/minmax_push.h"
|
||||
|
||||
|
||||
@ -39,8 +39,6 @@ SOFTWARE.
|
||||
#include "type_traits.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
namespace etl
|
||||
{
|
||||
|
||||
@ -34,7 +34,6 @@ SOFTWARE.
|
||||
#include "platform.h"
|
||||
#include "frame_check_sequence.h"
|
||||
#include "ihash.h"
|
||||
#include "static_assert.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@ -76,17 +76,409 @@ namespace etl
|
||||
}
|
||||
};
|
||||
|
||||
template <class... Args>
|
||||
ETL_CONSTEXPR14 bool check_f(const char* fmt)
|
||||
#if ETL_USING_CPP20
|
||||
namespace private_format_check
|
||||
{
|
||||
// to be implemented later
|
||||
// return fmt[0] == 0; // actual check
|
||||
// Type category for compile-time type/specifier compatibility checking
|
||||
enum class type_category
|
||||
{
|
||||
NONE, // monostate
|
||||
BOOLEAN, // bool
|
||||
CHAR, // char
|
||||
INTEGER, // int, unsigned, long long, unsigned long long, short, etc.
|
||||
FLOAT, // float, double, long double
|
||||
STRING, // const char*, string_view
|
||||
POINTER // const void*
|
||||
};
|
||||
|
||||
// Map a type to its category. Decays and removes cv-qualifiers.
|
||||
template <class T>
|
||||
constexpr type_category get_type_category()
|
||||
{
|
||||
using U = typename etl::remove_cv<typename etl::remove_reference<T>::type>::type;
|
||||
|
||||
// Order matters: bool before integral, char before integral
|
||||
if (etl::is_same<U, bool>::value)
|
||||
return type_category::BOOLEAN;
|
||||
if (etl::is_same<U, char>::value)
|
||||
return type_category::CHAR;
|
||||
if (etl::is_same<U, signed char>::value)
|
||||
return type_category::CHAR;
|
||||
if (etl::is_same<U, unsigned char>::value)
|
||||
return type_category::CHAR;
|
||||
if (etl::is_integral<U>::value)
|
||||
return type_category::INTEGER;
|
||||
if (etl::is_same<U, float>::value)
|
||||
return type_category::FLOAT;
|
||||
if (etl::is_same<U, double>::value)
|
||||
return type_category::FLOAT;
|
||||
if (etl::is_same<U, long double>::value)
|
||||
return type_category::FLOAT;
|
||||
if (etl::is_same<U, const char*>::value)
|
||||
return type_category::STRING;
|
||||
if (etl::is_same<U, char*>::value)
|
||||
return type_category::STRING;
|
||||
if (etl::is_same<U, etl::string_view>::value)
|
||||
return type_category::STRING;
|
||||
if (etl::is_base_of<etl::istring, U>::value)
|
||||
return type_category::STRING;
|
||||
if (etl::is_pointer<U>::value)
|
||||
return type_category::POINTER;
|
||||
if (etl::is_same<U, const void*>::value)
|
||||
return type_category::POINTER;
|
||||
if (etl::is_same<U, void*>::value)
|
||||
return type_category::POINTER;
|
||||
return type_category::NONE; // unknown type: custom formatter, be permissive
|
||||
}
|
||||
|
||||
// Check if a format type character is valid for a given type category.
|
||||
// '\0' means no explicit type was specified (always valid — uses default presentation).
|
||||
inline constexpr bool ct_check_type_spec(type_category cat, char type_char)
|
||||
{
|
||||
if (type_char == '\0')
|
||||
{
|
||||
return true; // no explicit type: always OK, uses default
|
||||
}
|
||||
|
||||
switch (cat)
|
||||
{
|
||||
case type_category::BOOLEAN:
|
||||
// bool: s (as "true"/"false"), b, B, c, d, o, x, X (as integer 0/1)
|
||||
return type_char == 's' || type_char == 'b' || type_char == 'B' || type_char == 'c' || type_char == 'd' || type_char == 'o'
|
||||
|| type_char == 'x' || type_char == 'X';
|
||||
|
||||
case type_category::CHAR:
|
||||
// char: c (default), b, B, d, o, x, X (as integer), s, ?
|
||||
return type_char == 'c' || type_char == '?' || type_char == 'b' || type_char == 'B' || type_char == 'd' || type_char == 'o'
|
||||
|| type_char == 'x' || type_char == 'X' || type_char == 's';
|
||||
|
||||
case type_category::INTEGER:
|
||||
// integers: b, B, c, d, o, x, X
|
||||
return type_char == 'b' || type_char == 'B' || type_char == 'c' || type_char == 'd' || type_char == 'o' || type_char == 'x'
|
||||
|| type_char == 'X';
|
||||
|
||||
case type_category::FLOAT:
|
||||
// floats: a, A, e, E, f, F, g, G
|
||||
return type_char == 'a' || type_char == 'A' || type_char == 'e' || type_char == 'E' || type_char == 'f' || type_char == 'F'
|
||||
|| type_char == 'g' || type_char == 'G';
|
||||
|
||||
case type_category::STRING:
|
||||
// strings: s, ?
|
||||
return type_char == 's' || type_char == '?';
|
||||
|
||||
case type_category::POINTER:
|
||||
// pointers: p, P
|
||||
return type_char == 'p' || type_char == 'P';
|
||||
|
||||
case type_category::NONE:
|
||||
default: return true; // unknown/custom type: be permissive, let runtime handle it
|
||||
}
|
||||
}
|
||||
|
||||
inline constexpr bool ct_is_digit(char c)
|
||||
{
|
||||
return c >= '0' && c <= '9';
|
||||
}
|
||||
|
||||
// Parse an unsigned integer from fmt starting at pos. Updates pos past the digits.
|
||||
// Returns the parsed number, or -1 if no digits found, or -2 on overflow.
|
||||
inline constexpr int ct_parse_num(const char* fmt, int& pos)
|
||||
{
|
||||
if (!ct_is_digit(fmt[pos]))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
int result = 0;
|
||||
while (ct_is_digit(fmt[pos]))
|
||||
{
|
||||
int new_result = result * 10 + (fmt[pos] - '0');
|
||||
if (new_result < result)
|
||||
{
|
||||
// Overflow detected
|
||||
return -2;
|
||||
}
|
||||
result = new_result;
|
||||
++pos;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
inline constexpr bool ct_is_align(char c)
|
||||
{
|
||||
return c == '<' || c == '>' || c == '^';
|
||||
}
|
||||
|
||||
inline constexpr bool ct_is_sign(char c)
|
||||
{
|
||||
return c == '+' || c == '-' || c == ' ';
|
||||
}
|
||||
|
||||
inline constexpr bool ct_is_type(char c)
|
||||
{
|
||||
// All valid type characters from the format spec
|
||||
return (c == 's') || (c == '?') || (c == 'b') || (c == 'B') || (c == 'c') || (c == 'd') || (c == 'o') || (c == 'x') || (c == 'X') || (c == 'a')
|
||||
|| (c == 'A') || (c == 'e') || (c == 'E') || (c == 'f') || (c == 'F') || (c == 'g') || (c == 'G') || (c == 'p') || (c == 'P');
|
||||
}
|
||||
|
||||
// Validate a nested replacement field like {}, {0}, {1} inside width/precision.
|
||||
// pos should be at the '{'. Updates pos past the closing '}'.
|
||||
// Updates auto_count / has_manual / has_auto. Returns false on error.
|
||||
inline constexpr bool ct_parse_nested_replacement(const char* fmt, int& pos, int n_args, int& auto_count, bool& has_auto, bool& has_manual)
|
||||
{
|
||||
if (fmt[pos] != '{')
|
||||
return false;
|
||||
++pos; // skip '{'
|
||||
|
||||
int num = ct_parse_num(fmt, pos);
|
||||
if (num == -2)
|
||||
return false; // overflow
|
||||
if (num >= 0)
|
||||
{
|
||||
// manual index
|
||||
if (has_auto)
|
||||
return false; // mixing
|
||||
has_manual = true;
|
||||
if (num >= n_args)
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// automatic index
|
||||
if (has_manual)
|
||||
return false; // mixing
|
||||
has_auto = true;
|
||||
if (auto_count >= n_args)
|
||||
return false;
|
||||
++auto_count;
|
||||
}
|
||||
|
||||
if (fmt[pos] != '}')
|
||||
return false;
|
||||
++pos; // skip '}'
|
||||
return true;
|
||||
}
|
||||
|
||||
// Skip/validate the format-spec portion after the colon:
|
||||
// [[fill]align][sign][#][0][width][.precision][L][type]
|
||||
// pos is right after ':'. Returns false on invalid spec.
|
||||
// parsed_type is set to the type character found, or '\0' if none.
|
||||
inline constexpr bool ct_skip_format_spec(const char* fmt, int& pos, int n_args, int& auto_count, bool& has_auto, bool& has_manual,
|
||||
char& parsed_type, bool& parsed_has_precision)
|
||||
{
|
||||
parsed_type = '\0';
|
||||
parsed_has_precision = false;
|
||||
|
||||
if (fmt[pos] == '\0' || fmt[pos] == '}')
|
||||
{
|
||||
return true; // empty spec is valid
|
||||
}
|
||||
|
||||
// fill-and-align: either [align] or [fill][align]
|
||||
// Look ahead: if second char is an align char, first is fill
|
||||
if (fmt[pos + 1] != '\0' && ct_is_align(fmt[pos + 1]))
|
||||
{
|
||||
char fill = fmt[pos];
|
||||
if (fill == '{' || fill == '}')
|
||||
return false; // { and } not allowed as fill
|
||||
pos += 2; // skip fill + align
|
||||
}
|
||||
else if (ct_is_align(fmt[pos]))
|
||||
{
|
||||
++pos; // skip align only
|
||||
}
|
||||
|
||||
// sign
|
||||
if (ct_is_sign(fmt[pos]))
|
||||
{
|
||||
++pos;
|
||||
}
|
||||
|
||||
// '#'
|
||||
if (fmt[pos] == '#')
|
||||
{
|
||||
++pos;
|
||||
}
|
||||
|
||||
// '0'
|
||||
if (fmt[pos] == '0')
|
||||
{
|
||||
++pos;
|
||||
}
|
||||
|
||||
// width: number or nested replacement
|
||||
if (ct_is_digit(fmt[pos]))
|
||||
{
|
||||
if (ct_parse_num(fmt, pos) == -2)
|
||||
return false; // overflow
|
||||
}
|
||||
else if (fmt[pos] == '{')
|
||||
{
|
||||
if (!ct_parse_nested_replacement(fmt, pos, n_args, auto_count, has_auto, has_manual))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// precision: '.' followed by number or nested replacement
|
||||
bool has_precision = false;
|
||||
if (fmt[pos] == '.')
|
||||
{
|
||||
has_precision = true;
|
||||
++pos;
|
||||
if (ct_is_digit(fmt[pos]))
|
||||
{
|
||||
if (ct_parse_num(fmt, pos) == -2)
|
||||
return false; // overflow
|
||||
}
|
||||
else if (fmt[pos] == '{')
|
||||
{
|
||||
if (!ct_parse_nested_replacement(fmt, pos, n_args, auto_count, has_auto, has_manual))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// else: '.' with no precision number/replacement — still valid (empty precision)
|
||||
}
|
||||
|
||||
// locale-specific: 'L'
|
||||
if (fmt[pos] == 'L')
|
||||
{
|
||||
++pos;
|
||||
}
|
||||
|
||||
// type
|
||||
if (ct_is_type(fmt[pos]))
|
||||
{
|
||||
parsed_type = fmt[pos];
|
||||
++pos;
|
||||
}
|
||||
|
||||
// After parsing the spec, we must be at '}' (the closing brace is consumed by the caller)
|
||||
// Any remaining characters before '}' means invalid spec
|
||||
if (fmt[pos] != '}')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
parsed_has_precision = has_precision;
|
||||
|
||||
return true;
|
||||
}
|
||||
} // namespace private_format_check
|
||||
|
||||
template <class... Args>
|
||||
constexpr bool check_format(const char* fmt)
|
||||
{
|
||||
const int n_args = static_cast<int>(sizeof...(Args));
|
||||
int pos = 0;
|
||||
int auto_count = 0;
|
||||
bool has_auto = false;
|
||||
bool has_manual = false;
|
||||
|
||||
// Build a constexpr array mapping arg index -> type category
|
||||
const private_format_check::type_category arg_categories[] = {
|
||||
private_format_check::get_type_category<Args>()...,
|
||||
private_format_check::type_category::NONE // sentinel for zero-arg case
|
||||
};
|
||||
|
||||
while (fmt[pos] != '\0')
|
||||
{
|
||||
char c = fmt[pos];
|
||||
++pos;
|
||||
|
||||
if (c == '{')
|
||||
{
|
||||
if (fmt[pos] == '{')
|
||||
{
|
||||
// escaped '{'
|
||||
++pos;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Start of a replacement field: [arg_id][:format_spec]
|
||||
int resolved_index = -1;
|
||||
int arg_index = private_format_check::ct_parse_num(fmt, pos);
|
||||
if (arg_index == -2)
|
||||
return false; // overflow in arg index
|
||||
if (arg_index >= 0)
|
||||
{
|
||||
// manual index
|
||||
if (has_auto)
|
||||
return false; // mixing auto and manual
|
||||
has_manual = true;
|
||||
if (arg_index >= n_args)
|
||||
return false; // index out of range
|
||||
resolved_index = arg_index;
|
||||
}
|
||||
else
|
||||
{
|
||||
// automatic index
|
||||
if (has_manual)
|
||||
return false; // mixing auto and manual
|
||||
has_auto = true;
|
||||
if (auto_count >= n_args)
|
||||
return false; // too many arguments
|
||||
resolved_index = auto_count;
|
||||
++auto_count;
|
||||
}
|
||||
|
||||
char type_char = '\0';
|
||||
bool has_precision = false;
|
||||
if (fmt[pos] == ':')
|
||||
{
|
||||
++pos; // skip ':'
|
||||
if (!private_format_check::ct_skip_format_spec(fmt, pos, n_args, auto_count, has_auto, has_manual, type_char, has_precision))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Validate type specifier against argument type
|
||||
if (resolved_index >= 0 && resolved_index < n_args)
|
||||
{
|
||||
if (!private_format_check::ct_check_type_spec(arg_categories[resolved_index], type_char))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Precision is not allowed for integer, boolean, or pointer types
|
||||
if (has_precision)
|
||||
{
|
||||
auto cat = arg_categories[resolved_index];
|
||||
if (cat == private_format_check::type_category::INTEGER || cat == private_format_check::type_category::BOOLEAN
|
||||
|| cat == private_format_check::type_category::POINTER)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// Precision is also invalid for char when presented as char (not as integer)
|
||||
if (cat == private_format_check::type_category::CHAR && (type_char == '\0' || type_char == 'c' || type_char == '?'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (fmt[pos] != '}')
|
||||
{
|
||||
return false; // missing closing brace
|
||||
}
|
||||
++pos; // skip '}'
|
||||
}
|
||||
else if (c == '}')
|
||||
{
|
||||
if (fmt[pos] != '}')
|
||||
{
|
||||
return false; // unmatched '}'
|
||||
}
|
||||
++pos; // skip second '}'
|
||||
}
|
||||
}
|
||||
|
||||
(void)fmt;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline void please_note_this_is_error_message_1() noexcept {}
|
||||
inline void please_note_this_is_error_message_format_string_syntax_error() noexcept {}
|
||||
#endif // ETL_USING_CPP20
|
||||
|
||||
template <class... Args>
|
||||
struct basic_format_string
|
||||
@ -94,20 +486,15 @@ namespace etl
|
||||
inline ETL_CONSTEVAL basic_format_string(const char* fmt)
|
||||
: _sv(fmt)
|
||||
{
|
||||
bool format_string_ok = check_f(fmt);
|
||||
|
||||
if (!format_string_ok)
|
||||
#if ETL_USING_CPP20
|
||||
// Compile-time validation: check_format runs at compile time via consteval.
|
||||
// In pre-C++20, runtime checks in vformat_to/parse_format_spec/etc. are sufficient.
|
||||
if (!check_format<Args...>(fmt))
|
||||
{
|
||||
// if (etl::is_constant_evaluated()) // compile time error path
|
||||
//{
|
||||
// // calling a non-constexpr function in a consteval context to
|
||||
// trigger a compile error please_note_this_is_error_message_1();
|
||||
// }
|
||||
// else // run time error path
|
||||
//{
|
||||
ETL_ASSERT_FAIL_AND_RETURN(ETL_ERROR(bad_format_string_exception));
|
||||
//}
|
||||
// Calling a non-constexpr function in a consteval context triggers a compile error.
|
||||
please_note_this_is_error_message_format_string_syntax_error();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
ETL_CONSTEXPR basic_format_string(const basic_format_string& other) = default;
|
||||
@ -181,7 +568,6 @@ namespace etl
|
||||
// automatic number generation only allowed if not already in manual mode
|
||||
ETL_ASSERT(manual_mode == false, ETL_ERROR(bad_format_string_exception));
|
||||
automatic_mode = true;
|
||||
// TODO: compile time check
|
||||
ETL_ASSERT(current < num_args, ETL_ERROR(bad_format_string_exception) /* not enough arguments for generated index */);
|
||||
return current++;
|
||||
}
|
||||
@ -598,18 +984,6 @@ namespace etl
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool parse_sequence(format_parse_context& parse_ctx, etl::string_view sequence)
|
||||
{
|
||||
auto fmt_it = parse_ctx.begin();
|
||||
if (etl::equal(sequence.cbegin(), sequence.cend(), fmt_it))
|
||||
{
|
||||
fmt_it += sequence.size();
|
||||
parse_ctx.advance_to(fmt_it);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool is_align_character(char c)
|
||||
{
|
||||
return c == '<' || c == '>' || c == '^';
|
||||
@ -1459,6 +1833,40 @@ namespace etl
|
||||
fmt_context.advance_to(tmp);
|
||||
}
|
||||
|
||||
// Compute prefix/suffix padding sizes for alignment.
|
||||
// default_align_start: if true, NONE defaults to left-align (START); otherwise right-align (END).
|
||||
inline void compute_padding(size_t pad, spec_align_t align, bool default_align_start, size_t& prefix_size, size_t& suffix_size)
|
||||
{
|
||||
switch (align)
|
||||
{
|
||||
case spec_align_t::START:
|
||||
prefix_size = 0;
|
||||
suffix_size = pad;
|
||||
break;
|
||||
case spec_align_t::CENTER:
|
||||
prefix_size = pad / 2;
|
||||
suffix_size = pad - prefix_size;
|
||||
break;
|
||||
case spec_align_t::END:
|
||||
prefix_size = pad;
|
||||
suffix_size = 0;
|
||||
break;
|
||||
case spec_align_t::NONE:
|
||||
default:
|
||||
if (default_align_start)
|
||||
{
|
||||
prefix_size = 0;
|
||||
suffix_size = pad;
|
||||
}
|
||||
else
|
||||
{
|
||||
prefix_size = pad;
|
||||
suffix_size = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename OutputIt, typename Int>
|
||||
typename format_context<OutputIt>::iterator format_aligned_int(Int arg, format_context<OutputIt>& fmt_ctx)
|
||||
{
|
||||
@ -1467,32 +1875,13 @@ namespace etl
|
||||
|
||||
if (fmt_ctx.format_spec.width)
|
||||
{
|
||||
// calculate size
|
||||
private_format::counter_iterator counter;
|
||||
private_format::format_num<private_format::counter_iterator, Int>(counter, arg, fmt_ctx.format_spec);
|
||||
|
||||
if (counter.value() < fmt_ctx.format_spec.width.value())
|
||||
{
|
||||
size_t pad = fmt_ctx.format_spec.width.value() - counter.value();
|
||||
switch (fmt_ctx.format_spec.align)
|
||||
{
|
||||
case private_format::spec_align_t::START:
|
||||
prefix_size = 0;
|
||||
suffix_size = pad;
|
||||
break;
|
||||
case private_format::spec_align_t::CENTER:
|
||||
prefix_size = pad / 2;
|
||||
suffix_size = pad - prefix_size;
|
||||
break;
|
||||
case private_format::spec_align_t::NONE: // default
|
||||
case private_format::spec_align_t::END:
|
||||
prefix_size = pad;
|
||||
suffix_size = 0;
|
||||
break;
|
||||
default:
|
||||
// invalid alignment specification
|
||||
ETL_ASSERT_FAIL(ETL_ERROR(bad_format_string_exception));
|
||||
}
|
||||
compute_padding(pad, fmt_ctx.format_spec.align, false, prefix_size, suffix_size);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1513,32 +1902,13 @@ namespace etl
|
||||
|
||||
if (fmt_ctx.format_spec.width)
|
||||
{
|
||||
// calculate size
|
||||
private_format::counter_iterator counter;
|
||||
private_format::format_floating<private_format::counter_iterator, Float>(counter, arg, fmt_ctx.format_spec);
|
||||
|
||||
if (counter.value() < fmt_ctx.format_spec.width.value())
|
||||
{
|
||||
size_t pad = fmt_ctx.format_spec.width.value() - counter.value();
|
||||
switch (fmt_ctx.format_spec.align)
|
||||
{
|
||||
case private_format::spec_align_t::START:
|
||||
prefix_size = 0;
|
||||
suffix_size = pad;
|
||||
break;
|
||||
case private_format::spec_align_t::CENTER:
|
||||
prefix_size = pad / 2;
|
||||
suffix_size = pad - prefix_size;
|
||||
break;
|
||||
case private_format::spec_align_t::NONE: // default
|
||||
case private_format::spec_align_t::END:
|
||||
prefix_size = pad;
|
||||
suffix_size = 0;
|
||||
break;
|
||||
default:
|
||||
// invalid alignment specification
|
||||
ETL_ASSERT_FAIL(ETL_ERROR(bad_format_string_exception));
|
||||
}
|
||||
compute_padding(pad, fmt_ctx.format_spec.align, false, prefix_size, suffix_size);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1609,32 +1979,13 @@ namespace etl
|
||||
|
||||
if (fmt_ctx.format_spec.width)
|
||||
{
|
||||
// calculate size
|
||||
private_format::counter_iterator counter;
|
||||
private_format::format_string_view<private_format::counter_iterator>(counter, arg, fmt_ctx.format_spec);
|
||||
|
||||
if (counter.value() < fmt_ctx.format_spec.width.value())
|
||||
{
|
||||
size_t pad = fmt_ctx.format_spec.width.value() - counter.value();
|
||||
switch (fmt_ctx.format_spec.align)
|
||||
{
|
||||
case private_format::spec_align_t::NONE: // default
|
||||
case private_format::spec_align_t::START:
|
||||
prefix_size = 0;
|
||||
suffix_size = pad;
|
||||
break;
|
||||
case private_format::spec_align_t::CENTER:
|
||||
prefix_size = pad / 2;
|
||||
suffix_size = pad - prefix_size;
|
||||
break;
|
||||
case private_format::spec_align_t::END:
|
||||
prefix_size = pad;
|
||||
suffix_size = 0;
|
||||
break;
|
||||
default:
|
||||
// invalid alignment specification
|
||||
ETL_ASSERT_FAIL(ETL_ERROR(bad_format_string_exception));
|
||||
}
|
||||
compute_padding(pad, fmt_ctx.format_spec.align, true, prefix_size, suffix_size);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1646,99 +1997,10 @@ namespace etl
|
||||
return it;
|
||||
}
|
||||
|
||||
template <typename OutputIt>
|
||||
void format_chars(OutputIt& it, const char* arg, const format_spec_t& spec)
|
||||
{
|
||||
bool escaped = false;
|
||||
if (spec.type.has_value())
|
||||
{
|
||||
switch (spec.type.value())
|
||||
{
|
||||
case 's':
|
||||
// default output
|
||||
break;
|
||||
case '?':
|
||||
// escaped string
|
||||
escaped = true;
|
||||
break;
|
||||
default:
|
||||
// invalid type for string
|
||||
ETL_ASSERT_FAIL(ETL_ERROR(bad_format_string_exception));
|
||||
}
|
||||
}
|
||||
size_t limit = etl::numeric_limits<size_t>::max();
|
||||
if (spec.precision.has_value())
|
||||
{
|
||||
limit = spec.precision.value();
|
||||
}
|
||||
|
||||
if (escaped)
|
||||
{
|
||||
format_plain_char(it, '"');
|
||||
}
|
||||
const char_type* arg_it = arg;
|
||||
while (*arg_it != '\0' && limit > 0)
|
||||
{
|
||||
if (escaped)
|
||||
{
|
||||
format_escaped_char(it, *arg_it);
|
||||
}
|
||||
else
|
||||
{
|
||||
format_plain_char(it, *arg_it);
|
||||
}
|
||||
++arg_it;
|
||||
--limit;
|
||||
}
|
||||
if (escaped)
|
||||
{
|
||||
format_plain_char(it, '"');
|
||||
}
|
||||
}
|
||||
|
||||
template <typename OutputIt>
|
||||
typename format_context<OutputIt>::iterator format_aligned_chars(const char* arg, format_context<OutputIt>& fmt_ctx)
|
||||
{
|
||||
size_t prefix_size = 0;
|
||||
size_t suffix_size = 0;
|
||||
|
||||
if (fmt_ctx.format_spec.width)
|
||||
{
|
||||
// calculate size
|
||||
private_format::counter_iterator counter;
|
||||
private_format::format_chars<private_format::counter_iterator>(counter, arg, fmt_ctx.format_spec);
|
||||
|
||||
if (counter.value() < fmt_ctx.format_spec.width.value())
|
||||
{
|
||||
size_t pad = fmt_ctx.format_spec.width.value() - counter.value();
|
||||
switch (fmt_ctx.format_spec.align)
|
||||
{
|
||||
case private_format::spec_align_t::NONE: // default
|
||||
case private_format::spec_align_t::START:
|
||||
prefix_size = 0;
|
||||
suffix_size = pad;
|
||||
break;
|
||||
case private_format::spec_align_t::CENTER:
|
||||
prefix_size = pad / 2;
|
||||
suffix_size = pad - prefix_size;
|
||||
break;
|
||||
case private_format::spec_align_t::END:
|
||||
prefix_size = pad;
|
||||
suffix_size = 0;
|
||||
break;
|
||||
default:
|
||||
// invalid alignment specification
|
||||
ETL_ASSERT_FAIL(ETL_ERROR(bad_format_string_exception));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// actual output
|
||||
OutputIt it = fmt_ctx.out();
|
||||
private_format::fill<OutputIt>(it, prefix_size, fmt_ctx.format_spec.fill);
|
||||
private_format::format_chars<OutputIt>(it, arg, fmt_ctx.format_spec);
|
||||
private_format::fill<OutputIt>(it, suffix_size, fmt_ctx.format_spec.fill);
|
||||
return it;
|
||||
return format_aligned_string_view<OutputIt>(etl::string_view(arg), fmt_ctx);
|
||||
}
|
||||
|
||||
inline void check_char_spec(const format_spec_t& spec)
|
||||
@ -1793,43 +2055,16 @@ namespace etl
|
||||
|
||||
if (fmt_ctx.format_spec.width)
|
||||
{
|
||||
// calculate size
|
||||
private_format::counter_iterator counter;
|
||||
private_format::format_char<private_format::counter_iterator>(counter, arg, fmt_ctx.format_spec);
|
||||
|
||||
if (counter.value() < fmt_ctx.format_spec.width.value())
|
||||
{
|
||||
size_t pad = fmt_ctx.format_spec.width.value() - counter.value();
|
||||
switch (fmt_ctx.format_spec.align)
|
||||
{
|
||||
case private_format::spec_align_t::NONE: // default
|
||||
if (!fmt_ctx.format_spec.type.has_value() || fmt_ctx.format_spec.type.value() == 'c' || fmt_ctx.format_spec.type.value() == '?')
|
||||
{
|
||||
prefix_size = 0;
|
||||
suffix_size = pad;
|
||||
}
|
||||
else
|
||||
{
|
||||
prefix_size = pad;
|
||||
suffix_size = 0;
|
||||
}
|
||||
break;
|
||||
case private_format::spec_align_t::START:
|
||||
prefix_size = 0;
|
||||
suffix_size = pad;
|
||||
break;
|
||||
case private_format::spec_align_t::CENTER:
|
||||
prefix_size = pad / 2;
|
||||
suffix_size = pad - prefix_size;
|
||||
break;
|
||||
case private_format::spec_align_t::END:
|
||||
prefix_size = pad;
|
||||
suffix_size = 0;
|
||||
break;
|
||||
default:
|
||||
// invalid alignment specification
|
||||
ETL_ASSERT_FAIL(ETL_ERROR(bad_format_string_exception));
|
||||
}
|
||||
// char type defaults to left-align, integer presentation defaults to right-align
|
||||
bool default_start =
|
||||
!fmt_ctx.format_spec.type.has_value() || fmt_ctx.format_spec.type.value() == 'c' || fmt_ctx.format_spec.type.value() == '?';
|
||||
compute_padding(pad, fmt_ctx.format_spec.align, default_start, prefix_size, suffix_size);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1877,32 +2112,13 @@ namespace etl
|
||||
|
||||
if (fmt_ctx.format_spec.width)
|
||||
{
|
||||
// calculate size
|
||||
private_format::counter_iterator counter;
|
||||
private_format::format_bool<private_format::counter_iterator>(counter, arg, fmt_ctx.format_spec);
|
||||
|
||||
if (counter.value() < fmt_ctx.format_spec.width.value())
|
||||
{
|
||||
size_t pad = fmt_ctx.format_spec.width.value() - counter.value();
|
||||
switch (fmt_ctx.format_spec.align)
|
||||
{
|
||||
case private_format::spec_align_t::START:
|
||||
prefix_size = 0;
|
||||
suffix_size = pad;
|
||||
break;
|
||||
case private_format::spec_align_t::CENTER:
|
||||
prefix_size = pad / 2;
|
||||
suffix_size = pad - prefix_size;
|
||||
break;
|
||||
case private_format::spec_align_t::NONE: // default
|
||||
case private_format::spec_align_t::END:
|
||||
prefix_size = pad;
|
||||
suffix_size = 0;
|
||||
break;
|
||||
default:
|
||||
// invalid alignment specification
|
||||
ETL_ASSERT_FAIL(ETL_ERROR(bad_format_string_exception));
|
||||
}
|
||||
compute_padding(pad, fmt_ctx.format_spec.align, false, prefix_size, suffix_size);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1946,32 +2162,13 @@ namespace etl
|
||||
|
||||
if (fmt_ctx.format_spec.width)
|
||||
{
|
||||
// calculate size
|
||||
private_format::counter_iterator counter;
|
||||
private_format::format_pointer<private_format::counter_iterator>(counter, arg, fmt_ctx.format_spec);
|
||||
|
||||
if (counter.value() < fmt_ctx.format_spec.width.value())
|
||||
{
|
||||
size_t pad = fmt_ctx.format_spec.width.value() - counter.value();
|
||||
switch (fmt_ctx.format_spec.align)
|
||||
{
|
||||
case private_format::spec_align_t::START:
|
||||
prefix_size = 0;
|
||||
suffix_size = pad;
|
||||
break;
|
||||
case private_format::spec_align_t::CENTER:
|
||||
prefix_size = pad / 2;
|
||||
suffix_size = pad - prefix_size;
|
||||
break;
|
||||
case private_format::spec_align_t::NONE: // default
|
||||
case private_format::spec_align_t::END:
|
||||
prefix_size = pad;
|
||||
suffix_size = 0;
|
||||
break;
|
||||
default:
|
||||
// invalid alignment specification
|
||||
ETL_ASSERT_FAIL(ETL_ERROR(bad_format_string_exception));
|
||||
}
|
||||
compute_padding(pad, fmt_ctx.format_spec.align, false, prefix_size, suffix_size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -36,7 +36,6 @@ SOFTWARE.
|
||||
#include "type_traits.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace etl
|
||||
{
|
||||
|
||||
@ -36,8 +36,6 @@ SOFTWARE.
|
||||
#include "exception.h"
|
||||
#include "utility.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
///\defgroup ihash Common data for all hash type classes.
|
||||
///\ingroup hash
|
||||
|
||||
|
||||
@ -31,7 +31,8 @@ SOFTWARE.
|
||||
|
||||
#include "platform.h"
|
||||
#include "integral_limits.h"
|
||||
#include "static_assert.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
namespace etl
|
||||
{
|
||||
|
||||
@ -35,7 +35,6 @@ SOFTWARE.
|
||||
#include "type_traits.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "private/minmax_push.h"
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ SOFTWARE.
|
||||
#include "type_traits.h"
|
||||
#include "utility.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
|
||||
//*****************************************************************************
|
||||
// Note:
|
||||
|
||||
@ -35,8 +35,6 @@ SOFTWARE.
|
||||
#include "functional.h"
|
||||
#include "limits.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace etl
|
||||
{
|
||||
//***************************************************************************
|
||||
|
||||
@ -37,9 +37,10 @@ SOFTWARE.
|
||||
#include "iterator.h"
|
||||
#include "memory.h"
|
||||
#include "placement_new.h"
|
||||
#include "static_assert.h"
|
||||
#include "utility.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#define ETL_POOL_CPP03_CODE 0
|
||||
|
||||
namespace etl
|
||||
|
||||
@ -36,7 +36,6 @@ SOFTWARE.
|
||||
#include "frame_check_sequence.h"
|
||||
#include "ihash.h"
|
||||
#include "iterator.h"
|
||||
#include "static_assert.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@ -36,8 +36,6 @@ SOFTWARE.
|
||||
#include "functional.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace etl
|
||||
{
|
||||
namespace private_limiter
|
||||
|
||||
@ -43,7 +43,6 @@ SOFTWARE.
|
||||
#include <float.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "private/minmax_push.h"
|
||||
|
||||
|
||||
@ -42,7 +42,6 @@ SOFTWARE.
|
||||
|
||||
#include "private/addressof.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(ETL_IN_UNIT_TEST) || ETL_USING_STL
|
||||
|
||||
@ -36,8 +36,6 @@ SOFTWARE.
|
||||
#include "static_assert.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace etl
|
||||
{
|
||||
//***************************************************************************
|
||||
|
||||
@ -36,8 +36,6 @@ SOFTWARE.
|
||||
#include "nullptr.h"
|
||||
#include "span.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace etl
|
||||
{
|
||||
//***************************************************************************
|
||||
|
||||
@ -36,10 +36,9 @@ SOFTWARE.
|
||||
#include "message.h"
|
||||
#include "message_router.h"
|
||||
#include "message_types.h"
|
||||
#include "nullptr.h"
|
||||
#include "vector.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
namespace etl
|
||||
{
|
||||
|
||||
@ -39,8 +39,6 @@ SOFTWARE.
|
||||
#include "type_list.h"
|
||||
#include "utility.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace etl
|
||||
{
|
||||
#if ETL_USING_CPP17 && !defined(ETL_MESSAGE_PACKET_FORCE_CPP03_IMPLEMENTATION)
|
||||
|
||||
@ -38,14 +38,12 @@ SOFTWARE.
|
||||
#include "message.h"
|
||||
#include "message_packet.h"
|
||||
#include "message_types.h"
|
||||
#include "nullptr.h"
|
||||
#include "placement_new.h"
|
||||
#include "shared_message.h"
|
||||
#include "successor.h"
|
||||
#include "type_list.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
namespace etl
|
||||
{
|
||||
|
||||
@ -38,7 +38,7 @@ SOFTWARE.
|
||||
#include "memory.h"
|
||||
#include "message_router.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
namespace etl
|
||||
{
|
||||
|
||||
@ -35,7 +35,6 @@ SOFTWARE.
|
||||
#include "error_handler.h"
|
||||
#include "exception.h"
|
||||
#include "memory.h"
|
||||
#include "static_assert.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
namespace etl
|
||||
|
||||
@ -32,7 +32,7 @@ SOFTWARE.
|
||||
#include "platform.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#if ETL_CPP11_SUPPORTED
|
||||
namespace etl
|
||||
|
||||
@ -566,6 +566,14 @@ namespace etl
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 bool is_valid() const ETL_NOEXCEPT
|
||||
{
|
||||
// GCC's UBSan instruments function pointer comparisons, which prevents
|
||||
// constexpr evaluation. Use implicit bool conversion at compile time
|
||||
// to avoid the instrumented != comparison while still checking validity.
|
||||
if (etl::is_constant_evaluated())
|
||||
{
|
||||
return static_cast<bool>(invocation.stub);
|
||||
}
|
||||
|
||||
return invocation.stub != ETL_NULLPTR;
|
||||
}
|
||||
|
||||
|
||||
@ -35,8 +35,9 @@ SOFTWARE.
|
||||
#include "functional.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
////#include <math.h>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace etl
|
||||
{
|
||||
|
||||
@ -44,7 +44,6 @@ SOFTWARE.
|
||||
#include "utility.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
//*****************************************************************************
|
||||
///\defgroup queue queue
|
||||
|
||||
@ -32,7 +32,6 @@ SOFTWARE.
|
||||
#define ETL_QUEUE_LOCKABLE_INCLUDED
|
||||
|
||||
#include "platform.h"
|
||||
#include "function.h"
|
||||
#include "integral_limits.h"
|
||||
#include "memory.h"
|
||||
#include "memory_model.h"
|
||||
@ -42,7 +41,6 @@ SOFTWARE.
|
||||
#include "utility.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace etl
|
||||
{
|
||||
|
||||
@ -41,7 +41,6 @@ SOFTWARE.
|
||||
#include "utility.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#if ETL_HAS_ATOMIC
|
||||
|
||||
|
||||
@ -41,7 +41,6 @@ SOFTWARE.
|
||||
#include "utility.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace etl
|
||||
{
|
||||
|
||||
@ -42,7 +42,6 @@ SOFTWARE.
|
||||
#include "utility.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace etl
|
||||
{
|
||||
|
||||
@ -37,7 +37,6 @@ SOFTWARE.
|
||||
|
||||
#include "type_traits.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
///\defgroup ratio ratio
|
||||
|
||||
@ -37,7 +37,6 @@ SOFTWARE.
|
||||
#include "type_traits.h"
|
||||
|
||||
// #include <math.h>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace etl
|
||||
{
|
||||
|
||||
@ -33,7 +33,6 @@ SOFTWARE.
|
||||
|
||||
#include "platform.h"
|
||||
#include "absolute.h"
|
||||
#include "static_assert.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
namespace etl
|
||||
|
||||
@ -44,7 +44,6 @@ SOFTWARE.
|
||||
#include "utility.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
//*****************************************************************************
|
||||
///\defgroup stack stack
|
||||
|
||||
@ -39,7 +39,7 @@ SOFTWARE.
|
||||
#include "optional.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "private/minmax_push.h"
|
||||
|
||||
|
||||
@ -36,7 +36,6 @@ SOFTWARE.
|
||||
#include "type_traits.h"
|
||||
|
||||
// #include <math.h>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace etl
|
||||
{
|
||||
|
||||
@ -32,10 +32,10 @@ SOFTWARE.
|
||||
#include "platform.h"
|
||||
#include "integral_limits.h"
|
||||
#include "null_type.h"
|
||||
#include "static_assert.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
|
||||
namespace etl
|
||||
{
|
||||
//***************************************************************************
|
||||
|
||||
@ -31,8 +31,10 @@ SOFTWARE.
|
||||
|
||||
#include "platform.h"
|
||||
#include "null_type.h"
|
||||
#include "static_assert.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
namespace etl
|
||||
{
|
||||
#if ETL_USING_CPP11 && !defined(ETL_TYPE_SELECT_FORCE_CPP03_IMPLEMENTATION)
|
||||
|
||||
@ -43,7 +43,6 @@ SOFTWARE.
|
||||
#include "intrusive_forward_list.h"
|
||||
#include "iterator.h"
|
||||
#include "nth_type.h"
|
||||
#include "nullptr.h"
|
||||
#include "parameter_type.h"
|
||||
#include "placement_new.h"
|
||||
#include "pool.h"
|
||||
|
||||
@ -42,7 +42,6 @@ SOFTWARE.
|
||||
#include "intrusive_forward_list.h"
|
||||
#include "iterator.h"
|
||||
#include "nth_type.h"
|
||||
#include "nullptr.h"
|
||||
#include "parameter_type.h"
|
||||
#include "placement_new.h"
|
||||
#include "pool.h"
|
||||
|
||||
@ -42,7 +42,6 @@ SOFTWARE.
|
||||
#include "intrusive_forward_list.h"
|
||||
#include "iterator.h"
|
||||
#include "nth_type.h"
|
||||
#include "nullptr.h"
|
||||
#include "parameter_type.h"
|
||||
#include "placement_new.h"
|
||||
#include "pool.h"
|
||||
|
||||
@ -42,7 +42,6 @@ SOFTWARE.
|
||||
#include "intrusive_forward_list.h"
|
||||
#include "iterator.h"
|
||||
#include "nth_type.h"
|
||||
#include "nullptr.h"
|
||||
#include "parameter_type.h"
|
||||
#include "placement_new.h"
|
||||
#include "pool.h"
|
||||
|
||||
@ -35,7 +35,7 @@ SOFTWARE.
|
||||
#include "static_assert.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
namespace etl
|
||||
{
|
||||
|
||||
@ -40,7 +40,6 @@ SOFTWARE.
|
||||
#include "debug_count.h"
|
||||
#include "error_handler.h"
|
||||
#include "exception.h"
|
||||
#include "functional.h"
|
||||
#include "initializer_list.h"
|
||||
#include "iterator.h"
|
||||
#include "memory.h"
|
||||
|
||||
@ -1 +1,2 @@
|
||||
option('use_stl', description: 'Compiling for STL', type: 'boolean', value: true)
|
||||
option('enable_sanitizer', description: 'Enable address and undefined behavior sanitizers', type: 'boolean', value: false)
|
||||
|
||||
162
test/meson.build
162
test/meson.build
@ -1,4 +1,3 @@
|
||||
|
||||
etl_test_sources = files(
|
||||
'main.cpp',
|
||||
'murmurhash3.cpp',
|
||||
@ -8,48 +7,91 @@ etl_test_sources = files(
|
||||
'test_array_view.cpp',
|
||||
'test_array_wrapper.cpp',
|
||||
'test_atomic.cpp',
|
||||
'test_base64_RFC2152_decoder.cppp',
|
||||
'test_base64_RFC2152_encoder.cppp',
|
||||
'test_base64_RFC3501_decoder.cppp',
|
||||
'test_base64_RFC3501_encoder.cppp',
|
||||
'test_base64_RFC4648_decoder_with_no_padding.cppp',
|
||||
'test_base64_RFC4648_decoder_with_padding.cppp',
|
||||
'test_base64_RFC4648_encoder_with_no_padding.cppp',
|
||||
'test_base64_RFC4648_encoder_with_padding.cppp',
|
||||
'test_base64_RFC4648_URL_decoder_with_no_padding.cppp',
|
||||
'test_base64_RFC4648_URL_decoder_with_padding.cppp',
|
||||
'test_base64_RFC4648_URL_encoder_with_no_padding.cppp',
|
||||
'test_base64_RFC2152_decoder.cpp',
|
||||
'test_base64_RFC2152_encoder.cpp',
|
||||
'test_base64_RFC3501_decoder.cpp',
|
||||
'test_base64_RFC3501_encoder.cpp',
|
||||
'test_base64_RFC4648_URL_decoder_with_no_padding.cpp',
|
||||
'test_base64_RFC4648_URL_decoder_with_padding.cpp',
|
||||
'test_base64_RFC4648_URL_encoder_with_no_padding.cpp',
|
||||
'test_base64_RFC4648_URL_encoder_with_padding.cpp',
|
||||
'test_base64_RFC4648_decoder_with_no_padding.cpp',
|
||||
'test_base64_RFC4648_decoder_with_padding.cpp',
|
||||
'test_base64_RFC4648_encoder_with_no_padding.cpp',
|
||||
'test_base64_RFC4648_encoder_with_padding.cpp',
|
||||
'test_binary.cpp',
|
||||
'test_bip_buffer_spsc_atomic.cpp',
|
||||
'test_bit.cpp',
|
||||
'test_bitset_legacy.cpp',
|
||||
'test_bitset_new_default_element_type.cpp',
|
||||
'test_bitset_new_explicit_single_element_type.cpp',
|
||||
'test_bitset_new_ext_default_element_type.cpp',
|
||||
'test_bitset_new_ext_explicit_single_element_type.cpp',
|
||||
'test_bit_stream.cpp',
|
||||
'test_bit_stream_reader_big_endian.cpp',
|
||||
'test_bit_stream_reader_little_endian.cpp',
|
||||
'test_bit_stream_writer_big_endian.cpp',
|
||||
'test_bit_stream_writer_little_endian.cpp',
|
||||
'test_byte.cpp',
|
||||
'test_byte_stream.cpp',
|
||||
'test_bitset_legacy.cpp',
|
||||
'test_bitset_new_comparisons.cpp',
|
||||
'test_bitset_new_default_element_type.cpp',
|
||||
'test_bitset_new_explicit_single_element_type.cpp',
|
||||
'test_bitset_new_ext_default_element_type.cpp',
|
||||
'test_bitset_new_ext_explicit_single_element_type.cpp',
|
||||
'test_bloom_filter.cpp',
|
||||
'test_bresenham_line.cpp',
|
||||
'test_bsd_checksum.cpp',
|
||||
'test_buffer_descriptors.cpp',
|
||||
'test_byte.cpp',
|
||||
'test_byte_stream.cpp',
|
||||
'test_callback_service.cpp',
|
||||
'test_callback_timer.cpp',
|
||||
'test_callback_timer_atomic.cpp',
|
||||
'test_callback_timer_deferred_locked.cpp',
|
||||
'test_callback_timer_interrupt.cpp',
|
||||
'test_callback_timer_locked.cpp',
|
||||
'test_char_traits.cpp',
|
||||
'test_checksum.cpp',
|
||||
'test_chrono_clocks.cpp',
|
||||
'test_chrono_day.cpp',
|
||||
'test_chrono_duration.cpp',
|
||||
'test_chrono_hh_mm_ss.cpp',
|
||||
'test_chrono_literals.cpp',
|
||||
'test_chrono_month.cpp',
|
||||
'test_chrono_month_day.cpp',
|
||||
'test_chrono_month_day_last.cpp',
|
||||
'test_chrono_month_weekday.cpp',
|
||||
'test_chrono_month_weekday_last.cpp',
|
||||
'test_chrono_operators.cpp',
|
||||
'test_chrono_time_point.cpp',
|
||||
'test_chrono_weekday.cpp',
|
||||
'test_chrono_weekday_indexed.cpp',
|
||||
'test_chrono_weekday_last.cpp',
|
||||
'test_chrono_year.cpp',
|
||||
'test_chrono_year_month.cpp',
|
||||
'test_chrono_year_month_day.cpp',
|
||||
'test_chrono_year_month_day_last.cpp',
|
||||
'test_chrono_year_month_weekday.cpp',
|
||||
'test_chrono_year_month_weekday_last.cpp',
|
||||
'test_circular_buffer.cpp',
|
||||
'test_circular_buffer_external_buffer.cpp',
|
||||
'test_circular_iterator.cpp',
|
||||
'test_closure_with_default_delegate.cpp',
|
||||
'test_closure_with_default_delegate_constexpr.cpp',
|
||||
'test_closure_with_inplace_function.cpp',
|
||||
'test_compare.cpp',
|
||||
'test_compiler_settings.cpp',
|
||||
'test_concepts.cpp',
|
||||
'test_const_map.cpp',
|
||||
'test_const_map_constexpr.cpp',
|
||||
'test_const_map_ext.cpp',
|
||||
'test_const_map_ext_constexpr.cpp',
|
||||
'test_const_multimap.cpp',
|
||||
'test_const_multimap_constexpr.cpp',
|
||||
'test_const_multimap_ext.cpp',
|
||||
'test_const_multimap_ext_constexpr.cpp',
|
||||
'test_const_multiset.cpp',
|
||||
'test_const_multiset_constexpr.cpp',
|
||||
'test_const_multiset_ext.cpp',
|
||||
'test_const_multiset_ext_constexpr.cpp',
|
||||
'test_const_set.cpp',
|
||||
'test_const_set_constexpr.cpp',
|
||||
'test_const_set_ext.cpp',
|
||||
'test_const_set_ext_constexpr.cpp',
|
||||
'test_constant.cpp',
|
||||
'test_container.cpp',
|
||||
'test_correlation.cpp',
|
||||
@ -69,9 +111,12 @@ etl_test_sources = files(
|
||||
'test_crc16_en13757.cpp',
|
||||
'test_crc16_genibus.cpp',
|
||||
'test_crc16_kermit.cpp',
|
||||
'test_crc16_m17.cpp',
|
||||
'test_crc16_maxim.cpp',
|
||||
'test_crc16_mcrf4xx.cpp',
|
||||
'test_crc16_modbus.cpp',
|
||||
'test_crc16_opensafety_a.cpp',
|
||||
'test_crc16_opensafety_b.cpp',
|
||||
'test_crc16_profibus.cpp',
|
||||
'test_crc16_riello.cpp',
|
||||
'test_crc16_t10dif.cpp',
|
||||
@ -90,6 +135,7 @@ etl_test_sources = files(
|
||||
'test_crc32_q.cpp',
|
||||
'test_crc32_xfer.cpp',
|
||||
'test_crc64_ecma.cpp',
|
||||
'test_crc64_iso.cpp',
|
||||
'test_crc8_ccitt.cpp',
|
||||
'test_crc8_cdma2000.cpp',
|
||||
'test_crc8_darc.cpp',
|
||||
@ -97,21 +143,29 @@ etl_test_sources = files(
|
||||
'test_crc8_ebu.cpp',
|
||||
'test_crc8_icode.cpp',
|
||||
'test_crc8_itu.cpp',
|
||||
'test_crc8_j1850.cpp',
|
||||
'test_crc8_j1850_zero.cpp',
|
||||
'test_crc8_maxim.cpp',
|
||||
'test_crc8_nrsc5.cpp',
|
||||
'test_crc8_opensafety.cpp',
|
||||
'test_crc8_rohc.cpp',
|
||||
'test_crc8_wcdma.cpp',
|
||||
'test_cyclic_value.cpp',
|
||||
'test_debounce.cpp',
|
||||
'test_delegate.cpp',
|
||||
'test_delegate_cpp03.cpp',
|
||||
'test_delegate_observable.cpp',
|
||||
'test_delegate_service.cpp',
|
||||
'test_delegate_service_compile_time.cpp',
|
||||
'test_delegate_service_cpp03.cpp',
|
||||
'test_deque.cpp',
|
||||
'test_endian.cpp',
|
||||
'test_enum_type.cpp',
|
||||
'test_error_handler.cpp',
|
||||
'test_etl_assert.cpp',
|
||||
'test_etl_traits.cpp',
|
||||
'test_exception.cpp',
|
||||
'test_expected.cpp',
|
||||
'test_fixed_iterator.cpp',
|
||||
'test_fixed_sized_memory_block_allocator.cpp',
|
||||
'test_flags.cpp',
|
||||
@ -120,18 +174,24 @@ etl_test_sources = files(
|
||||
'test_flat_multiset.cpp',
|
||||
'test_flat_set.cpp',
|
||||
'test_fnv_1.cpp',
|
||||
'test_format.cpp',
|
||||
'test_format_spec.cpp',
|
||||
'test_forward_list.cpp',
|
||||
'test_forward_list_shared_pool.cpp',
|
||||
'test_fsm.cpp',
|
||||
'test_function.cpp',
|
||||
'test_function_traits.cpp',
|
||||
'test_functional.cpp',
|
||||
'test_gamma.cpp',
|
||||
'test_hash.cpp',
|
||||
'test_hfsm.cpp',
|
||||
'test_hfsm_recurse_to_inner_state_on_start.cpp',
|
||||
'test_hfsm_transition_on_enter.cpp',
|
||||
'test_histogram.cpp',
|
||||
'test_index_of_type.cpp',
|
||||
'test_indirect_vector.cpp',
|
||||
'test_indirect_vector_external_buffer.cpp',
|
||||
'test_inplace_function.cpp',
|
||||
'test_instance_count.cpp',
|
||||
'test_integral_limits.cpp',
|
||||
'test_intrusive_forward_list.cpp',
|
||||
@ -140,7 +200,9 @@ etl_test_sources = files(
|
||||
'test_intrusive_queue.cpp',
|
||||
'test_intrusive_stack.cpp',
|
||||
'test_invert.cpp',
|
||||
'test_invoke.cpp',
|
||||
'test_io_port.cpp',
|
||||
'test_is_invocable.cpp',
|
||||
'test_iterator.cpp',
|
||||
'test_jenkins.cpp',
|
||||
'test_largest.cpp',
|
||||
@ -148,14 +210,17 @@ etl_test_sources = files(
|
||||
'test_limits.cpp',
|
||||
'test_list.cpp',
|
||||
'test_list_shared_pool.cpp',
|
||||
'test_macros.cpp',
|
||||
'test_make_string.cpp',
|
||||
'test_manchester.cpp',
|
||||
'test_map.cpp',
|
||||
'test_math.cpp',
|
||||
'test_math_functions.cpp',
|
||||
'test_mean.cpp',
|
||||
'test_mem_cast.cpp',
|
||||
'test_mem_cast_ptr.cpp',
|
||||
'test_memory.cpp',
|
||||
'test_memory.cpp',
|
||||
'test_message.cpp',
|
||||
'test_message_broker.cpp',
|
||||
'test_message_bus.cpp',
|
||||
'test_message_packet.cpp',
|
||||
@ -163,18 +228,23 @@ etl_test_sources = files(
|
||||
'test_message_router_registry.cpp',
|
||||
'test_message_timer.cpp',
|
||||
'test_message_timer_atomic.cpp',
|
||||
'test_message_timer_interrupt.cpp',
|
||||
'test_message_timer_interrupt.cpp',
|
||||
'test_message_timer_locked.cpp',
|
||||
'test_multimap.cpp',
|
||||
'test_multiset.cpp',
|
||||
'test_multi_array.cpp',
|
||||
'test_multi_range.cpp',
|
||||
'test_multi_span.cpp',
|
||||
'test_multi_vector.cpp',
|
||||
'test_multimap.cpp',
|
||||
'test_multiset.cpp',
|
||||
'test_murmur3.cpp',
|
||||
'test_not_null_pointer.cpp',
|
||||
'test_not_null_pointer_constexpr.cpp',
|
||||
'test_not_null_unique_pointer.cpp',
|
||||
'test_nth_type.cpp',
|
||||
'test_numeric.cpp',
|
||||
'test_observer.cpp',
|
||||
'test_optional.cpp',
|
||||
'test_overload.cpp',
|
||||
'test_packet.cpp',
|
||||
'test_parameter_pack.cpp',
|
||||
'test_parameter_type.cpp',
|
||||
@ -184,6 +254,7 @@ etl_test_sources = files(
|
||||
'test_poly_span_fixed_extent.cpp',
|
||||
'test_pool.cpp',
|
||||
'test_pool_external_buffer.cpp',
|
||||
'test_print.cpp',
|
||||
'test_priority_queue.cpp',
|
||||
'test_pseudo_moving_average.cpp',
|
||||
'test_quantize.cpp',
|
||||
@ -200,45 +271,54 @@ etl_test_sources = files(
|
||||
'test_queue_spsc_locked.cpp',
|
||||
'test_queue_spsc_locked_small.cpp',
|
||||
'test_random.cpp',
|
||||
'test_ranges.cpp',
|
||||
'test_ratio.cpp',
|
||||
'test_reference_flat_map.cpp',
|
||||
'test_reference_flat_multimap.cpp',
|
||||
'test_reference_flat_multiset.cpp',
|
||||
'test_reference_flat_set.cpp',
|
||||
'test_rescale.cpp',
|
||||
'test_result.cpp',
|
||||
'test_rms.cpp',
|
||||
'test_rounded_integral_division.cpp',
|
||||
'test_scaled_rounding.cpp',
|
||||
'test_set.cpp',
|
||||
'test_shared_message.cpp',
|
||||
'test_signal.cpp',
|
||||
'test_singleton.cpp',
|
||||
'test_singleton_base.cpp',
|
||||
'test_smallest.cpp',
|
||||
'test_span_dynamic_extent.cpp',
|
||||
'test_span_fixed_extent.cpp',
|
||||
'test_stack.cpp',
|
||||
'test_standard_deviation.cpp',
|
||||
'test_state_chart.cpp',
|
||||
'test_state_chart_with_data_parameter.cpp',
|
||||
'test_state_chart_with_rvalue_data_parameter.cpp',
|
||||
'test_state_chart_compile_time.cpp',
|
||||
'test_state_chart_compile_time_with_data_parameter.cpp',
|
||||
'test_state_chart_with_data_parameter.cpp',
|
||||
'test_state_chart_with_rvalue_data_parameter.cpp',
|
||||
'test_string_char.cpp',
|
||||
'test_string_char_external_buffer.cpp',
|
||||
'test_string_stream.cpp',
|
||||
'test_string_u8.cpp',
|
||||
'test_string_u8_external_buffer.cpp',
|
||||
'test_string_stream_u16.cpp',
|
||||
'test_string_stream_u32.cpp',
|
||||
'test_string_stream_u8.cpp',
|
||||
'test_string_stream_wchar_t.cpp',
|
||||
'test_string_u16.cpp',
|
||||
'test_string_u16_external_buffer.cpp',
|
||||
'test_string_u32.cpp',
|
||||
'test_string_u32_external_buffer.cpp',
|
||||
'test_string_u8.cpp',
|
||||
'test_string_u8_external_buffer.cpp',
|
||||
'test_string_utilities.cpp',
|
||||
'test_string_utilities_std.cpp',
|
||||
'test_string_utilities_std_u16.cpp',
|
||||
'test_string_utilities_std_u32.cpp',
|
||||
'test_string_utilities_std_u8.cpp',
|
||||
'test_string_utilities_std_wchar_t.cpp',
|
||||
'test_string_utilities_u16.cpp',
|
||||
'test_string_utilities_u32.cpp',
|
||||
'test_string_utilities_u8.cpp',
|
||||
'test_string_utilities_wchar_t.cpp',
|
||||
'test_string_view.cpp',
|
||||
'test_string_wchar_t.cpp',
|
||||
@ -246,17 +326,25 @@ etl_test_sources = files(
|
||||
'test_successor.cpp',
|
||||
'test_task_scheduler.cpp',
|
||||
'test_threshold.cpp',
|
||||
'test_to_arithmetic.cpp',
|
||||
'test_to_arithmetic_u16.cpp',
|
||||
'test_to_arithmetic_u32.cpp',
|
||||
'test_to_arithmetic_u8.cpp',
|
||||
'test_to_arithmetic_wchar_t.cpp',
|
||||
'test_to_string.cpp',
|
||||
'test_to_u8string.cpp',
|
||||
'test_to_u16string.cpp',
|
||||
'test_to_u32string.cpp',
|
||||
'test_to_u8string.cpp',
|
||||
'test_to_wstring.cpp',
|
||||
'test_tuple.cpp',
|
||||
'test_type_def.cpp',
|
||||
'test_type_list.cpp',
|
||||
'test_type_lookup.cpp',
|
||||
'test_type_select.cpp',
|
||||
'test_type_traits.cpp',
|
||||
'test_unaligned_type.cpp',
|
||||
'test_unaligned_type_constexpr.cpp',
|
||||
'test_unaligned_type_ext.cpp',
|
||||
'test_uncopyable.cpp',
|
||||
'test_unordered_map.cpp',
|
||||
'test_unordered_multimap.cpp',
|
||||
'test_unordered_multiset.cpp',
|
||||
@ -265,9 +353,9 @@ etl_test_sources = files(
|
||||
'test_utility.cpp',
|
||||
'test_variance.cpp',
|
||||
'test_variant_legacy.cpp',
|
||||
'test_variant_variadic.cpp',
|
||||
'test_variant_pool.cpp',
|
||||
'test_variant_pool_external_buffer.cpp',
|
||||
'test_variant_variadic.cpp',
|
||||
'test_vector.cpp',
|
||||
'test_vector_external_buffer.cpp',
|
||||
'test_vector_non_trivial.cpp',
|
||||
@ -280,24 +368,26 @@ etl_test_sources = files(
|
||||
|
||||
compile_args = [
|
||||
'-DENABLE_ETL_UNIT_TESTS',
|
||||
'-DETL_DEBUG',
|
||||
]
|
||||
link_args = []
|
||||
|
||||
if get_option('use_stl')
|
||||
compile_args += '-DETL_NO_STL=0'
|
||||
elif
|
||||
else
|
||||
compile_args += '-DETL_NO_STL=1'
|
||||
endif
|
||||
|
||||
if meson.get_compiler('cpp').get_argument_syntax() == 'gcc'
|
||||
compile_args += '-fsanitize=address,undefined'
|
||||
compile_args += '-fexceptions'
|
||||
compile_args += '-Wall'
|
||||
compile_args += '-Wextra'
|
||||
compile_args += '-Wextra'
|
||||
compile_args += '-Wno-non-virtual-dtor' #TODO remove and fix warning in code
|
||||
compile_args += '-Werror'
|
||||
link_args += '-fsanitize=address,undefined'
|
||||
|
||||
if get_option('enable_sanitizer')
|
||||
compile_args += '-fsanitize=address,undefined'
|
||||
link_args += '-fsanitize=address,undefined'
|
||||
endif
|
||||
endif
|
||||
|
||||
threads_dep = dependency('threads')
|
||||
|
||||
@ -58,7 +58,7 @@ for CXXSTD in 11 14 17 20 23 26; do
|
||||
-DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF \
|
||||
-DETL_OPTIMISATION=-O0 \
|
||||
-DETL_CXX_STANDARD=$CXXSTD \
|
||||
-DETL_ENABLE_SANITIZER=Off \
|
||||
-DETL_ENABLE_SANITIZER=OFF \
|
||||
-DETL_MESSAGES_ARE_NOT_VIRTUAL=OFF \
|
||||
-DETL_USE_BUILTIN_MEM_FUNCTIONS=ON ..
|
||||
cmake --build .
|
||||
|
||||
@ -163,11 +163,11 @@ fi
|
||||
# Set the sanitizer enable. Default OFF
|
||||
#******************************************************************************
|
||||
if [ "$4" = "s" ]; then
|
||||
sanitize="On"
|
||||
sanitize="ON"
|
||||
elif [ "$4" = "n" ]; then
|
||||
sanitize="Off"
|
||||
sanitize="OFF"
|
||||
else
|
||||
sanitize="Off"
|
||||
sanitize="OFF"
|
||||
fi
|
||||
|
||||
#******************************************************************************
|
||||
|
||||
@ -50,7 +50,7 @@ namespace
|
||||
|
||||
for (size_t i = 0UL; i < sizeof(value_type); ++i)
|
||||
{
|
||||
uint8_t byte = static_cast<uint8_t>((static_cast<unsigned char>(value) >> (i * 8UL)) & 0xFFU);
|
||||
uint8_t byte = static_cast<uint8_t>((static_cast<unsigned int>(value) >> (i * 8U)) & 0xFFU);
|
||||
checksum = etl::rotate_right(checksum) + byte;
|
||||
}
|
||||
}
|
||||
|
||||
@ -403,7 +403,9 @@ namespace
|
||||
|
||||
CHECK_EQUAL("data1", test_format(s, "{}", sv));
|
||||
CHECK_EQUAL("data1", test_format(s, "{:s}", sv));
|
||||
#if !ETL_USING_CPP20
|
||||
CHECK_THROW(test_format(s, "{:d}", sv), etl::bad_format_string_exception);
|
||||
#endif
|
||||
CHECK_EQUAL("data1 ", test_format(s, "{:10s}", sv));
|
||||
CHECK_EQUAL("data1 ", test_format(s, "{:<10s}", sv));
|
||||
CHECK_EQUAL(" data1", test_format(s, "{:>10s}", sv));
|
||||
@ -432,7 +434,9 @@ namespace
|
||||
|
||||
CHECK_EQUAL("data1", test_format(s, "{}", s_arg));
|
||||
CHECK_EQUAL("data1", test_format(s, "{:s}", s_arg));
|
||||
#if !ETL_USING_CPP20
|
||||
CHECK_THROW(test_format(s, "{:d}", s_arg), etl::bad_format_string_exception);
|
||||
#endif
|
||||
CHECK_EQUAL("data1 ", test_format(s, "{:10s}", s_arg));
|
||||
CHECK_EQUAL("data1 ", test_format(s, "{:<10s}", s_arg));
|
||||
CHECK_EQUAL(" data1", test_format(s, "{:>10s}", s_arg));
|
||||
@ -466,7 +470,9 @@ namespace
|
||||
|
||||
CHECK_EQUAL("data1", test_format(s, "{}", string_t(data)));
|
||||
CHECK_EQUAL("data1", test_format(s, "{:s}", string_t(data)));
|
||||
#if !ETL_USING_CPP20
|
||||
CHECK_THROW(test_format(s, "{:d}", string_t(data)), etl::bad_format_string_exception);
|
||||
#endif
|
||||
CHECK_EQUAL("data1 ", test_format(s, "{:10s}", string_t(data)));
|
||||
CHECK_EQUAL("data1 ", test_format(s, "{:<10s}", string_t(data)));
|
||||
CHECK_EQUAL(" data1", test_format(s, "{:>10s}", string_t(data)));
|
||||
@ -495,7 +501,9 @@ namespace
|
||||
|
||||
CHECK_EQUAL("data1", test_format(s, "{}", chars));
|
||||
CHECK_EQUAL("data1", test_format(s, "{:s}", chars));
|
||||
#if !ETL_USING_CPP20
|
||||
CHECK_THROW(test_format(s, "{:d}", chars), etl::bad_format_string_exception);
|
||||
#endif
|
||||
CHECK_EQUAL("data1 ", test_format(s, "{:10s}", chars));
|
||||
CHECK_EQUAL("data1 ", test_format(s, "{:<10s}", chars));
|
||||
CHECK_EQUAL(" data1", test_format(s, "{:>10s}", chars));
|
||||
@ -640,28 +648,28 @@ namespace
|
||||
{
|
||||
etl::string<100> s;
|
||||
|
||||
#if !ETL_USING_CPP20
|
||||
// These are caught at compile time in C++20 (consteval), so only test at runtime for pre-C++20
|
||||
CHECK_THROW(test_format(s, "a{b}", 1),
|
||||
etl::bad_format_string_exception); // bad format index spec
|
||||
// goal: rejected at compile time on C++20, error on <= C++17
|
||||
|
||||
CHECK_THROW(test_format(s, "a{b"),
|
||||
etl::bad_format_string_exception); // closing brace missing
|
||||
// goal: rejected at compile time on C++20, error on <= C++17
|
||||
|
||||
CHECK_THROW(test_format(s, "a{b}"),
|
||||
etl::bad_format_string_exception); // arg missing
|
||||
// goal: rejected at compile time on C++20, error on <= C++17
|
||||
|
||||
CHECK_THROW(test_format(s, "a}b"),
|
||||
etl::bad_format_string_exception); // bad format: only escaped
|
||||
// }} allowed
|
||||
// goal: rejected at compile time on C++20, error on <= C++17
|
||||
|
||||
CHECK_EQUAL("123", test_format(s, "{:}", 123)); // valid
|
||||
CHECK_THROW(test_format(s, "{::}", 123),
|
||||
etl::bad_format_string_exception); // bad format spec
|
||||
CHECK_THROW(test_format(s, "{1}", 123),
|
||||
etl::bad_format_string_exception); // bad index
|
||||
#endif
|
||||
|
||||
CHECK_EQUAL("123", test_format(s, "{:}", 123)); // valid
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -720,7 +728,9 @@ namespace
|
||||
CHECK_EQUAL(" 34 ", test_format(s, "{:^5}", 34));
|
||||
CHECK_EQUAL(" -65 ", test_format(s, "{:^5}", -65));
|
||||
CHECK_EQUAL("34 ", test_format(s, "{:<4}", 34));
|
||||
#if !ETL_USING_CPP20
|
||||
CHECK_THROW(test_format(s, "a{:*5}", 34), etl::bad_format_string_exception);
|
||||
#endif
|
||||
CHECK_EQUAL("a*34**", test_format(s, "a{:*^5}", 34));
|
||||
CHECK_EQUAL("a*34**", test_format(s, "a{:*^5}", static_cast<unsigned int>(34)));
|
||||
CHECK_EQUAL("a***-341234567890****", test_format(s, "a{:*^20}", static_cast<long long int>(-341234567890)));
|
||||
@ -773,7 +783,9 @@ namespace
|
||||
CHECK_EQUAL("00067", test_format(s, "{:05d}", 67));
|
||||
CHECK_EQUAL("+00067", test_format(s, "{:+05d}", 67));
|
||||
CHECK_EQUAL("+0X00EF1", test_format(s, "{:+#05X}", 0xEF1));
|
||||
#if !ETL_USING_CPP20
|
||||
CHECK_THROW(test_format(s, "{:+#05.5X}", 0xEF1), etl::bad_format_string_exception);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@ -3541,6 +3541,7 @@
|
||||
<ClInclude Include="..\..\include\etl\crc8_wcdma.h" />
|
||||
<ClInclude Include="..\..\include\etl\delegate_observable.h" />
|
||||
<ClInclude Include="..\..\include\etl\expected.h" />
|
||||
<ClInclude Include="..\..\include\etl\format.h" />
|
||||
<ClInclude Include="..\..\include\etl\function_traits.h" />
|
||||
<ClInclude Include="..\..\include\etl\gcd.h" />
|
||||
<ClInclude Include="..\..\include\etl\generators\fsm_cpp03_generator.h" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user