Compare commits

..

556 Commits

Author SHA1 Message Date
Roland Reichwein
3e4d41ca57
Fix operator| conflict with std::ranges (#1395) 2026-04-14 11:56:05 +02:00
John Wellbelove
912e22f238 Merge branch 'development' 2026-04-05 14:32:40 +01:00
John Wellbelove
1a6762d6c3 Updated version and release notes 2026-04-05 14:13:22 +01:00
John Wellbelove
ee04aa76c5 VS2022 project update 2026-04-05 14:03:32 +01:00
Roland Reichwein
3cd03fcb7f
Fix initializer_list use in algorithm.h and definition of data() in iterator.h (#1374)
* Print test names at test time (#1343)

* Fix initializer_list use in algorithm.h

Needs to be conditional.

* Move definition of data() in iterator.h

Needs to be defined earlier.

---------

Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.com>
2026-04-05 13:37:15 +01:00
John Wellbelove
654e222bd9 Merge branch 'development' 2026-04-04 10:50:06 +01:00
John Wellbelove
a1ad13364e Updated release notes 2026-04-04 10:49:00 +01:00
John Wellbelove
22ee76914d Merge branch 'development'
# Conflicts:
#	test/main.cpp
2026-04-04 10:02:24 +01:00
John Wellbelove
e2bed92814 Updated version and release notes 2026-04-04 09:40:46 +01:00
John Wellbelove
576b03f38d Merged from local copy of PR1295 2026-04-04 00:14:49 +01:00
John Wellbelove
f7e1384a70 Merge development 2026-04-03 20:09:06 +01:00
John Wellbelove
e61589ebf2 Merge branch 'development' into delegate-from-non-capturing-lambda
# Conflicts:
#	include/etl/private/delegate_cpp11.h
#	test/test_delegate.cpp
2026-04-03 20:08:41 +01:00
Maksim Danilov
823f2493b4
Rename 'leaf' to 'child' in intrusive_links.h (#1373)
* Print test names at test time (#1343)

* Rename 'leaf' to 'child' in intrusive_links.h

Recent versions of the Tasking TriCore compiler treat
'leaf' as a reserved C++ keyword, causing compilation failures in ETL.

---------

Co-authored-by: Roland Reichwein <Roland.Reichwein@bmw.de>
Co-authored-by: Maksim Danilov <maksim.danilov@accenture.com>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-04-03 17:35:41 +01:00
John Wellbelove
982adecca4 Added manually triggered clang-format action
# Conflicts:
#	.github/workflows/clang-format_update.yaml
2026-04-03 16:55:18 +01:00
John Wellbelove
2059c5b657 Added manually triggered clang-format action
# Conflicts:
#	.github/workflows/clang-format_update.yaml
2026-04-03 16:46:42 +01:00
John Wellbelove
bd6e55b12e Added manually triggered clang-format action
# Conflicts:
#	.github/workflows/clang-format_update.yaml
2026-04-03 16:45:25 +01:00
John Wellbelove
5a7674b637 Added manually triggered clang-format action
# Conflicts:
#	.github/workflows/clang-format_update.yaml
2026-04-03 16:42:29 +01:00
John Wellbelove
2e74b07dff Added manually triggered clang-format action 2026-04-03 16:35:57 +01:00
John Wellbelove
f5128a39fe Attempt to fix syntax that comfuse clang-format 2026-04-03 13:58:19 +01:00
John Wellbelove
01066b86ae Attempt to fix syntax that comfuse clang-format 2026-04-03 12:31:51 +01:00
John Wellbelove
aeb8e4f734 Formatted source files 2026-04-02 14:11:45 +01:00
John Wellbelove
c7571660bd Adjusted ColumnLimit to 150 2026-04-02 14:07:10 +01:00
John Wellbelove
6a1585b317 Improved include regex 2026-04-02 13:13:33 +01:00
John Wellbelove
9fba468dc2 Removed ETL_DEPRECATED_REASON=[[deprecated(%0)]] from configuration 2026-04-02 11:33:44 +01:00
John Wellbelove
bd1def8b41 Used the correct macro for 'if constexpr' 2026-04-02 10:35:49 +01:00
John Wellbelove
27d284713a Updated .clang-format to include more ETL macros 2026-04-02 10:15:35 +01:00
John Wellbelove
1405bf65de Updated .treefmt to exclude more files and directories 2026-04-02 08:27:46 +01:00
Roland Reichwein
09dd40d4dd Fix .clang-format to recognize ETL macros as attributes 2026-04-02 08:20:43 +01:00
Roland Reichwein
c536a39f0a Treefmt config 2026-04-02 08:19:45 +01:00
John Wellbelove
9b394b8677 Added certain Hugo files and diectories to the Git ignore file 2026-04-01 17:34:15 +01:00
John Wellbelove
9d2c73793d Ran clang-format on generated files, using the .clang-format from PR #1314 2026-04-01 13:33:18 +01:00
Benedek Kupper
1ce3deb0f7 test: delegate: add unary + to convert lambda to function pointer 2026-03-31 21:56:42 +02:00
John Wellbelove
ea397ec2dd Changed non-capturing lambda API to runtime function pointer API 2026-03-31 21:27:44 +02:00
John Wellbelove
a483eb90c4 Fixed generator_test.py
Updated generator files in the VS2022 project
Adde licence headers to the generator headers
2026-03-31 19:11:02 +01:00
Diogo Cavaleiro
c970fa9bad Add clang-format v18 workflow and configuration 2026-03-31 16:59:09 +01:00
Roland Reichwein
d17c0297ec
Factor out generated code (#1369)
Previously, generator code under include/etl/generators needed to be
synchronized with the generated files under include/etl explicitly.
Leading to errors in the CI checks if forgotten.

This change separates out the generated parts to cpp03 specific
snippets. This way, most code under include/etl is now directly editable,
with only some pre-C++11 code separated out to
include/etl/generators/*_cpp03_generator.h which still needs to be
re-generated on respective changes. But in many cases, this is not necessary.

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-03-31 16:36:54 +01:00
William Sciaroni
3c2a4d48a9
Update Dockerfile and Devcontainer. (#1360)
* Print test names at test time (#1343)

* Remove python3-cogapp from Dockerfile

Removed python3-cogapp from the Dockerfile installation.

* Update .devcontainer/Dockerfile

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Change base image and update Python package installation

* Change container to use cpp devcontainer version 2

* Point to specific version of the devcontainer

* Update devcontainer to use debian snapshot for reproducability

* Fetch sources via https

* Make devcontainer more robust for debian_snapshot

* Make fetch non-https for snapshot

* Install CMake from apt

* Update devcontainers to remove CMake version

* Change Clang version from 22 to 21

* Apply suggestion from @rolandreichweinbmw

---------

Co-authored-by: Roland Reichwein <Roland.Reichwein@bmw.de>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-03-31 12:20:31 +01:00
John Wellbelove
3d564d68b9 Fixed sign conversion in advance_helper 2026-03-30 19:34:15 +01:00
John Wellbelove
e4dfb6c045 Fixed iterator.h #if #else #endif
Fixed type_lookup_generator to match genereted
2026-03-30 19:06:07 +01:00
John Wellbelove
95c9cabc10 Fix for PR 1367 2026-03-28 20:37:03 +00:00
John Wellbelove
3638d89f8b Fix for PR 1367 2026-03-28 13:50:27 +00:00
John Wellbelove
03ca3c817e Fix for PR 1367 2026-03-28 12:03:12 +00:00
Roland Reichwein
b83cef5668
Fix compilation with -Wsign-conversion (#1367)
* Fix compilation with -Wsign-conversion

For tests with GCC and Clang

Fixes https://github.com/ETLCPP/etl/issues/632

* Fix support of negative Id in type_lookup.h: type_from_id

* Fix element access arithmetic in atomic_gcc_sync.h fetch_add/fetch_sub

* Fix rounded_integral_division.h: divide_round_half_odd(): direction is always 1
2026-03-28 11:15:56 +00:00
Bram Meijer
2c2ce9a39f
Add a inplace_function constructor from a nullptr (#1336)
* Add a inplace_function constructor with a nullptr argument

* Add unit test for nullptr construction

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-03-28 09:16:00 +00:00
Daniel Santos
f718c54396
Add bounds and empty checks to container classes (#1334)
* add bounds and empty checks to containers

* address code rabbit review

* correct C++11 constexpr error

* rename new constexpr macro and make it global

* rename queue specializations' exceptions

* change front() implementation in locked queue specializations

* refactor usage of CONSTEXPR and NO_EXCEPT

* expand intrusive queue tests

* introduce lock guards on locked queues

* Print test names at test time (#1343)

* revert mutex and return changes on locking queues

* finish reverting the locked queues

---------

Co-authored-by: Roland Reichwein <Roland.Reichwein@bmw.de>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-03-27 10:17:56 +00:00
Roland Reichwein
12cdbc0da0
Bug fixes in variant_variadic.h (#1358)
* Print test names at test time (#1343)

* Bug fixes in variant_variadic.h

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-03-27 09:19:50 +00:00
Bram Meijer
ab03ea114f
Fix compilation issue when including etl/chrono next to etl/to_string. (#1365)
* Print test names at test time (#1343)

* Fix namespace issue of floor/round in to_string_helper

---------

Co-authored-by: Roland Reichwein <Roland.Reichwein@bmw.de>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-03-27 08:11:45 +00:00
Roland Reichwein
2f242e37f2
Restrict etl::atomic for general types (#1359)
* Print test names at test time (#1343)

* Restrict etl::atomic for general types

Needs adding is_copy_assignable and is_move_assignable, and
adjustments to is_trivially_copyable and is_assignable

* Resolve mutable T value vs. volatile qualified methods

* Remove volatile method overloads

They are deprecated in C++20 because they don't work as users expect anyway.

MSVC hinted for this.

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-03-26 09:46:20 +00:00
Roland Reichwein
31b87b5419
Add C++ ranges library for C++17 (#1316)
* Add ranges

* Print test names at test time (#1343)

* Fix conflit commit errors

* Cast return value of operator* to value_type

Fixed warning on VS2022

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-03-26 08:56:17 +00:00
Roland Reichwein
add42b6c87
Mark uninitialized use from std library (#1349)
* Print test names at test time (#1343)

* Mark uninitialized use from std library

Similar to other cases, adds compiler pragmas against warnings
caused by std library in optimized builds of tests

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-03-26 08:29:05 +00:00
Timon Zijnge
2f6a3e04aa
Manchester big endian support (#1353)
* manchester
* Added manchester code and test

* manchester
* Formatting and added missing file

* manchester
* Some functions can only be constexpr since C++14

* manchester
* Manchester decode and some refactoring

* manchester
* Added some missing typenames

* manchester
* constexpr void function not allowed in C++11

* manchester
* condition on static_assert tests

* manchester
* revert CMakeLists.txt
* Using ETL_STATIC_ASSERT
* Some cleanup

* manchester
* Added static_assert message

* manchester
* Added compile time tests

* manchester
* Added invert manchester
* Some refactoring

* manchester
* Disable test for now
* Move ETL_NODISCARD before static

* manchester
* Test for valid_span

* manchester
* Remove redundant (?) storage specifiers for template specializations. Storage specifier already given in base template

* manchester
* refactoring to get rid of specialized template functions in template class

* manchester
* cleanup

* manchester
* Added documentation comments
* Some refactoring

* manchester
* introducing namespace detail_manchester

* manchester
* Some refactoring
* Update tests

* manchester
* Some refactoring
* Removed possible undefined behavior by refactoring encode_span
* constexpr version of encode_span
* Static assertion for rare case where code doesn't work because CHAR_BIT is not the same as the number of bits in uint_least8_t

* manchester
* renamed valid to is_valid

* manchester
* renamed is_valid_span to is_valid
* Using etl exceptions in ETL_ASSERT

* manchester
* Removed _fast functions
* merged encode_in_place with encode and decode_in_place with decode
* removed _span to create normal overloads of encode and decode for span
* Some renaming and minor refactoring

* manchester
* Fix build issues

* manchester
* Conditionally compile manchester_decoded

* Update test_manchester.cpp

Removed redundant semicolon

* #1258 Manchester coding
* Formatting
* consistency: hex literals with lower case 0x

* #1258 Manchester coding
* Moved copyright to top of file
* Make constexpr encode/decode span functions equal for little and big endian platforms

* #1258 Manchester coding
* Added missing include
* Added missing 8bit/64bit guards
* Fixed is_valid for big endian platforms

* #1258 Manchester coding
* private memcpy alias

* #1258 Manchester coding
* Review comments

* #1258 Manchester coding
* Cleanup
* Fix build error

* #1258 Manchester coding
* Add manchester documentation

* #1258 Manchester coding
* Preparation for GitHub pages

* #1324 Manchester documentation
* Some small fixes

* Print test names at test time (#1343)

* IGN-280 biphasic amplitude as float
* Add big-endian devcontainer

* manchester
* fixed the configuration to work with GitHub Codespaces. The changes use cross-compilation with QEMU emulation instead of trying to use a native s390x container.

* manchester
* Made manchester work for big-endian
* Some updates to the container

* Manchester big-endian support
* Cleanup

* Manchester big-endian support
* add sourcedirectory

* Enable running with ctest

* Manchester big-endian support
* Update documentation

* Manchester big-endian support
* QA

* Manchester big-endian support
* QA

* Enable testing with ctest with cross-compiler (#5)

* Enable testing with ctest and with cross-compiler
* Clean up includes in manchester.h

---------

Co-authored-by: Timon Zijnge <timon.zijnge@imec.nl>

---------

Co-authored-by: Timon Zijnge <timon.zijnge@imec.nl>
Co-authored-by: Roland Reichwein <Roland.Reichwein@bmw.de>
2026-03-26 07:56:50 +00:00
Roland Reichwein
d5fc8d0cd1
Add code coverage report (#1357)
* Print test names at test time (#1343)

* Add code coverage report
2026-03-25 20:48:41 +00:00
Roland Reichwein
7fdea7f7ae
Adjustments in tuple.h from review (#1350)
* Print test names at test time (#1343)

* Adjustments in tuple.h from review

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-03-25 19:28:12 +00:00
Roland Reichwein
e7107b24f1
Fix tests on big endian (#1356)
* Print test names at test time (#1343)

* Fix tests on big endian

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-03-25 12:47:03 +00:00
Roland Reichwein
66e3d83a81
Fix ETL_HAS_CONSTEXPR_ENDIANESS in unaligned_type.h (#1361)
* Print test names at test time (#1343)

* Fix ETL_HAS_CONSTEXPR_ENDIANESS in unaligned_type.h

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-03-25 12:16:36 +00:00
Roland Reichwein
bd15e42440
Fix etl::optional for deleted copy constructors (#1362)
* Print test names at test time (#1343)

* Fix etl::optional for deleted copy constructors

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-03-25 08:14:33 +00:00
Roland Reichwein
0b5621e809
Fix span size type (#1363)
* Print test names at test time (#1343)

* Fix span size type

size() returned a signed value while declared (unsigned) size_t.

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-03-25 07:54:18 +00:00
Roland Reichwein
fa3ac74558
Limit clock duration to milliseconds type on narrow int type (#1364)
* Print test names at test time (#1343)

* Limit clock duration to milliseconds type on narrow int type

On AVR, for 16 bit int types, nano and micro are not provided.
Now, consistently use them only conditionally.

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-03-23 19:51:30 +00:00
William Sciaroni
325908b1b9
Add permutation functions (#1348)
* Print test names at test time (#1343)

* Add permutation functions

* Refactor permutation to use etl::less

* Add test for next_permutation where begin == end

* Update code to avoid multiple bind1st objects in loop

* Remove duplicate is_partitioned test case

Removed the duplicate is_partitioned test case from the test suite.

---------

Co-authored-by: Roland Reichwein <Roland.Reichwein@bmw.de>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-03-23 19:30:03 +00:00
Henri Bragge
29ad4b327e
Fix comment in queue::pop (#1347)
* Print test names at test time (#1343)

* Fix comment in queue::pop

---------

Co-authored-by: Roland Reichwein <Roland.Reichwein@bmw.de>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-03-17 11:05:28 +00:00
John Wellbelove
3639850b6b Fixed type_traits.h generator 2026-03-13 07:37:02 +00:00
Roland Reichwein
89284de733
Add treefmt support (#1323)
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-03-13 00:11:51 +00:00
Ralph Rooding
ad6e027b08
Add PURL to Zephyr module.yml for SBoM generation (#1344)
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-03-12 20:39:53 +00:00
Roland Reichwein
78d8b82afb Print test names at test time (#1343) 2026-03-12 20:08:22 +00:00
Roland Reichwein
a0c98662ca
Print test names at test time (#1343) 2026-03-12 19:55:16 +00:00
Christoph Rüthing
237d83c107
Add pre C++20 Support for ETL_CONSTINIT using Compiler Extensions (#1335)
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-03-12 19:47:39 +00:00
John Wellbelove
8a61985ac8
span is constructible from temporary (#1338)
* Added missing files from VS2022 project

* Added global data() overloads to complement etl::size()

* Added C++03 compatible implementation of etl::is_convertible

* Updated etl::span to more closely align with std::span

* Fix etl::rotate (#1327)

Per the C++ standard, std::rotate returns first + (last - middle):

* When first == middle, return last
* When middle == last, return first

* Fix greater_equal and less_equal (#1331)

* Align comparison operators (#1330)

In functional.h, the comparison operators for equal_to and not_equal_to
mismatch between the actual comparison execution and the type inference
for the return type. This change adjusts it by using the same operator==()
in the return type inference as used in the comparison execution.

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>

* Add missing tests (#1321)

* Add missing tests

* Typo fixes

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>

* Add ETL_FORMAT_NO_FLOATING_POINT control macro for etl::format (#1329)

When ETL_FORMAT_NO_FLOATING_POINT is defined, all floating-point formatting support (float, double, long double) is excluded from etl::format. This reduces code size on targets that do not require floating-point formatting.

Guarded sections:

- #include <cmath>

- float/double/long double in supported_format_types variant

- float/double/long double constructors in basic_format_arg

- format_floating_* functions and format_aligned_floating

- formatter<float>, formatter<double>, formatter<long double>

- Floating-point test cases in test_format.cpp

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
# Conflicts:
#	include/etl/platform.h

* Manchester documentation (#1325)

* manchester
* Added manchester code and test

* manchester
* Formatting and added missing file

* manchester
* Some functions can only be constexpr since C++14

* manchester
* Manchester decode and some refactoring

* manchester
* Added some missing typenames

* manchester
* constexpr void function not allowed in C++11

* manchester
* condition on static_assert tests

* manchester
* revert CMakeLists.txt
* Using ETL_STATIC_ASSERT
* Some cleanup

* manchester
* Added static_assert message

* manchester
* Added compile time tests

* manchester
* Added invert manchester
* Some refactoring

* manchester
* Disable test for now
* Move ETL_NODISCARD before static

* manchester
* Test for valid_span

* manchester
* Remove redundant (?) storage specifiers for template specializations. Storage specifier already given in base template

* manchester
* refactoring to get rid of specialized template functions in template class

* manchester
* cleanup

* manchester
* Added documentation comments
* Some refactoring

* manchester
* introducing namespace detail_manchester

* manchester
* Some refactoring
* Update tests

* manchester
* Some refactoring
* Removed possible undefined behavior by refactoring encode_span
* constexpr version of encode_span
* Static assertion for rare case where code doesn't work because CHAR_BIT is not the same as the number of bits in uint_least8_t

* manchester
* renamed valid to is_valid

* manchester
* renamed is_valid_span to is_valid
* Using etl exceptions in ETL_ASSERT

* manchester
* Removed _fast functions
* merged encode_in_place with encode and decode_in_place with decode
* removed _span to create normal overloads of encode and decode for span
* Some renaming and minor refactoring

* manchester
* Fix build issues

* manchester
* Conditionally compile manchester_decoded

* Update test_manchester.cpp

Removed redundant semicolon

* #1258 Manchester coding
* Formatting
* consistency: hex literals with lower case 0x

* #1258 Manchester coding
* Moved copyright to top of file
* Make constexpr encode/decode span functions equal for little and big endian platforms

* #1258 Manchester coding
* Added missing include
* Added missing 8bit/64bit guards
* Fixed is_valid for big endian platforms

* #1258 Manchester coding
* private memcpy alias

* #1258 Manchester coding
* Review comments

* #1258 Manchester coding
* Cleanup
* Fix build error

* #1258 Manchester coding
* Add manchester documentation

* #1258 Manchester coding
* Preparation for GitHub pages

* #1324 Manchester documentation
* Some small fixes

---------

Co-authored-by: Timon Zijnge <timon.zijnge@imec.nl>

* Moved and split has_size_and_data in span.h to has_size & has_data in type_traits.h

* Removed has_size_and_data traits, and move to type_traits.h

Added ETL_ASSERT for for fixed extent constructors from iterator range and begin/size

* Added macro ETL_NOEXCEPT_IF that takes a compile time boolean expression

* Changed two fixed span constructors to ETL_CONSTEXPR14 due to ETL_ASSERT in the constructor bodies

Added ETL_NOEXCEPT_IF for simpler boolean conditions
Added tests for construction from mismatched sizes

* Added definition for ETL_NOEXCEPT_IF in no C++11 path

* Changes  to disable construction from rvalue temporaries

---------

Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.com>
Co-authored-by: Roland Reichwein <Roland.Reichwein@bmw.de>
Co-authored-by: Niu Zhihong <zhihong@nzhnb.com>
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Co-authored-by: Timon Zijnge <47081647+tzijnge@users.noreply.github.com>
Co-authored-by: Timon Zijnge <timon.zijnge@imec.nl>
2026-03-12 17:08:02 +00:00
John Wellbelove
d3affac417
Enforce o(log n) dispatch for messages when using fsm for c++11 and up (#1337)
* Updated message handling to be worst case O(logN)

* Copied optimised message handling from etl::fsm

* Updated fsm generator

* Updated message_router generator

* Added optimised accepts() member function

* Modified comment, as the FSM doesn't support a successor

* Updated version and release notes

* Hotfix/etl  multiset iterator invalidation during erase leads to incorrect sorted order in depth first traversal (#1317)

* Fixed issue for both multiset and multimap

* Added std::is_sorted checks to all map/set tests

* Updated with coderabbit suggestions

---------

Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.com>

* Updated release notes and version

* Changed std::is_same to etl::is_same in struct type_list_is_unique (#1320)

Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.com>

* Updated release notes and version

* Fix etl::rotate (#1327)

Per the C++ standard, std::rotate returns first + (last - middle):

* When first == middle, return last
* When middle == last, return first

* Added missing files from VS2022 project

* Fix greater_equal and less_equal (#1331)

* Align comparison operators (#1330)

In functional.h, the comparison operators for equal_to and not_equal_to
mismatch between the actual comparison execution and the type inference
for the return type. This change adjusts it by using the same operator==()
in the return type inference as used in the comparison execution.

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>

* Add missing tests (#1321)

* Add missing tests

* Typo fixes

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>

* Add ETL_FORMAT_NO_FLOATING_POINT control macro for etl::format (#1329)

When ETL_FORMAT_NO_FLOATING_POINT is defined, all floating-point formatting support (float, double, long double) is excluded from etl::format. This reduces code size on targets that do not require floating-point formatting.

Guarded sections:

- #include <cmath>

- float/double/long double in supported_format_types variant

- float/double/long double constructors in basic_format_arg

- format_floating_* functions and format_aligned_floating

- formatter<float>, formatter<double>, formatter<long double>

- Floating-point test cases in test_format.cpp

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>

* Manchester documentation (#1325)

* manchester
* Added manchester code and test

* manchester
* Formatting and added missing file

* manchester
* Some functions can only be constexpr since C++14

* manchester
* Manchester decode and some refactoring

* manchester
* Added some missing typenames

* manchester
* constexpr void function not allowed in C++11

* manchester
* condition on static_assert tests

* manchester
* revert CMakeLists.txt
* Using ETL_STATIC_ASSERT
* Some cleanup

* manchester
* Added static_assert message

* manchester
* Added compile time tests

* manchester
* Added invert manchester
* Some refactoring

* manchester
* Disable test for now
* Move ETL_NODISCARD before static

* manchester
* Test for valid_span

* manchester
* Remove redundant (?) storage specifiers for template specializations. Storage specifier already given in base template

* manchester
* refactoring to get rid of specialized template functions in template class

* manchester
* cleanup

* manchester
* Added documentation comments
* Some refactoring

* manchester
* introducing namespace detail_manchester

* manchester
* Some refactoring
* Update tests

* manchester
* Some refactoring
* Removed possible undefined behavior by refactoring encode_span
* constexpr version of encode_span
* Static assertion for rare case where code doesn't work because CHAR_BIT is not the same as the number of bits in uint_least8_t

* manchester
* renamed valid to is_valid

* manchester
* renamed is_valid_span to is_valid
* Using etl exceptions in ETL_ASSERT

* manchester
* Removed _fast functions
* merged encode_in_place with encode and decode_in_place with decode
* removed _span to create normal overloads of encode and decode for span
* Some renaming and minor refactoring

* manchester
* Fix build issues

* manchester
* Conditionally compile manchester_decoded

* Update test_manchester.cpp

Removed redundant semicolon

* #1258 Manchester coding
* Formatting
* consistency: hex literals with lower case 0x

* #1258 Manchester coding
* Moved copyright to top of file
* Make constexpr encode/decode span functions equal for little and big endian platforms

* #1258 Manchester coding
* Added missing include
* Added missing 8bit/64bit guards
* Fixed is_valid for big endian platforms

* #1258 Manchester coding
* private memcpy alias

* #1258 Manchester coding
* Review comments

* #1258 Manchester coding
* Cleanup
* Fix build error

* #1258 Manchester coding
* Add manchester documentation

* #1258 Manchester coding
* Preparation for GitHub pages

* #1324 Manchester documentation
* Some small fixes

---------

Co-authored-by: Timon Zijnge <timon.zijnge@imec.nl>

* Changes from review of algorithm.h on development branch (#1340)

* Add missing constexpr in algorithm.h

* Fix call of nth_element

2nd argument (nth) was missing

* Replace partition point with O(log(N)) algorithm

The C++ standard defines O(log(N)) calls of predicate as the
complexity of partition_point(). The old algorithm was linear.

* Use predicate in calculation of is_permutation consistently

In case of predicate not equal_to, the calculation previously
returned wron results

* Omit swap in selection_sort if iterators are equal

* Use difference_type in rotate_general() instead of int

* Typo fix in algorithm.h

* Simplifications in algorithm.h

Application of plain refactoring by keeping semantics

* Guard against past-end iterator in etl::rotate()

And fix scope of rotate_right_by_one for etl::rotate()

* Support empty ranges in selection_sort

* Add tests for swap_ranges

* Add tests for binary_search

* Add tests for find_end

* Add tests for accumulate

* Add tests for move_s

* Added tests for is_heap and sort_heap

* Remove early exit for empty input

* Add adjacent_find

* Add unique

* Add unique_copy

* Add merge

* Add inplace_merge

* Add partial_sort

* Add partial_sort_copy

* copilot review change

---------

Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.com>
Co-authored-by: Roland Reichwein <Roland.Reichwein@bmw.de>
Co-authored-by: Niu Zhihong <zhihong@nzhnb.com>
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Co-authored-by: Timon Zijnge <47081647+tzijnge@users.noreply.github.com>
Co-authored-by: Timon Zijnge <timon.zijnge@imec.nl>
2026-03-12 17:06:26 +00:00
Roland Reichwein
0a56d40bdd
Fix undefined behaviour of etl::absolute() for etl::numeric_limits<T>::min (#1333)
absolute_unsigned() already handled that case correctly. Now adding this
check to absolute() also. It can be caught at compile time now, if in a
constexpr context. Also separating integral and non-integral versions
via enable_if.

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-03-12 16:38:10 +00:00
Roland Reichwein
54a1c82c98
Fix run-syntax-checks.sh to be executable (#1342)
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-03-12 15:54:51 +00:00
Roland Reichwein
4a8c167a31
Changes from review of algorithm.h on development branch (#1340)
* Add missing constexpr in algorithm.h

* Fix call of nth_element

2nd argument (nth) was missing

* Replace partition point with O(log(N)) algorithm

The C++ standard defines O(log(N)) calls of predicate as the
complexity of partition_point(). The old algorithm was linear.

* Use predicate in calculation of is_permutation consistently

In case of predicate not equal_to, the calculation previously
returned wron results

* Omit swap in selection_sort if iterators are equal

* Use difference_type in rotate_general() instead of int

* Typo fix in algorithm.h

* Simplifications in algorithm.h

Application of plain refactoring by keeping semantics

* Guard against past-end iterator in etl::rotate()

And fix scope of rotate_right_by_one for etl::rotate()

* Support empty ranges in selection_sort

* Add tests for swap_ranges

* Add tests for binary_search

* Add tests for find_end

* Add tests for accumulate

* Add tests for move_s

* Added tests for is_heap and sort_heap

* Remove early exit for empty input

* Add adjacent_find

* Add unique

* Add unique_copy

* Add merge

* Add inplace_merge

* Add partial_sort

* Add partial_sort_copy
2026-03-10 20:39:13 +00:00
Timon Zijnge
521df8ee19
Manchester documentation (#1325)
* manchester
* Added manchester code and test

* manchester
* Formatting and added missing file

* manchester
* Some functions can only be constexpr since C++14

* manchester
* Manchester decode and some refactoring

* manchester
* Added some missing typenames

* manchester
* constexpr void function not allowed in C++11

* manchester
* condition on static_assert tests

* manchester
* revert CMakeLists.txt
* Using ETL_STATIC_ASSERT
* Some cleanup

* manchester
* Added static_assert message

* manchester
* Added compile time tests

* manchester
* Added invert manchester
* Some refactoring

* manchester
* Disable test for now
* Move ETL_NODISCARD before static

* manchester
* Test for valid_span

* manchester
* Remove redundant (?) storage specifiers for template specializations. Storage specifier already given in base template

* manchester
* refactoring to get rid of specialized template functions in template class

* manchester
* cleanup

* manchester
* Added documentation comments
* Some refactoring

* manchester
* introducing namespace detail_manchester

* manchester
* Some refactoring
* Update tests

* manchester
* Some refactoring
* Removed possible undefined behavior by refactoring encode_span
* constexpr version of encode_span
* Static assertion for rare case where code doesn't work because CHAR_BIT is not the same as the number of bits in uint_least8_t

* manchester
* renamed valid to is_valid

* manchester
* renamed is_valid_span to is_valid
* Using etl exceptions in ETL_ASSERT

* manchester
* Removed _fast functions
* merged encode_in_place with encode and decode_in_place with decode
* removed _span to create normal overloads of encode and decode for span
* Some renaming and minor refactoring

* manchester
* Fix build issues

* manchester
* Conditionally compile manchester_decoded

* Update test_manchester.cpp

Removed redundant semicolon

* #1258 Manchester coding
* Formatting
* consistency: hex literals with lower case 0x

* #1258 Manchester coding
* Moved copyright to top of file
* Make constexpr encode/decode span functions equal for little and big endian platforms

* #1258 Manchester coding
* Added missing include
* Added missing 8bit/64bit guards
* Fixed is_valid for big endian platforms

* #1258 Manchester coding
* private memcpy alias

* #1258 Manchester coding
* Review comments

* #1258 Manchester coding
* Cleanup
* Fix build error

* #1258 Manchester coding
* Add manchester documentation

* #1258 Manchester coding
* Preparation for GitHub pages

* #1324 Manchester documentation
* Some small fixes

---------

Co-authored-by: Timon Zijnge <timon.zijnge@imec.nl>
2026-03-07 08:13:00 +00:00
Niu Zhihong
8ce59792fd
Add ETL_FORMAT_NO_FLOATING_POINT control macro for etl::format (#1329)
When ETL_FORMAT_NO_FLOATING_POINT is defined, all floating-point formatting support (float, double, long double) is excluded from etl::format. This reduces code size on targets that do not require floating-point formatting.

Guarded sections:

- #include <cmath>

- float/double/long double in supported_format_types variant

- float/double/long double constructors in basic_format_arg

- format_floating_* functions and format_aligned_floating

- formatter<float>, formatter<double>, formatter<long double>

- Floating-point test cases in test_format.cpp

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-03-06 22:04:32 +00:00
Roland Reichwein
67ecc8e11e
Add missing tests (#1321)
* Add missing tests

* Typo fixes

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-03-06 21:34:54 +00:00
Roland Reichwein
7329efc7df
Align comparison operators (#1330)
In functional.h, the comparison operators for equal_to and not_equal_to
mismatch between the actual comparison execution and the type inference
for the return type. This change adjusts it by using the same operator==()
in the return type inference as used in the comparison execution.

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-03-06 20:29:58 +00:00
Roland Reichwein
4ad6126ec5
Fix greater_equal and less_equal (#1331) 2026-03-06 20:08:31 +00:00
John Wellbelove
f96510bd79 Added missing files from VS2022 project 2026-03-06 11:21:38 +00:00
Roland Reichwein
a8ebe338f8
Fix etl::rotate (#1327)
Per the C++ standard, std::rotate returns first + (last - middle):

* When first == middle, return last
* When middle == last, return first
2026-03-06 10:11:46 +00:00
John Wellbelove
7bac1d02f7 Updated release notes and version 2026-03-02 09:16:18 +00:00
John Wellbelove
25c9235cbc
Changed std::is_same to etl::is_same in struct type_list_is_unique (#1320)
Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.com>
2026-03-02 09:13:19 +00:00
John Wellbelove
6ed9ca3f1d Updated release notes and version 2026-03-01 13:12:44 +00:00
John Wellbelove
7ee7f10f58
Hotfix/etl multiset iterator invalidation during erase leads to incorrect sorted order in depth first traversal (#1317)
* Fixed issue for both multiset and multimap

* Added std::is_sorted checks to all map/set tests

* Updated with coderabbit suggestions

---------

Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.com>
2026-03-01 12:27:39 +00:00
John Wellbelove
70e4850a0b Updated version and release notes 2026-02-27 17:43:47 +00:00
John Wellbelove
089f65cce1
Added get_endianness() to etl::byte_stream_reader (#1315)
Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.com>
2026-02-27 11:18:29 +00:00
Timon Zijnge
810a106bdf
#1258 Manchester coding (#1285)
* manchester
* Added manchester code and test

* manchester
* Formatting and added missing file

* manchester
* Some functions can only be constexpr since C++14

* manchester
* Manchester decode and some refactoring

* manchester
* Added some missing typenames

* manchester
* constexpr void function not allowed in C++11

* manchester
* condition on static_assert tests

* manchester
* revert CMakeLists.txt
* Using ETL_STATIC_ASSERT
* Some cleanup

* manchester
* Added static_assert message

* manchester
* Added compile time tests

* manchester
* Added invert manchester
* Some refactoring

* manchester
* Disable test for now
* Move ETL_NODISCARD before static

* manchester
* Test for valid_span

* manchester
* Remove redundant (?) storage specifiers for template specializations. Storage specifier already given in base template

* manchester
* refactoring to get rid of specialized template functions in template class

* manchester
* cleanup

* manchester
* Added documentation comments
* Some refactoring

* manchester
* introducing namespace detail_manchester

* manchester
* Some refactoring
* Update tests

* manchester
* Some refactoring
* Removed possible undefined behavior by refactoring encode_span
* constexpr version of encode_span
* Static assertion for rare case where code doesn't work because CHAR_BIT is not the same as the number of bits in uint_least8_t

* manchester
* renamed valid to is_valid

* manchester
* renamed is_valid_span to is_valid
* Using etl exceptions in ETL_ASSERT

* manchester
* Removed _fast functions
* merged encode_in_place with encode and decode_in_place with decode
* removed _span to create normal overloads of encode and decode for span
* Some renaming and minor refactoring

* manchester
* Fix build issues

* manchester
* Conditionally compile manchester_decoded

* Update test_manchester.cpp

Removed redundant semicolon

* #1258 Manchester coding
* Formatting
* consistency: hex literals with lower case 0x

* #1258 Manchester coding
* Moved copyright to top of file
* Make constexpr encode/decode span functions equal for little and big endian platforms

* #1258 Manchester coding
* Added missing include
* Added missing 8bit/64bit guards
* Fixed is_valid for big endian platforms

* #1258 Manchester coding
* private memcpy alias

* #1258 Manchester coding
* Review comments

* #1258 Manchester coding
* Cleanup
* Fix build error

---------

Co-authored-by: Timon Zijnge <timon.zijnge@imec.nl>
2026-02-27 09:40:42 +00:00
John Wellbelove
7ef01fcaed
Enforce worse-case O(log n) dispatch for messages when using message router for c++11 and up (#1312)
* Added compare_message_id

* Added new C++11 and up message routing code using a sorted type_list

* Renamed compare_message)id to compare_message_id_less

* Added documenation for compare_message_id_less

Added static asserts for message type template parameters

* Added optimisation for contiguous message IDs

Added more Doxygen documentation

* Added etl::type_list_all_of, etl::type_list_any_of, and etl::type_list_none_of

* Added etl::type_list_is_unique

* Added common definitions to all router types

* Added static_asserts to check message types

* Added etl::type_list to etl::nth_type

* Added missing 'typename' to type_list nth_type

* Added type_list_is_empty

* indentation fix

* Renamed type_list_prepend & type_list_append to type_list_push_front & type_list_push_back respectively

* Added tests for make_index_sequence & make_index_sequence_with_offset

* Add more features to etl::type_list (#1307)

* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Added etl::type_list to etl::observer

* Added etl::type_list to etl::nth_type

* Added missing 'typename' to type_list nth_type

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Added type_list definitions for nth_type and observer

* Added etl::type_list to etl::variant

* Updated comments

* Addedetl::type~_list to message_router, observer, visitor

# Conflicts:
#	include/etl/observer.h
#	test/vs2022/etl.vcxproj.filters

* Added member type_list type to tuple

* Work in progress

* Copy changes from other source

* Removed unused tests

* Fix iter_swap namespace

* Add type_list functionality to etl::variant using etl::variant_from_type_list

* Add type_list functionality to etl::message_packet using etl::message_packet_from_type_list

* Add type_list functionality to etl::message_router using etl::message_router_from_type_list

* Add type_list functionality to etl::observer using etl::observer_from_type_list

* Add type_list functionality to etl::tuple using etl::tuple_from_type_list

* Allow etl::make_index_sequence to be created from an etl::type_list

* Add type_list functionality to etl::visitor using etl::visitor_from_type_list

* Fix iter_swap namespace

* Allow creation of a message_packet with no message types

* Allow creation of a message_router with no message types

* Updated VS2022 project files

* Added missing test files CMakeLists.txt

* Fix C++03 compatibility

Fixed unused aregument warnings

* Synced message_packet generator to updated code

* Synced message_router generator to updated code

* Synced message_router generator to updated code

# Conflicts:
#	include/etl/generators/message_router_generator.h
#	include/etl/message_router.h

* Fixed missing zero message specialisation for <= C++14

* Fixed missing zero message specialisation for <= C++14

* Fix year_month arithmetic and correct chrono API behavior (#1257)

* Fix & add more tests for year_month arithmetic

* Minor addtions to previous commit

* More missing values to be uninitialized

* Update the default constructors to = default and correct default constructor tests accordingly

* Fix & add more tests for year_month arithmetic

* Minor addtions to previous commit

* More missing values to be uninitialized

* Update the default constructors to = default and correct default constructor tests accordingly

* Restore default constructor behavior for chrono calender

* Suppress warnings from std in optimized builds (#1259)

When testing with ./run-tests.sh 23 3 10, some warnings from
std surfaced which resulted in build errors.

* Add template deduction guide for span from vector (#1264)

* Create span from vector deduction

* Use ivector for deduction.  Add vector_ext to test

* Add vector pointer to test

* Finish tests

* Initialize pdata_ext and others

* Document how to implement platform specifics (#1262)

Some interfaces need to be implemented in every project
or platform using the ETL:

* etl_get_high_resolution_clock
* etl_get_system_clock
* etl_get_steady_clock
* etl_putchar

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>

* Fix etl::as_bytes for etl::span<const T> (#1266)

A missing 'const' in the etl::as_bytes implementation was causing a
compile-time error when etl::as_bytes was called on a span of const
values.

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>

* Remove some UB in test_vector_non_trivial.cpp (#1268)

Some of the tests' UB are detectable by Gcc15 and thus give a compile error due to warnings-as-error flag.

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>

* Update C++26 deprecated constructs to ensure future standard compliance (#1267)

* Update C++26 deprecated constructs to ensure future standard compliance

I replaced std::is_trivial with a combination of std::is_trivially_default_constructible and std::is_trivially_copyable. Additionally, I added the required comma before the ellipsis in variadic functions to match updated language specifications.

* Some additional is_trivial related changes not found directly when compiling tests in C++26

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>

* Fix return value of get_token_list (#1271)

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>

* Fix etl::tuple template signature error in pair assignment operator (#1265)

* Fix etl::tuple template signature error in pair assignment operator

* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update etl::tuple to explicitly use etl::pair or std::pair in assignment operator

* Added tests for etl::tuple assignment from pair

---------

Co-authored-by: Bryton Flecker <bflecker@swe.com>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>

* Remove advance() on static spans (#1281)

* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Remove advance() on static spans

Since the size of a static span is constant, we can't reasonably
advance() on it.

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>

* Add missing includes (#1286)

* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Add missing includes

Before this change, the includes needed to be done explicitly by
files using basic_string_stream.h, and be included first. This
was error prone, especially if includes are reordered (e.g. via
the currently defined clang-format rules).

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>

* Move comparison operators of etl::expected to namespace etl (#1287)

* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Move comparison operators of etl::expected to namespace etl

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>

* Make typed_storage constructor constexpr (#1291)

* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Make typed_storage constructor constexpr

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>

* Add basic_format_arg constructor for ibasic_string (#1288)

* Allow string as format arg

* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Added test string escaped

* Add temporary string test

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>

* QR Code for Github

* Added etl::visitor_from_type_list

* accepts(id) for empty router passes on to a sucessor

* Fixed incorrect comment from 'tuple' to 'message_router'

* PR review changes

* PR review changes

* Fixed internal constexptr flag in message_packet

* Fixed unused variable in unti test

* Added new type_list features

Added make_index_sequence_with_offset

* Renamed type_list_select_from_sequence to type_list_select_from_index_sequence

* Replaced type_list_size<TTypeList>::value with TTypeList::size internally for better clarity.

* Added etl::type_list_remove, etl::type_list_remove_if, etl::type_list_unique, etl::type_list_pop_front, etl::type_list_pop_back

* Add ref-qualifiers to basic_format_spec (#1292)

* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* feat: use ref-qualifiers for basic_format_spec

Converted the l-value methods to ref-qualified and also added r-value ref-qualified methods.

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>

* Add support for size_t and unsigned long to etl::format (#1290)

* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Add support for size_t and unsigned long to etl::format

* Document list of supported types in etl::supported_format_types

* Add further types and tests for etl::format

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>

* Deduce underlying storage size when constructing string_ext from char[]. (#1269)

* Deduce underlying storage size when constructing string_ext from char[].

This removes the need for passing sizeof(storage) to the constructor.

* Add array constructors for the other string types.

- u16string_ext
- u32string_ext
- u8string_ext
- wstring_ext

* Add additional constructors to match existing API.

* Fix inconsistent test argument order.

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>

* Added etl::type_list_all_of, etl::type_list_any_of, and etl::type_list_none_of

* Added etl::type_list_is_unique

* Added type_list_is_empty

* indentation fix

* Fix merge error

* Renamed type_list_prepend & type_list_append to type_list_push_front & type_list_push_back respectively

* Added tests for make_index_sequence & make_index_sequence_with_offset

* Resolve coderabbit review issues

* Resolve coderabbit review issues

* Resolve coderabbit review issues

* Resolve coderabbit review issues

* Added  etl::type_list_indices_of_type which create an etl::index_sequence of all of the indexes of a specified type in an etl::type_list

* Updated comments

* Resolve coderabbit review issues

Added index_sequence utility to support type_list utilities. Added additional index_sequence utilities for completeness

* Added etl::index_sequence_cat, etl::index_sequence_pop_front, etl::index_sequence_pop_back, etl::index_sequence_at

* Fix 'unused variable' error in index_sequence tests

---------

Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.co.uk>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>
Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.com>
Co-authored-by: Bo Rydberg <2945606+bolry@users.noreply.github.com>
Co-authored-by: Roland Reichwein <Roland.Reichwein@bmw.de>
Co-authored-by: Mike Bloom <91038685+mike919192@users.noreply.github.com>
Co-authored-by: taltenbach <92919739+taltenbach@users.noreply.github.com>
Co-authored-by: Bryton Flecker <fleckerbr@gmail.com>
Co-authored-by: Bryton Flecker <bflecker@swe.com>
Co-authored-by: Drew Rife <drew.rife95@gmail.com>
Co-authored-by: Marco Nilsson <marco@zyax.se>

* Moved O(1)/O(logN) index search test to get_dispatch_index_from_message_id

Updated message_router generator

* Fixed C++03 compatibilty

* Replaced is_base_of with is_message

* Missing 'return' in chrono example

* Fixed doxygen comments

* Check message inherits from etl::message<>

* Copilot & coderabbit review changes

Check for no duplicated message IDs
Added diagnostic disable
Make Message_Id_Start an etl::message_id_t type

* Synchronised message_router_generator.h

* Modified the "All message IDs must be unique" static_assert to directly use the index_sequence of message IDs

Added addition index_sequence utilities to support this change.

* Changed Router1 definition to use unordered message ids to check message sorting in message_router

* Added has_message_id and compare_message_id_less to message.h

* Moved member type definitions to a traits class

message_packet, message_types, sorted_message_types

* Sync message_router_generator to changes

* Fixed C++03 compatibility

---------

Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.com>
Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.co.uk>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>
Co-authored-by: Bo Rydberg <2945606+bolry@users.noreply.github.com>
Co-authored-by: Roland Reichwein <Roland.Reichwein@bmw.de>
Co-authored-by: Mike Bloom <91038685+mike919192@users.noreply.github.com>
Co-authored-by: taltenbach <92919739+taltenbach@users.noreply.github.com>
Co-authored-by: Bryton Flecker <fleckerbr@gmail.com>
Co-authored-by: Bryton Flecker <bflecker@swe.com>
Co-authored-by: Drew Rife <drew.rife95@gmail.com>
Co-authored-by: Marco Nilsson <marco@zyax.se>
2026-02-26 10:34:14 +00:00
Roland Reichwein
e439963258
Fix etl::variant get() for ambiguous types (#1304)
When a type occured multiple times in a variant, comparison operator
asserted before.

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-02-25 09:42:56 +00:00
Marco Nilsson
37aba58965
Reduce string flash usage (#1309)
* Remove call to initialise() in constructors.

The constructor execution flows were:

 constructor
   initialise()
   assign()
     append_impl()

initialise() does:
 - Set current_size to 0
 - Null terminate the buffer
 - Clear truncation flag

append_impl() does:
 - Assign truncation flag
 - Set current size to source size
 - Copy and null terminate the buffer

All the hard work done by initialise() is immediately overwritten. Removing the
call to initialise() saves 6-8 bytes of flash per constructor invocation when
targeting Cortex M33 with -Os.

* Avoid calling templated assign(iter, iter) with C strings.

Call the single pointer version of assign which ends up in the non-templated
append_impl. This calls the C lib's strlen and memmove rather than etl::strlen
which is a hand rolled loop.

This also reduces the risk of instantiating the iterator version of assign() if
it's not used elsewhere.

* Dispatch pointer iterators to non-template append_impl core.

When append_impl is called with pointer iterators (e.g. begin()/end()), SFINAE
routes them to a non-template core that takes a pointer and length. This
avoids duplicating the function body for each pointer type instantiation,
reducing flash usage on ARM Cortex-M by ~836 bytes at -Os.

* Revert make_string changes.

The original implementation used a bounded strlen which avoided OOB array access.

* Treat start, free_space and count as size_t to avoid casts.

* Ensure that append start is within the buffer.

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-02-25 09:02:02 +00:00
John Wellbelove
7a8944224b
Add more features to etl::type_list (#1307)
* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Added etl::type_list to etl::observer

* Added etl::type_list to etl::nth_type

* Added missing 'typename' to type_list nth_type

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Added type_list definitions for nth_type and observer

* Added etl::type_list to etl::variant

* Updated comments

* Addedetl::type~_list to message_router, observer, visitor

# Conflicts:
#	include/etl/observer.h
#	test/vs2022/etl.vcxproj.filters

* Added member type_list type to tuple

* Work in progress

* Copy changes from other source

* Removed unused tests

* Fix iter_swap namespace

* Add type_list functionality to etl::variant using etl::variant_from_type_list

* Add type_list functionality to etl::message_packet using etl::message_packet_from_type_list

* Add type_list functionality to etl::message_router using etl::message_router_from_type_list

* Add type_list functionality to etl::observer using etl::observer_from_type_list

* Add type_list functionality to etl::tuple using etl::tuple_from_type_list

* Allow etl::make_index_sequence to be created from an etl::type_list

* Add type_list functionality to etl::visitor using etl::visitor_from_type_list

* Fix iter_swap namespace

* Allow creation of a message_packet with no message types

* Allow creation of a message_router with no message types

* Updated VS2022 project files

* Added missing test files CMakeLists.txt

* Fix C++03 compatibility

Fixed unused aregument warnings

* Synced message_packet generator to updated code

* Synced message_router generator to updated code

* Synced message_router generator to updated code

# Conflicts:
#	include/etl/generators/message_router_generator.h
#	include/etl/message_router.h

* Fixed missing zero message specialisation for <= C++14

* Fixed missing zero message specialisation for <= C++14

* Fix year_month arithmetic and correct chrono API behavior (#1257)

* Fix & add more tests for year_month arithmetic

* Minor addtions to previous commit

* More missing values to be uninitialized

* Update the default constructors to = default and correct default constructor tests accordingly

* Fix & add more tests for year_month arithmetic

* Minor addtions to previous commit

* More missing values to be uninitialized

* Update the default constructors to = default and correct default constructor tests accordingly

* Restore default constructor behavior for chrono calender

* Suppress warnings from std in optimized builds (#1259)

When testing with ./run-tests.sh 23 3 10, some warnings from
std surfaced which resulted in build errors.

* Add template deduction guide for span from vector (#1264)

* Create span from vector deduction

* Use ivector for deduction.  Add vector_ext to test

* Add vector pointer to test

* Finish tests

* Initialize pdata_ext and others

* Document how to implement platform specifics (#1262)

Some interfaces need to be implemented in every project
or platform using the ETL:

* etl_get_high_resolution_clock
* etl_get_system_clock
* etl_get_steady_clock
* etl_putchar

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>

* Fix etl::as_bytes for etl::span<const T> (#1266)

A missing 'const' in the etl::as_bytes implementation was causing a
compile-time error when etl::as_bytes was called on a span of const
values.

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>

* Remove some UB in test_vector_non_trivial.cpp (#1268)

Some of the tests' UB are detectable by Gcc15 and thus give a compile error due to warnings-as-error flag.

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>

* Update C++26 deprecated constructs to ensure future standard compliance (#1267)

* Update C++26 deprecated constructs to ensure future standard compliance

I replaced std::is_trivial with a combination of std::is_trivially_default_constructible and std::is_trivially_copyable. Additionally, I added the required comma before the ellipsis in variadic functions to match updated language specifications.

* Some additional is_trivial related changes not found directly when compiling tests in C++26

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>

* Fix return value of get_token_list (#1271)

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>

* Fix etl::tuple template signature error in pair assignment operator (#1265)

* Fix etl::tuple template signature error in pair assignment operator

* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update etl::tuple to explicitly use etl::pair or std::pair in assignment operator

* Added tests for etl::tuple assignment from pair

---------

Co-authored-by: Bryton Flecker <bflecker@swe.com>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>

* Remove advance() on static spans (#1281)

* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Remove advance() on static spans

Since the size of a static span is constant, we can't reasonably
advance() on it.

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>

* Add missing includes (#1286)

* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Add missing includes

Before this change, the includes needed to be done explicitly by
files using basic_string_stream.h, and be included first. This
was error prone, especially if includes are reordered (e.g. via
the currently defined clang-format rules).

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>

* Move comparison operators of etl::expected to namespace etl (#1287)

* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Move comparison operators of etl::expected to namespace etl

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>

* Make typed_storage constructor constexpr (#1291)

* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Make typed_storage constructor constexpr

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>

* Add basic_format_arg constructor for ibasic_string (#1288)

* Allow string as format arg

* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Added test string escaped

* Add temporary string test

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>

* QR Code for Github

* Added etl::visitor_from_type_list

* accepts(id) for empty router passes on to a sucessor

* Fixed incorrect comment from 'tuple' to 'message_router'

* PR review changes

* PR review changes

* Fixed internal constexptr flag in message_packet

* Fixed unused variable in unti test

* Added new type_list features

Added make_index_sequence_with_offset

* Renamed type_list_select_from_sequence to type_list_select_from_index_sequence

* Replaced type_list_size<TTypeList>::value with TTypeList::size internally for better clarity.

* Added etl::type_list_remove, etl::type_list_remove_if, etl::type_list_unique, etl::type_list_pop_front, etl::type_list_pop_back

* Add ref-qualifiers to basic_format_spec (#1292)

* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* feat: use ref-qualifiers for basic_format_spec

Converted the l-value methods to ref-qualified and also added r-value ref-qualified methods.

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>

* Add support for size_t and unsigned long to etl::format (#1290)

* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Add support for size_t and unsigned long to etl::format

* Document list of supported types in etl::supported_format_types

* Add further types and tests for etl::format

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>

* Deduce underlying storage size when constructing string_ext from char[]. (#1269)

* Deduce underlying storage size when constructing string_ext from char[].

This removes the need for passing sizeof(storage) to the constructor.

* Add array constructors for the other string types.

- u16string_ext
- u32string_ext
- u8string_ext
- wstring_ext

* Add additional constructors to match existing API.

* Fix inconsistent test argument order.

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>

* Added etl::type_list_all_of, etl::type_list_any_of, and etl::type_list_none_of

* Added etl::type_list_is_unique

* Added type_list_is_empty

* indentation fix

* Fix merge error

* Renamed type_list_prepend & type_list_append to type_list_push_front & type_list_push_back respectively

* Added tests for make_index_sequence & make_index_sequence_with_offset

* Resolve coderabbit review issues

* Resolve coderabbit review issues

* Resolve coderabbit review issues

* Resolve coderabbit review issues

* Added  etl::type_list_indices_of_type which create an etl::index_sequence of all of the indexes of a specified type in an etl::type_list

* Updated comments

* Resolve coderabbit review issues

Added index_sequence utility to support type_list utilities. Added additional index_sequence utilities for completeness

* Added etl::index_sequence_cat, etl::index_sequence_pop_front, etl::index_sequence_pop_back, etl::index_sequence_at

* Fix 'unused variable' error in index_sequence tests

---------

Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.co.uk>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>
Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.com>
Co-authored-by: Bo Rydberg <2945606+bolry@users.noreply.github.com>
Co-authored-by: Roland Reichwein <Roland.Reichwein@bmw.de>
Co-authored-by: Mike Bloom <91038685+mike919192@users.noreply.github.com>
Co-authored-by: taltenbach <92919739+taltenbach@users.noreply.github.com>
Co-authored-by: Bryton Flecker <fleckerbr@gmail.com>
Co-authored-by: Bryton Flecker <bflecker@swe.com>
Co-authored-by: Drew Rife <drew.rife95@gmail.com>
Co-authored-by: Marco Nilsson <marco@zyax.se>
2026-02-21 09:36:48 +00:00
John Wellbelove
58b5bf5190 Added tests for make_index_sequence & make_index_sequence_with_offset 2026-02-19 19:35:49 +00:00
John Wellbelove
55da732fc8 Renamed type_list_prepend & type_list_append to type_list_push_front & type_list_push_back respectively 2026-02-19 19:23:36 +00:00
John Wellbelove
1d47e1b731 Fix merge error 2026-02-19 19:05:53 +00:00
John Wellbelove
52e57bc8b6 Merge branch 'development' into feature/Add-more-type_list-features
# Conflicts:
#	include/etl/utility.h
2026-02-19 19:03:41 +00:00
John Wellbelove
56dce4a3aa indentation fix 2026-02-19 18:23:58 +00:00
John Wellbelove
9ebcf41e63 Added type_list_is_empty 2026-02-19 13:29:11 +00:00
Roland Reichwein
992348b4bb
Add constexpr to array comparison operators (#1303)
* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Add constexpr to array comparison operators

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>
2026-02-19 13:18:12 +00:00
John Wellbelove
226117b972
Add etl::type_list API to more classes. (#1275)
* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Added etl::type_list to etl::observer

* Added etl::type_list to etl::nth_type

* Added missing 'typename' to type_list nth_type

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Added type_list definitions for nth_type and observer

* Added etl::type_list to etl::variant

* Updated comments

* Addedetl::type~_list to message_router, observer, visitor

# Conflicts:
#	include/etl/observer.h
#	test/vs2022/etl.vcxproj.filters

* Added member type_list type to tuple

* Work in progress

* Copy changes from other source

* Removed unused tests

* Fix iter_swap namespace

* Add type_list functionality to etl::variant using etl::variant_from_type_list

* Add type_list functionality to etl::message_packet using etl::message_packet_from_type_list

* Add type_list functionality to etl::message_router using etl::message_router_from_type_list

* Add type_list functionality to etl::observer using etl::observer_from_type_list

* Add type_list functionality to etl::tuple using etl::tuple_from_type_list

* Allow etl::make_index_sequence to be created from an etl::type_list

* Add type_list functionality to etl::visitor using etl::visitor_from_type_list

* Fix iter_swap namespace

* Allow creation of a message_packet with no message types

* Allow creation of a message_router with no message types

* Updated VS2022 project files

* Added missing test files CMakeLists.txt

* Fix C++03 compatibility

Fixed unused aregument warnings

* Synced message_packet generator to updated code

* Synced message_router generator to updated code

* Synced message_router generator to updated code

# Conflicts:
#	include/etl/generators/message_router_generator.h
#	include/etl/message_router.h

* Fixed missing zero message specialisation for <= C++14

* Fixed missing zero message specialisation for <= C++14

* Fix year_month arithmetic and correct chrono API behavior (#1257)

* Fix & add more tests for year_month arithmetic

* Minor addtions to previous commit

* More missing values to be uninitialized

* Update the default constructors to = default and correct default constructor tests accordingly

* Fix & add more tests for year_month arithmetic

* Minor addtions to previous commit

* More missing values to be uninitialized

* Update the default constructors to = default and correct default constructor tests accordingly

* Restore default constructor behavior for chrono calender

* Suppress warnings from std in optimized builds (#1259)

When testing with ./run-tests.sh 23 3 10, some warnings from
std surfaced which resulted in build errors.

* Add template deduction guide for span from vector (#1264)

* Create span from vector deduction

* Use ivector for deduction.  Add vector_ext to test

* Add vector pointer to test

* Finish tests

* Initialize pdata_ext and others

* Document how to implement platform specifics (#1262)

Some interfaces need to be implemented in every project
or platform using the ETL:

* etl_get_high_resolution_clock
* etl_get_system_clock
* etl_get_steady_clock
* etl_putchar

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>

* Fix etl::as_bytes for etl::span<const T> (#1266)

A missing 'const' in the etl::as_bytes implementation was causing a
compile-time error when etl::as_bytes was called on a span of const
values.

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>

* Remove some UB in test_vector_non_trivial.cpp (#1268)

Some of the tests' UB are detectable by Gcc15 and thus give a compile error due to warnings-as-error flag.

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>

* Update C++26 deprecated constructs to ensure future standard compliance (#1267)

* Update C++26 deprecated constructs to ensure future standard compliance

I replaced std::is_trivial with a combination of std::is_trivially_default_constructible and std::is_trivially_copyable. Additionally, I added the required comma before the ellipsis in variadic functions to match updated language specifications.

* Some additional is_trivial related changes not found directly when compiling tests in C++26

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>

* Fix return value of get_token_list (#1271)

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>

* Fix etl::tuple template signature error in pair assignment operator (#1265)

* Fix etl::tuple template signature error in pair assignment operator

* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update etl::tuple to explicitly use etl::pair or std::pair in assignment operator

* Added tests for etl::tuple assignment from pair

---------

Co-authored-by: Bryton Flecker <bflecker@swe.com>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>

* Remove advance() on static spans (#1281)

* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Remove advance() on static spans

Since the size of a static span is constant, we can't reasonably
advance() on it.

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>

* Add missing includes (#1286)

* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Add missing includes

Before this change, the includes needed to be done explicitly by
files using basic_string_stream.h, and be included first. This
was error prone, especially if includes are reordered (e.g. via
the currently defined clang-format rules).

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>

* Move comparison operators of etl::expected to namespace etl (#1287)

* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Move comparison operators of etl::expected to namespace etl

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>

* Make typed_storage constructor constexpr (#1291)

* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Make typed_storage constructor constexpr

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>

* Add basic_format_arg constructor for ibasic_string (#1288)

* Allow string as format arg

* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Added test string escaped

* Add temporary string test

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>

* QR Code for Github

* Added etl::visitor_from_type_list

* accepts(id) for empty router passes on to a sucessor

* Fixed incorrect comment from 'tuple' to 'message_router'

* PR review changes

* PR review changes

* Fixed internal constexptr flag in message_packet

* Fixed unused variable in unti test

---------

Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.co.uk>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>
Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.com>
Co-authored-by: Bo Rydberg <2945606+bolry@users.noreply.github.com>
Co-authored-by: Roland Reichwein <Roland.Reichwein@bmw.de>
Co-authored-by: Mike Bloom <91038685+mike919192@users.noreply.github.com>
Co-authored-by: taltenbach <92919739+taltenbach@users.noreply.github.com>
Co-authored-by: Bryton Flecker <fleckerbr@gmail.com>
Co-authored-by: Bryton Flecker <bflecker@swe.com>
2026-02-19 12:41:48 +00:00
John Wellbelove
2ba5e93d01 Added etl::type_list_is_unique 2026-02-19 10:00:57 +00:00
John Wellbelove
25b88e509b Added etl::type_list_all_of, etl::type_list_any_of, and etl::type_list_none_of 2026-02-19 09:16:13 +00:00
John Wellbelove
1b244ec4c0
Fix link rotations for etl::tree_node (#1299)
* Fixed tree node rotate

Improved tree node rotate tests to test all links.

* Removed trailing whitespace

* Removed trailing whitespace

---------

Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.com>
2026-02-18 20:46:21 +00:00
Benedek Kupper
bfbb7259e1 delegate: allow constructing from non-capturing lambdas
Signed-off-by: Benedek Kupper <kupper.benedek@gmail.com>
2026-02-10 22:35:52 +01:00
Marco Nilsson
dc0f62cc3f Deduce underlying storage size when constructing string_ext from char[]. (#1269)
* Deduce underlying storage size when constructing string_ext from char[].

This removes the need for passing sizeof(storage) to the constructor.

* Add array constructors for the other string types.

- u16string_ext
- u32string_ext
- u8string_ext
- wstring_ext

* Add additional constructors to match existing API.

* Fix inconsistent test argument order.

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-02-09 11:07:13 +00:00
Roland Reichwein
13c90eb8f2 Add support for size_t and unsigned long to etl::format (#1290)
* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Add support for size_t and unsigned long to etl::format

* Document list of supported types in etl::supported_format_types

* Add further types and tests for etl::format

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>
2026-02-09 11:07:13 +00:00
Drew Rife
4cf97675bd Add ref-qualifiers to basic_format_spec (#1292)
* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* feat: use ref-qualifiers for basic_format_spec

Converted the l-value methods to ref-qualified and also added r-value ref-qualified methods.

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>
2026-02-09 11:07:12 +00:00
Marco Nilsson
45b352a059
Deduce underlying storage size when constructing string_ext from char[]. (#1269)
* Deduce underlying storage size when constructing string_ext from char[].

This removes the need for passing sizeof(storage) to the constructor.

* Add array constructors for the other string types.

- u16string_ext
- u32string_ext
- u8string_ext
- wstring_ext

* Add additional constructors to match existing API.

* Fix inconsistent test argument order.

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-02-09 11:01:20 +00:00
John Wellbelove
43972b416e Added etl::type_list_remove, etl::type_list_remove_if, etl::type_list_unique, etl::type_list_pop_front, etl::type_list_pop_back 2026-02-09 10:56:23 +00:00
John Wellbelove
f25e6b9d07 Replaced type_list_size<TTypeList>::value with TTypeList::size internally for better clarity. 2026-02-09 07:48:41 +00:00
John Wellbelove
81c8e351ff Renamed type_list_select_from_sequence to type_list_select_from_index_sequence 2026-02-08 21:22:07 +00:00
John Wellbelove
fe1f19ce4d Added new type_list features
Added make_index_sequence_with_offset
2026-02-08 10:42:03 +00:00
Roland Reichwein
10fd81c2be
Add support for size_t and unsigned long to etl::format (#1290)
* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Add support for size_t and unsigned long to etl::format

* Document list of supported types in etl::supported_format_types

* Add further types and tests for etl::format

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>
2026-02-06 10:08:17 +00:00
Drew Rife
2a79845dd5
Add ref-qualifiers to basic_format_spec (#1292)
* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* feat: use ref-qualifiers for basic_format_spec

Converted the l-value methods to ref-qualified and also added r-value ref-qualified methods.

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>
2026-02-06 09:32:54 +00:00
John Wellbelove
82f168c96e Fixed unused variable in unti test 2026-02-05 20:57:54 +00:00
John Wellbelove
6cec4a3971 Fixed internal constexptr flag in message_packet 2026-02-05 11:42:09 +00:00
John Wellbelove
ca6bbd50d0 PR review changes 2026-02-05 11:01:51 +00:00
John Wellbelove
1e2b69bc95 PR review changes 2026-02-05 10:53:08 +00:00
John Wellbelove
2e54c01c69 Fixed incorrect comment from 'tuple' to 'message_router' 2026-02-03 20:35:44 +00:00
John Wellbelove
fc7c80bb97 accepts(id) for empty router passes on to a sucessor 2026-02-03 20:34:04 +00:00
John Wellbelove
a4c2272ad6
Merge branch 'development' into feature/#1234-Add-etl--type_list-API-to-more-classes 2026-02-03 09:05:31 +00:00
John Wellbelove
58619ec675 Added etl::visitor_from_type_list 2026-02-03 08:59:56 +00:00
John Wellbelove
3826e2ab2e QR Code for Github 2026-02-03 08:59:55 +00:00
Mike Bloom
e80623bc1a Add basic_format_arg constructor for ibasic_string (#1288)
* Allow string as format arg

* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Added test string escaped

* Add temporary string test

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>
2026-02-03 08:59:55 +00:00
Roland Reichwein
75eb6680d6 Make typed_storage constructor constexpr (#1291)
* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Make typed_storage constructor constexpr

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>
2026-02-03 08:59:54 +00:00
Roland Reichwein
353c36c393 Move comparison operators of etl::expected to namespace etl (#1287)
* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Move comparison operators of etl::expected to namespace etl

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>
2026-02-03 08:59:53 +00:00
Roland Reichwein
d8d4187176 Add missing includes (#1286)
* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Add missing includes

Before this change, the includes needed to be done explicitly by
files using basic_string_stream.h, and be included first. This
was error prone, especially if includes are reordered (e.g. via
the currently defined clang-format rules).

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>
2026-02-03 08:59:53 +00:00
Roland Reichwein
17e6167317 Remove advance() on static spans (#1281)
* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Remove advance() on static spans

Since the size of a static span is constant, we can't reasonably
advance() on it.

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>
2026-02-03 08:59:52 +00:00
Bryton Flecker
012bbea249 Fix etl::tuple template signature error in pair assignment operator (#1265)
* Fix etl::tuple template signature error in pair assignment operator

* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update etl::tuple to explicitly use etl::pair or std::pair in assignment operator

* Added tests for etl::tuple assignment from pair

---------

Co-authored-by: Bryton Flecker <bflecker@swe.com>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-02-03 08:59:51 +00:00
Mike Bloom
8b0fd64289 Fix return value of get_token_list (#1271)
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-02-03 08:59:51 +00:00
Bo Rydberg
dbaffa9169 Update C++26 deprecated constructs to ensure future standard compliance (#1267)
* Update C++26 deprecated constructs to ensure future standard compliance

I replaced std::is_trivial with a combination of std::is_trivially_default_constructible and std::is_trivially_copyable. Additionally, I added the required comma before the ellipsis in variadic functions to match updated language specifications.

* Some additional is_trivial related changes not found directly when compiling tests in C++26

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-02-03 08:59:50 +00:00
Bo Rydberg
a843650649 Remove some UB in test_vector_non_trivial.cpp (#1268)
Some of the tests' UB are detectable by Gcc15 and thus give a compile error due to warnings-as-error flag.

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-02-03 08:59:49 +00:00
taltenbach
d419bbf16f Fix etl::as_bytes for etl::span<const T> (#1266)
A missing 'const' in the etl::as_bytes implementation was causing a
compile-time error when etl::as_bytes was called on a span of const
values.

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-02-03 08:59:49 +00:00
Roland Reichwein
24421edd29 Document how to implement platform specifics (#1262)
Some interfaces need to be implemented in every project
or platform using the ETL:

* etl_get_high_resolution_clock
* etl_get_system_clock
* etl_get_steady_clock
* etl_putchar

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-02-03 08:59:48 +00:00
Mike Bloom
45e5668782 Add template deduction guide for span from vector (#1264)
* Create span from vector deduction

* Use ivector for deduction.  Add vector_ext to test

* Add vector pointer to test

* Finish tests

* Initialize pdata_ext and others
2026-02-03 08:59:47 +00:00
Roland Reichwein
2a727b12b4 Suppress warnings from std in optimized builds (#1259)
When testing with ./run-tests.sh 23 3 10, some warnings from
std surfaced which resulted in build errors.
2026-02-03 08:59:47 +00:00
Bo Rydberg
86fea52f5c Fix year_month arithmetic and correct chrono API behavior (#1257)
* Fix & add more tests for year_month arithmetic

* Minor addtions to previous commit

* More missing values to be uninitialized

* Update the default constructors to = default and correct default constructor tests accordingly

* Fix & add more tests for year_month arithmetic

* Minor addtions to previous commit

* More missing values to be uninitialized

* Update the default constructors to = default and correct default constructor tests accordingly

* Restore default constructor behavior for chrono calender
2026-02-03 08:59:46 +00:00
John Wellbelove
21a1f58299 QR Code for Github 2026-02-02 19:32:04 +00:00
Mike Bloom
b51968d6dd
Add basic_format_arg constructor for ibasic_string (#1288)
* Allow string as format arg

* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Added test string escaped

* Add temporary string test

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>
2026-02-02 18:35:25 +00:00
Roland Reichwein
a3c8f80216
Make typed_storage constructor constexpr (#1291)
* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Make typed_storage constructor constexpr

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>
2026-02-02 16:43:26 +00:00
Roland Reichwein
570a7adaa3
Move comparison operators of etl::expected to namespace etl (#1287)
* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Move comparison operators of etl::expected to namespace etl

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>
2026-02-02 10:46:00 +00:00
Roland Reichwein
db89cc8920
Add missing includes (#1286)
* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Add missing includes

Before this change, the includes needed to be done explicitly by
files using basic_string_stream.h, and be included first. This
was error prone, especially if includes are reordered (e.g. via
the currently defined clang-format rules).

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>
2026-02-01 10:16:41 +00:00
John Wellbelove
15b96484d5 Fixed missing zero message specialisation for <= C++14 2026-01-30 18:33:30 +00:00
John Wellbelove
491c648d3e Fixed missing zero message specialisation for <= C++14 2026-01-30 11:08:09 +00:00
John Wellbelove
53a9cde9a4 Synced message_router generator to updated code
# Conflicts:
#	include/etl/generators/message_router_generator.h
#	include/etl/message_router.h
2026-01-30 09:22:57 +00:00
John Wellbelove
f0372eaeaa
Merge branch 'master' into feature/#1234-Add-etl--type_list-API-to-more-classes 2026-01-30 09:12:02 +00:00
John Wellbelove
a7fe6bc6b0 Synced message_router generator to updated code 2026-01-30 09:06:54 +00:00
John Wellbelove
0ad0cec342 Synced message_packet generator to updated code 2026-01-29 10:06:42 +00:00
John Wellbelove
ff03b2807d Fix C++03 compatibility
Fixed unused aregument warnings
2026-01-28 22:24:46 +00:00
John Wellbelove
fa8f07ab80 Added missing test files CMakeLists.txt 2026-01-28 17:46:35 +00:00
John Wellbelove
eb1216146c Updated VS2022 project files 2026-01-28 17:46:10 +00:00
John Wellbelove
a4ee9d01aa Allow creation of a message_router with no message types 2026-01-28 17:45:29 +00:00
John Wellbelove
fed1274324 Allow creation of a message_packet with no message types 2026-01-28 17:45:11 +00:00
John Wellbelove
21f68eb7b9 Fix iter_swap namespace 2026-01-28 17:42:43 +00:00
John Wellbelove
bde8747be8 Add type_list functionality to etl::visitor using etl::visitor_from_type_list 2026-01-28 17:42:25 +00:00
John Wellbelove
a61980660f Allow etl::make_index_sequence to be created from an etl::type_list 2026-01-28 17:33:32 +00:00
John Wellbelove
a4e4527669 Add type_list functionality to etl::tuple using etl::tuple_from_type_list 2026-01-28 17:26:57 +00:00
John Wellbelove
a669d1f46e Add type_list functionality to etl::observer using etl::observer_from_type_list 2026-01-28 17:26:20 +00:00
John Wellbelove
1243099471 Add type_list functionality to etl::message_router using etl::message_router_from_type_list 2026-01-28 17:25:08 +00:00
John Wellbelove
746761124c Add type_list functionality to etl::message_packet using etl::message_packet_from_type_list 2026-01-28 17:24:45 +00:00
John Wellbelove
69b741adb8 Add type_list functionality to etl::variant using etl::variant_from_type_list 2026-01-28 17:22:37 +00:00
John Wellbelove
d7dc1281ae Fix iter_swap namespace 2026-01-28 17:20:01 +00:00
John Wellbelove
49d7fa80bc Removed unused tests 2026-01-27 19:28:40 +00:00
John Wellbelove
947e89a6e9 Copy changes from other source 2026-01-26 17:56:33 +00:00
John Wellbelove
8320b35d47 Work in progress 2026-01-26 17:56:32 +00:00
John Wellbelove
92e33bb974 Added member type_list type to tuple 2026-01-26 17:56:31 +00:00
John Wellbelove
c67c617d8c Addedetl::type~_list to message_router, observer, visitor
# Conflicts:
#	include/etl/observer.h
#	test/vs2022/etl.vcxproj.filters
2026-01-26 17:56:31 +00:00
John Wellbelove
1c0d7a87de Updated comments 2026-01-25 19:19:18 +01:00
John Wellbelove
61796bee8f Added etl::type_list to etl::variant 2026-01-25 11:10:38 +01:00
John Wellbelove
682b1e7011 Added type_list definitions for nth_type and observer 2026-01-25 11:09:59 +01:00
Roland Reichwein
9757860241
Remove advance() on static spans (#1281)
* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update CONTRIBUTING.md

Updated the instructions for contributing.

* Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)

* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Remove advance() on static spans

Since the size of a static span is constant, we can't reasonably
advance() on it.

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: Sergei <sergej.shirokov@gmail.com>
2026-01-23 19:33:08 +01:00
Sergei
af1caa88fd Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)
* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.
2026-01-22 10:25:22 +01:00
Sergei
c600605734
Fix for issue 1276 "Data corruption in the etl::bip_buffer_spsc_atomic" (#1277)
* Reproduce data corruption bug in the `etl::bip_buffer_spsc_atomic`.

* Fix data corruption bug in the `etl::bip_buffer_spsc_atomic`.
2026-01-22 10:22:23 +01:00
Bryton Flecker
f9dc1caa94
Fix etl::tuple template signature error in pair assignment operator (#1265)
* Fix etl::tuple template signature error in pair assignment operator

* Remove AppVeyor build status badge

Removed AppVeyor build status badge from README.

* Update README.md

* Update etl::tuple to explicitly use etl::pair or std::pair in assignment operator

* Added tests for etl::tuple assignment from pair

---------

Co-authored-by: Bryton Flecker <bflecker@swe.com>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-01-22 05:30:20 +01:00
Mike Bloom
b82bf3b79d
Fix return value of get_token_list (#1271)
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-01-21 19:40:19 +01:00
John Wellbelove
01a0b63919 Added missing 'typename' to type_list nth_type 2026-01-21 11:26:14 +01:00
John Wellbelove
2862b3b247 Added etl::type_list to etl::nth_type 2026-01-21 09:50:15 +01:00
John Wellbelove
2cae496620 Added etl::type_list to etl::observer 2026-01-21 09:26:48 +01:00
John Wellbelove
fcd50486ce
Update CONTRIBUTING.md
Updated the instructions for contributing.
2026-01-21 09:00:51 +01:00
Bo Rydberg
2c78c3d151
Update C++26 deprecated constructs to ensure future standard compliance (#1267)
* Update C++26 deprecated constructs to ensure future standard compliance

I replaced std::is_trivial with a combination of std::is_trivially_default_constructible and std::is_trivially_copyable. Additionally, I added the required comma before the ellipsis in variadic functions to match updated language specifications.

* Some additional is_trivial related changes not found directly when compiling tests in C++26

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-01-20 11:36:14 +01:00
Bo Rydberg
1b1145ea4e
Remove some UB in test_vector_non_trivial.cpp (#1268)
Some of the tests' UB are detectable by Gcc15 and thus give a compile error due to warnings-as-error flag.

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-01-20 11:15:38 +01:00
John Wellbelove
142dff245c
Update README.md 2026-01-20 10:53:08 +01:00
John Wellbelove
a1744add1f
Remove AppVeyor build status badge
Removed AppVeyor build status badge from README.
2026-01-20 10:35:02 +01:00
taltenbach
55503e0b97
Fix etl::as_bytes for etl::span<const T> (#1266)
A missing 'const' in the etl::as_bytes implementation was causing a
compile-time error when etl::as_bytes was called on a span of const
values.

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-01-17 23:04:52 +01:00
Roland Reichwein
c92dbc2fce
Document how to implement platform specifics (#1262)
Some interfaces need to be implemented in every project
or platform using the ETL:

* etl_get_high_resolution_clock
* etl_get_system_clock
* etl_get_steady_clock
* etl_putchar

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-01-17 14:26:16 +01:00
Mike Bloom
3b1ca75ba2
Add template deduction guide for span from vector (#1264)
* Create span from vector deduction

* Use ivector for deduction.  Add vector_ext to test

* Add vector pointer to test

* Finish tests

* Initialize pdata_ext and others
2026-01-16 09:57:09 +01:00
Roland Reichwein
3780070bcf
Suppress warnings from std in optimized builds (#1259)
When testing with ./run-tests.sh 23 3 10, some warnings from
std surfaced which resulted in build errors.
2026-01-16 09:51:11 +01:00
John Wellbelove
226caa30b5
Changed ETL_OR_STD:: to etl:: (#1261)
Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.co.uk>
2026-01-16 09:47:32 +01:00
Bo Rydberg
0644f9827b
Fix year_month arithmetic and correct chrono API behavior (#1257)
* Fix & add more tests for year_month arithmetic

* Minor addtions to previous commit

* More missing values to be uninitialized

* Update the default constructors to = default and correct default constructor tests accordingly

* Fix & add more tests for year_month arithmetic

* Minor addtions to previous commit

* More missing values to be uninitialized

* Update the default constructors to = default and correct default constructor tests accordingly

* Restore default constructor behavior for chrono calender
2026-01-16 09:02:46 +01:00
John Wellbelove
e9c2577d8e Updated release note and version 2026-01-11 21:06:22 +01:00
John Wellbelove
cdd1de4b56 Updated release note and version 2026-01-11 18:56:17 +01:00
John Wellbelove
14ce8a93fb Updated release note and version 2026-01-11 18:55:00 +01:00
mike919192
3206ac9feb
ivector swap (#1256)
* Etl vector swap implementation

* Implement swap function overload

* Fix nitpicks

* Add size check

* Remove unnessecary etl swap overloads

* Use swap_range and move range

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-01-11 18:05:21 +01:00
John Wellbelove
6d6ecc9fb5
Add etl::inplace_function (#1251)
* Imported inplace_function and invoke functionality from original branch

* Fixed spelling mistake

* Update test/CMakeLists.txt

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update test/test_inplace_function.cpp

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Moved member type function_ptr to private section

* Updated comments in inplace_function.h

* Updated action workflows to be triggered on a pull-request based on development branch

* Added suggested changes from PR reviews

---------

Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.co.uk>
2026-01-10 09:46:50 +01:00
John Wellbelove
09555434f6 Fixed multiple definition of 'expected' 2026-01-08 23:05:46 +01:00
Bo Rydberg
f8ee5f450b
Make code base with tests compile under gcc-14 (#1254)
* Make code base with tests compile under gcc-14

* Update buffer_descriptors.h

Following the same style as non-tests headers have. E.g., include/etl/intrusive_list.h & include/etl/intrusive_forward_list.h

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-01-08 22:58:27 +01:00
Bo Rydberg
5b99aa50b3
Fix syntax errors in base64 test (#1255)
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-01-08 21:12:43 +01:00
littepoint
0c3dafa09e
feat(mutex): Add ThreadX mutex support (#1252)
* feat(mutex): Add ThreadX mutex support

* fix(mutex): Fix ThreadX mutex naming and destructor issues

Correct the header guard macro naming error from ETL_MUTEX_THREAD to ETL_MUTEX_THREADX
Add mutex destructor to properly release resources
Modify mutex creation name identifier to "etl mutex"

---------

Co-authored-by: littepoint <1053049738@qq.com>
2026-01-04 10:38:09 +00:00
Iványi Béla
16389b3eea
Indirect vector checks (#1239)
* Check in indirect_vector::emplace_back if the vector is full, when push pop checks are requested

* Add extra checks to indirect_vector

* Fix emplace in indirect_vector not taking const_iterator

* Fix usage of ipool::create<T> in indirect_vector, so that there are no intermitten objects created

---------

Co-authored-by: Béla Iványi <bela.ivanyi@idata.hu>
2026-01-01 09:56:25 +00:00
John Wellbelove
4f70ed5329 Merge branch 'development' of https://github.com/ETLCPP/etl into development
# Conflicts:
#	test/test_optional.cpp
2025-12-26 07:25:56 +00:00
Nik Delgado
af8ec168c4 implement .begin() and .end() for etl::optional (#1246)
Co-authored-by: nikdelgado <nikdelgado@icloud.com>
2025-12-26 07:25:33 +00:00
Nik Delgado
46a937fc34
implement .begin() and .end() for etl::optional (#1246)
Co-authored-by: nikdelgado <nikdelgado@icloud.com>
2025-12-26 07:01:58 +00:00
John Wellbelove
94d960748d Fixed incompatibilities with C++03 2025-12-23 08:28:47 +00:00
John Wellbelove
16b7183eb8 Merge branch 'pull-request/#1245-Fix-discrepancy-with-STL-in-max_element-and-minmax_element' into development 2025-12-23 07:35:26 +00:00
John Wellbelove
62c654c749 Merge branch 'pull-request/#1244-Fix-no-check-macros' into development 2025-12-23 07:17:28 +00:00
mike919192
819d813a12
Fix no check macros (#1244) 2025-12-23 07:11:07 +00:00
John Wellbelove
339f5abf0f Updated ignore 2025-12-23 07:10:10 +00:00
mike919192
342e43e28b
Fix discrepency with STL in max element and minmax element (#1245) 2025-12-23 07:09:37 +00:00
John Wellbelove
96e3229933 Fixed issue with use of binary constants with C++11 in etl::format tests 2025-12-23 07:05:23 +00:00
John Wellbelove
c798bd337b Revert script to full scrolling terminal style 2025-12-23 07:04:31 +00:00
John Wellbelove
c8fa20620e Fixed C++11 issue with constexpr in exception.h 2025-12-23 07:03:46 +00:00
John Wellbelove
922cfde453 Reverted scrolling changes on test script 2025-12-22 21:02:54 +00:00
John Wellbelove
6b3e776eb5 Fixed filters on VS2022 project 2025-12-22 21:02:17 +00:00
John Wellbelove
62d3fa12f1 Merge branch 'development' of https://github.com/ETLCPP/etl into development 2025-12-22 10:04:35 +00:00
John Wellbelove
84f037b616 Enhanced test and syntax check scripts to add non-scrolling command line header 2025-12-22 10:04:17 +00:00
John Wellbelove
d98c3ac903 Fixed issues with unsigned to signed conversion.
Added format.h to VS2022 project.
Added format.h to syntax check CMakeLists.txt
2025-12-22 10:04:16 +00:00
Roland Reichwein
8c90eb8ba8 Add etl::format (#1204)
* Synchronize on C++ 17 for "Windows - STL" and "Windows - No STL"

MSVC C++20 handles char* differently on iteration

* Add etl::format

This adds etl::format, guided by std::format, avoiding dynamic memory
allocation
2025-12-22 10:04:15 +00:00
John Wellbelove
f548cfc602 Fixed C++ standard check for concepts 2025-12-22 10:04:15 +00:00
John Wellbelove
fc951ff9e2 Disabled header include if <C++20 2025-12-22 10:04:14 +00:00
John Wellbelove
a948ffe686 Added concepts.h to VS2022 project.
Added concepts.h to syntax check CMakeLists.txt
2025-12-22 10:04:13 +00:00
Roland Reichwein
e85d29b1dd Added concepts.h and tests (#1213) 2025-12-22 10:04:13 +00:00
Christoph Rüthing
b2a4b4410c Spare more Resources for non-verbose Errors (#1214)
* Spare more Resources for non-verbose Errors

At the moment we only remove the __FILE__ in case ETL_VERBOSE_ERRORS is
not set. However, we also want to remove the error text which can
consume quite some resources and without the file name the line number
is also not very useful.

* Introduce separate ETL_MINIMAL_ERRORS to keep backwards compatability

To not break runtime backwards compatability, instead of removing the
text in case of ETL_VERBOSE_ERRORS not defined, we introduce a second
flag ETL_MINIMAL_ERRORS which is mutually exclusive. The semantic is as
follows:

- ETL_VERBOSE_ERRORS: We use verbose text, file names and line numbers.
- ETL_MINIMAL_ERRORS: We do not use anything.
- ETL_VERBOSE_ERRORS and ETL_MINIMAL_ERRORS: Issue an error.
- non defined: We use terse text without file names nor line numbers.

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2025-12-22 10:04:12 +00:00
John Wellbelove
8d2f91de9f Updated test_invoke 2025-12-22 10:04:12 +00:00
John Wellbelove
702dda4373 Synchronised etl::invoke_result with that in the etl::inplace_function branch 2025-12-22 10:04:11 +00:00
John Wellbelove
1f1e2c54c3 Updated VS2022 project to include invoke.h 2025-12-22 10:04:10 +00:00
John Wellbelove
054fca0e25 Updated functional.h from the code in the inplace_function branch 2025-12-22 10:04:10 +00:00
John Wellbelove
1ac82dc83e Updated invoke.h from the code in the inplace_function branch 2025-12-22 10:04:09 +00:00
John Wellbelove
552e0f8b90 Formatting updates 2025-12-22 10:04:09 +00:00
whitfijs-jw
269f3ffdfd Topic/expected monadic operations (#1219)
* topic/expected-monadic-operations:
	- added and_then, or_else, transform, and transform_error with simple tests

* topic/expected-monadic-operation:
	- added void TValue specialization operations
	- updated unit tests to include expected<void, TError>
	- added is_expected to expected.h, used in and_then to ensure that the returned type is an expected

* topic/expected-monadic-operations:
	- made implementation c++11 compatible

* topic/expected-monadic-operations:
	- started addressing coderabbit feedback

* topic/expected-monadic-operations:
	- adapted invoke to etl
	- reworked return type deduction
	- filled in or_else unit tests to be more complete
	- still need to add invoke unit tests

* topic/expected-monadic-operations:
	-c++14 compliance

* topic/expected-monadic-operations:
	- completed coderabbit suggestions

* topic/expected-monadic-operations:
	- formatting in invoke and expected
	- added test suite for invoke

* topic/expected-monadic-operations:
	- fixed missing moves for const TValue&& and const TError&&

* topic/expected-monadic-operations:
	- made everything c++11 compatible, very verbose as a result

* topic/expected-monadic-operations:
	- fixed code rabbit rewivew for move semantics in const && overloads

* topic/expected-monadic-operations:
	- moved around a move

* topic/expected-monadic-operations:
	- added etl:: to invoke_result calls that were missing it

* topic/expected-monadic-operations:
	- formatting

* topic/expected-monadic-operations:
	- added invoke for void f() calls for consistency

* topic/expected-monadic-operations:
	- reworked entire thing to be able to handle expected<T,E> to expected<void,E> without even more code duplication

* topic/expected-monadic-operations:
	- added trailing return type to maintain c++11 compatibility

* topic/expected-monadic-operations:
	- fixed mismatch between deduced type and return for a few functions

* topic/expected-monadic-operations:
	- replaced calls to get<TError> and get<TValue> with get<Error_Type> and get<Value_Type>

---------

Co-authored-by: Jon Whitfield <jon@volumetrix.com>
2025-12-22 10:04:08 +00:00
John Wellbelove
520b4a9f46 Removed redundant semicolon from TEST_SUITE block 2025-12-22 10:04:07 +00:00
Iványi Béla
0d792ef13b Exception std based option (#1232)
* Add ability to derive etl::exception from std::exception

* Only add test for exception std base when using STL

* Use ETL_NOEXCEPT macro to define a function as noexcept

* Rename macro to keep in line with common style

* Add using_std_exception to etl::traits

---------

Co-authored-by: Béla Iványi <bela.ivanyi@idata.hu>
2025-12-22 10:04:07 +00:00
Roland Reichwein
3c36e696f5 Bugfixes for compile errors in optimized tests (#1235)
* Fix optimized tests by suppressing warning from STL

* Fix uninitialized buffer in hash for month_weekday

* Fix overlapping memcpy with memmove

* Fix random out of bounds index in __builtin_memmove

Suppressing compiler warning

* Fix array bounds warnings from static casts in message_router

In compiled code, casting to wrong message types is generated,
even though the code paths are supposed to be never taken due to runtime
msg id checks. Therefore, the warnings can be suppressed.

* Fix syntax errors in base64 decoder tests

* Fix test failure in test_rounded_integral_division.cpp when optimized

When building tests optimized, test_round_to_half_even_signed_limits
fails due to the fact that

etl::absolute(std::numeric_limits<int32_t>::min()) < 0
2025-12-22 10:04:06 +00:00
John Wellbelove
636ed523bd Enhanced test and syntax check scripts to add non-scrolling command line header 2025-12-20 12:51:01 +00:00
John Wellbelove
8918cab50a Merge branch 'pull-request/#1238-Various-cleanup' of https://github.com/ETLCPP/etl into pull-request/#1238-Various-cleanup 2025-12-20 10:42:55 +00:00
Roland Reichwein
33f7bbc43d Various cleanup (#1238)
* Fix typo for remainder in rounded_integral_division.h

* Use etl::make_unsigned instead of std::make_unsigned

* Fix divide_round_half_down and divide_round_half_odd
2025-12-20 10:42:47 +00:00
John Wellbelove
6f11b19cfa Remove legacy VS2019 project 2025-12-17 09:55:35 +00:00
John Wellbelove
cb2b3fe6f4 Added --pedandic-errors and -Werror to CMakeLists.txt 2025-12-16 10:41:53 +00:00
John Wellbelove
d884719098 Fixed all 'extra semicolon' warnings 2025-12-16 09:15:26 +00:00
Roland Reichwein
8f3db74be8
Various cleanup (#1238)
* Fix typo for remainder in rounded_integral_division.h

* Use etl::make_unsigned instead of std::make_unsigned

* Fix divide_round_half_down and divide_round_half_odd
2025-12-13 07:46:14 +00:00
John Wellbelove
558c04b0a0 Added <type_traits> for C++23 clang 2025-12-10 18:35:45 +00:00
John Wellbelove
0744ee6989 Added type_traits to test_memory 2025-12-10 08:22:45 +00:00
John Wellbelove
6ebd24578b Don't test deprecated has_denorm in C++23 and above 2025-12-09 10:10:49 +00:00
John Wellbelove
9eb17369c4 Don't test deprecated has_denorm in C++23 and above 2025-12-09 09:47:00 +00:00
John Wellbelove
338d0a4cf5 Don't test deprecated has_denorm in C++23 and above 2025-12-09 09:34:07 +00:00
John Wellbelove
868eaa2b79 Changed Github CI to use macos-15 2025-12-09 09:11:07 +00:00
John Wellbelove
133d065bf1 Updated release notes 2025-12-09 08:58:07 +00:00
John Wellbelove
1039327148 Minor comment and project file change 2025-12-09 08:57:23 +00:00
John Wellbelove
31b658ba81 Improve implementation of traits for functions 2025-12-08 09:11:25 +00:00
John Wellbelove
57c50fce89 Updated misleading template parameter names 2025-12-08 09:11:25 +00:00
mike919192
3525c63b54
Bugfix: Issue 1212 span constructor (#1231)
* Quick fix for issue 1212

* #if macro around std array uses

* Fix macro placement

* Maybe size_t

* Maybe SIZE_

* Check if old boost style works

* Fix angle brackets

* Cleanup traits and add const constructors

* Add traits to C++03 constructors
2025-12-08 09:07:29 +00:00
John Wellbelove
743ed78223 Merge branch 'development' 2025-12-04 08:25:39 +00:00
John Wellbelove
1128414d21 Synced type_traits generator 2025-12-04 08:15:24 +00:00
John Wellbelove
1f15e86ebf Updated version and release notes 2025-12-04 08:11:50 +00:00
John Wellbelove
f5f76165ef Replaced locally defined logical_not_t with etl::negation 2025-12-04 08:11:11 +00:00
John Wellbelove
7fd0360664 Replaced locally defined logical_not_t with etl::negation 2025-12-04 07:47:39 +00:00
John Wellbelove
3c64940e90 Fixed C++03 compatibility
Updated type_traits generator
2025-12-03 09:07:27 +00:00
John Wellbelove
34abed35b0 Synchronised generators with source files 2025-12-02 17:13:10 +00:00
raitraak-rrk
ea73cde70b
variant_legacy.h: Rename template parameters (#1229)
* Bugfix: Fixed span reinterpret_as should return fixed span (#1210)

* Fixed span reinterpret should also return fixed span

* Use auto instead of CTAD

* variant_legacy.h: Rename template parameters

* Allows compatibility with legacy libraries defining U8 similar to uint8_t (e.g. Segger).

---------

Co-authored-by: mike919192 <91038685+mike919192@users.noreply.github.com>
2025-12-02 10:34:06 +00:00
John Wellbelove
ee820f0742 #1228u nused parameter 'secure'
Also fixed for 'truncated'
2025-11-29 09:54:36 +00:00
mike919192
cb25fdfff5 Bugfix: Fixed span reinterpret_as should return fixed span (#1210)
* Fixed span reinterpret should also return fixed span

* Use auto instead of CTAD
2025-11-29 09:54:35 +00:00
David Ockey
79afa52c1e
Catch reentrant calls to FSM and HFSM start, receive, etc. (#1202)
* Added mechanism to catch reentrant calls to methods that could change states in FSM/HFSM

* Added missing include for HFSM unit tests

* Fixed error text spacing

* Disabled move/copy semantics for reentrancy guard

* Updated FSM generator

* Made move semantics only available for C++11 and higher

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2025-11-29 09:54:17 +00:00
mike919192
81a643b9b5
Bugfix: Fixed span reinterpret_as should return fixed span (#1210)
* Fixed span reinterpret should also return fixed span

* Use auto instead of CTAD
2025-11-29 09:41:54 +00:00
Iványi Béla
79b41c85af
Fix is_truncated in basic_string (#1223)
Co-authored-by: Iványi Béla <bela.ivanyi@idata.hu>
2025-11-29 09:38:10 +00:00
Roland Reichwein
efd5c57419
Change generators to reflect changes in fsm.h and type_traits.h (#1211)
Previous changes were wrongfully made in fsm.h and type_traits.h
instead of in their generator counterparts.

Add CI check to ensure generated files are in sync.
2025-11-27 08:54:13 +00:00
mike919192
a6f4c0b4d1
Basic string checks (#1222)
* Add checks for index, front, back, and insert

* Add erase checks

* Add tests to string_char

* Add u16 tests

* Add tests to string u32

* Add u8 tests

* Add wchar tests

* Use size() for back functions.  Fix some uses of buffer2

* Add assert for swapped insert iterators.  Add tests
2025-11-27 08:52:37 +00:00
Roland Reichwein
14e3b9d11e
Cleanup platform.h includes, add missing test for unaligned_type (#1218)
* platform.h include cleanup

* Add test for implicit value conversion in unaligned_type
2025-11-27 08:50:39 +00:00
Helder Duarte
78f04ad298
Fix value_or not taking const in optional (#1225) 2025-11-27 08:48:27 +00:00
lschneidercor
e5dd953c8b
Add missing include to optional (#1226)
When the initializer list is not included, the default std::initializer
list is used and ETL_NO_STL would be ignored.
2025-11-27 08:47:50 +00:00
Roland Reichwein
2f535d385f
Add test for swap (#1221) 2025-11-12 18:05:20 +00:00
Filipe Cuim
43d3f0e89c
Add const specialization for etl::get_object_at (#1217)
Signed-off-by: Filipe Cuim <filipemocuim@gmail.com>
2025-11-11 19:12:39 +00:00
John Wellbelove
b6e78b7c9c Updated etl::array and etl::delegate
Updated release nots and version
2025-10-19 18:40:58 +01:00
mike919192
bb24ea2164
Fix array noexcept expr (#1208) 2025-10-19 17:10:32 +01:00
John Wellbelove
a025d0cc68 Update version and release notes 2025-10-15 08:33:38 +01:00
John Wellbelove
817f2ab99e Update version and release notes 2025-10-14 18:03:14 +01:00
John Wellbelove
4b8ab3eeda Added type_list_has_duplicates_of and type_list_count_of 2025-10-13 23:02:45 +01:00
John Wellbelove
c7d2682659 Added macro settings 2025-10-13 22:31:33 +01:00
John Wellbelove
02b0de1ae9 Added extra static assert checks for functors and lambdas 2025-10-13 17:42:27 +01:00
John Wellbelove
e0e7155d63 Merge branch 'pull-request/#1188-etl-array-checks' into development 2025-10-13 17:37:56 +01:00
mike919192
4147216231
etl::span checks (#1201)
* Implement checks

* handle cpp11 constexpr exceptions

* Cant use local variables

* Tests should be implemented

* Try to fix msvc

* Fix etl error text
2025-10-13 17:34:34 +01:00
John Wellbelove
23d78d5dc7 Merge branch 'hotfix/#1203-Potential-issue-with-forwarding-in-etl--delegate' into development 2025-10-12 11:05:45 +01:00
John Wellbelove
30ccdea629 Opimisation of delegate invocations 2025-10-12 11:05:30 +01:00
John Wellbelove
532c9737b7 Merge branch 'hotfix/Fix-usage-of-noexcept' into development
# Conflicts:
#	include/etl/platform.h
2025-10-11 16:37:39 +01:00
John Wellbelove
399899bbe2 Updated version 2025-10-11 16:30:28 +01:00
John Wellbelove
3f7b18e3c2 Changed result of etl::is_constant_evaluated() in test_is_constant_evaluated from const to constexpr. 2025-10-11 11:41:02 +01:00
John Wellbelove
85678586c4 Merge branch 'pull-request/#1199-Added-support-for-transitions-on-state-enter-for-HFSM' into development 2025-10-11 11:01:53 +01:00
John Wellbelove
07894526e0 Added test_hfsm_recurse_to_inner_state_on_start.cpp to project 2025-10-11 11:01:35 +01:00
John Wellbelove
047071211c Merge branch 'pull-request/#1012-Implement-Signal' into development
# Conflicts:
#	test/vs2022/etl.vcxproj.filters
2025-10-11 10:51:19 +01:00
John Wellbelove
11c509bb44 Merge branch 'pull-request/#1196-Added-back-in-support-for-populating-non-8-bit-strings-with-8-bit-data' into development 2025-10-11 10:47:46 +01:00
John Wellbelove
b328d06746 Merge branch 'pull-request/#1198-Add-etl--is_constant_evaluated' into development 2025-10-11 10:35:38 +01:00
John Wellbelove
115e0e91a2 Removed redundant member function 2025-10-10 09:51:11 +01:00
John Wellbelove
6ab05a5d7e Rebased on development 2025-10-08 10:26:28 +01:00
John Wellbelove
fa10567482 Restore ETL_NOEXCEPT_FROM missing from merges 2025-10-08 10:25:45 +01:00
John Wellbelove
d14f7a66a9 Added and fixed noexcept attributes
Added ETL_NOEXCEPT_FROM to set noexcept attributes based on an object or function.

# Conflicts:
#	include/etl/platform.h
2025-10-08 10:25:44 +01:00
John Wellbelove
07734033d3 Minor layout changes 2025-10-08 10:25:44 +01:00
David Ockey
1ea45ff28e Added conditional support of noexcept to fix IAR support (#1195) 2025-10-08 10:25:43 +01:00
mike919192
99a33535d3 Vector checks (#1193)
* Add checks to vector and fix test failures

* Add tests to vector

* Add tests to external buffer and non trivial

* All tests should be implemented

* Add checks to vector_pointer and vector_pointer_ext

* Get bad iterators from a second vector
2025-10-08 10:25:42 +01:00
Igor Pugachev
d2e0b07791 fix variant_variadic documentation (#1194)
* fix variant_variadic default constructor documentation

* fix valueless doc
2025-10-08 10:25:42 +01:00
John Wellbelove
a25f195637 Renamed ETL_ASSERT_UNTYPED to ETL_ASSERT_GENERIC 2025-10-08 10:25:41 +01:00
John Wellbelove
d456c78589 Fixed indentation
Removed unused ETL_ASSERT
2025-10-08 10:25:18 +01:00
John Wellbelove
9c3e786509 Added missing CI scripts to the project 2025-10-08 10:25:18 +01:00
Christoph Rüthing
ad1679ff93 Introduce Cast to void for Condition of Assert (#1191)
* Removed ETL_NOEXCEPT from delegate operator(), call_if(), and call_or()

Removed ETL_NOEXCEPT from closureoperator(), call_if(), and call_or()

* Updated version and release notes

* Updated version and release notes

* Remove noexcept from delegate method stubs. (#1185)

In addition to removing noexcept from call_if, this is also needed to prevent
an abort when cancelling a pthread that is executing a delegate.

* Updated version and release notes

* Introduce Cast to void for Condition of Assert

Currently, in case we use a parameter of a function _only_ inside of an
ETL_ASSERT and the ETL configuration disables the ETL_ASSERT, we get a
compiler warning about an unused parameter. Therefore, this change casts
the condition of ETL_ASSERT to void.

* Use sizeof to avoid evaluation of Expression

In case we disable ASSERTs in e.g. non debug builds, we want to expand
it to "nothing", similar to how the std assert works. Introducing a cast
to void on the conidition would still evaluate it and potentially cause
side-effects. Therefore, we use the sizeof operator to ensure the
expression is not evaluated in case ASSERTs are disabled.

---------

Co-authored-by: John Wellbelove <john.wellbelove@asterconsulting.co.uk>
Co-authored-by: Marco Nilsson <marco@zyax.se>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2025-10-08 10:25:17 +01:00
Christoph Rüthing
9e0121125f Allow easy Creation of Generic Exceptions with just a Text (#1192)
* Removed ETL_NOEXCEPT from delegate operator(), call_if(), and call_or()

Removed ETL_NOEXCEPT from closureoperator(), call_if(), and call_or()

* Updated version and release notes

* Updated version and release notes

* Remove noexcept from delegate method stubs. (#1185)

In addition to removing noexcept from call_if, this is also needed to prevent
an abort when cancelling a pthread that is executing a delegate.

* Updated version and release notes

* Allow easy Creation of Generic Exceptions with just a Text

Today when using ETL_ASSERT you need to pass a concrete exception type.
However, it can be quite unhandy to define a custom exception type for
each assert, therefore we want to also allow to simply use the generic
etl::exception type and directly provide the message.

---------

Co-authored-by: John Wellbelove <john.wellbelove@asterconsulting.co.uk>
Co-authored-by: Marco Nilsson <marco@zyax.se>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2025-10-08 10:25:17 +01:00
Christoph Rüthing
32a2e78d79 Enforce Semicolon after ETL_ASSERT (#1190)
* Removed ETL_NOEXCEPT from delegate operator(), call_if(), and call_or()

Removed ETL_NOEXCEPT from closureoperator(), call_if(), and call_or()

* Updated version and release notes

* Updated version and release notes

* Remove noexcept from delegate method stubs. (#1185)

In addition to removing noexcept from call_if, this is also needed to prevent
an abort when cancelling a pthread that is executing a delegate.

* Updated version and release notes

* Enforce Semicolon after ETL_ASSERT

---------

Co-authored-by: John Wellbelove <john.wellbelove@asterconsulting.co.uk>
Co-authored-by: Marco Nilsson <marco@zyax.se>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2025-10-08 10:25:16 +01:00
John Wellbelove
a2415cc30f Removed #define ETL_DEBUG as this is a project define 2025-10-08 10:25:00 +01:00
mike919192
f2c33a4466 Debug assert (#1175)
* debug assert POC

* Swith to ETL_CONSTEXPR14

* Finish TODO checks

* First and last can be equal

* Add ETL_DEBUG_THROW_EXCEPTIONS

* Try allowing c++11 constexpr

* Add macro for throwing from c++11 constexpr

* Remove braces

* Add extra asserts in size_t overload functions

* Fill out debug asserts

* Line up comments
2025-10-08 10:24:59 +01:00
John Wellbelove
da5e42a4bc Moved and renamed common class to base 2025-10-08 10:23:32 +01:00
John Wellbelove
8dff499500 Added insert/remove tests 2025-10-08 10:23:32 +01:00
John Wellbelove
947f9e523b Changed timer to match the internal layout of other timers 2025-10-08 10:23:31 +01:00
John Wellbelove
21d7ebe879 Added insert and remove timer callback tests to test_message_timer_interrupt and test_message_timer_locked 2025-10-08 10:23:30 +01:00
Mario Luzeiro
793bafa1b4 Added callbacks when a timer is inserted or removed (#1155) 2025-10-08 10:23:30 +01:00
mike919192
c13d01319e etl array checks (#1188)
* Regression fix: Support zero arguments emplace() in etl::optional (#1183)

* Added coderabbitai configuration

* Added builtin mem function tests

* Modified etl::typed_storage

* Modified etl::typed_storage

# Conflicts:
#	include/etl/alignment.h

* Added ETL_NOEXCEPT and ETL_NOEXCEPT_IF_NO_THROW

* Added etl::typed_storage_ext and swap for same

* Added etl::typed_storage_ext and swap for same

# Conflicts:
#	include/etl/alignment.h

* Added release notes

* Fixes to GCC -O2 errors

* Changed char* parameters to value_type* parameters

* Fixed compilation issues for const containers unit tests

* Added automatic selection of __builtin_memxxx functions for GCC and clang

* Added enhanced coderabbit configuration

* Updated version and release notes

* Disabled constexpr const container tests for C++11

* Attempted fixes for MacOS compilation

* Attempted fixes for MacOS compilation

* Attempted fixes for MacOS compilation

* Attempted fixes for MacOS compilation

* Updated version and release notes

* feat: removed unreachable break statements (#1169)

* Updated version and release notes

* Modified etl::typed_storage

# Conflicts:
#	include/etl/alignment.h

* Support zero arguments emplace() in etl::optional

For non-fundamental types, a recent change in etl::optional was
introduced that doesn't support zero arguments emplace() anymore.

This change fixes it and adds the respective test.

---------

Co-authored-by: John Wellbelove <john.wellbelove@asterconsulting.co.uk>
Co-authored-by: Drew Rife <darife@jlg.com>

* Fix etl::typed_storage by supporting omitted destructors (#1182)

* Added coderabbitai configuration

* Added builtin mem function tests

* Modified etl::typed_storage

* Modified etl::typed_storage

# Conflicts:
#	include/etl/alignment.h

* Added ETL_NOEXCEPT and ETL_NOEXCEPT_IF_NO_THROW

* Added etl::typed_storage_ext and swap for same

* Added etl::typed_storage_ext and swap for same

# Conflicts:
#	include/etl/alignment.h

* Added release notes

* Fixes to GCC -O2 errors

* Changed char* parameters to value_type* parameters

* Fixed compilation issues for const containers unit tests

* Added automatic selection of __builtin_memxxx functions for GCC and clang

* Added enhanced coderabbit configuration

* Updated version and release notes

* Disabled constexpr const container tests for C++11

* Attempted fixes for MacOS compilation

* Attempted fixes for MacOS compilation

* Attempted fixes for MacOS compilation

* Attempted fixes for MacOS compilation

* Updated version and release notes

* feat: removed unreachable break statements (#1169)

* Updated version and release notes

* Modified etl::typed_storage

# Conflicts:
#	include/etl/alignment.h

* Fix etl::typed_storage by supporting omitted destructors

In a recent change to alignment.h, the etl::typed_storage was
changed in a way that in case of an already constructed object,
the object is created via assignment.

However, this contradicts the original use case that led to
etl::typed_storage in the first place:
https://github.com/ETLCPP/etl/pull/1023

The goal is to omit destructors (and at the same time support
classes with deleted assignment operators), so they can be optimized out
at link time.

This change reverts commit ac7b268 to restore the original
functionality and changes the test to reflect the original
use case.

* Fix missing create() in non-C++11 typed_storage_ext constructor

* Typo fix

---------

Co-authored-by: John Wellbelove <john.wellbelove@asterconsulting.co.uk>
Co-authored-by: Drew Rife <darife@jlg.com>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>

* removed navis file from project

* Updated version and release notes

* Removed forced unsigned int cast in type_def bit-shift operators (#1178)

* Removed UB in type_def bit-shift operators

* Changed shift operators to allow both signed and unsigned operands for shifts
This allows the library user to explicitly use unsigned values to avoid UB

* Fixed constexpr errors for CPP11

* Changed is_arithmetic checks to use is_integral since valid shifts require integral operands

* Removed need for CPP11 since changes are CPP03 compatible

* Delete project navis files

* Add force CI check on piull requests

* Removed ETL_NOEXCEPT from delegate operator(), call_if(), and call_or()

Removed ETL_NOEXCEPT from closureoperator(), call_if(), and call_or()

* Updated version and release notes

* Updated version and release notes

* Remove noexcept from delegate method stubs. (#1185)

In addition to removing noexcept from call_if, this is also needed to prevent
an abort when cancelling a pthread that is executing a delegate.

* Updated version and release notes

* Re architect the extra checks

* Add CHECK_EXTRA

* Fix newline at end of file

* The check index macro also needs to be defined to throw

* Remove ETL_VERBOSE_ERRORS macros

---------

Co-authored-by: Roland Reichwein <Roland.Reichwein@bmw.de>
Co-authored-by: John Wellbelove <john.wellbelove@asterconsulting.co.uk>
Co-authored-by: Drew Rife <darife@jlg.com>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: David Ockey <2897027+ockeydockey@users.noreply.github.com>
Co-authored-by: Marco Nilsson <marco@zyax.se>
2025-10-08 10:22:54 +01:00
John Wellbelove
df6b0b20c8 Modified to use new ETL_ASSERTs 2025-10-08 10:22:54 +01:00
John Wellbelove
abc2735504 Added more ETL_NOEXCEPT to etl::array 2025-10-08 10:22:15 +01:00
John Wellbelove
da32625f10 Removed #define ETL_DEBUG as this is a project define 2025-10-08 10:22:14 +01:00
mike919192
5b76824c61 Debug assert (#1175)
* debug assert POC

* Swith to ETL_CONSTEXPR14

* Finish TODO checks

* First and last can be equal

* Add ETL_DEBUG_THROW_EXCEPTIONS

* Try allowing c++11 constexpr

* Add macro for throwing from c++11 constexpr

* Remove braces

* Add extra asserts in size_t overload functions

* Fill out debug asserts

* Line up comments
2025-10-08 10:21:14 +01:00
David Ockey
f9982a6fde
Added back in support for populating non 8-bit strings with 8-bit data (#1196)
* Fixed ability to populate 16-bit strings with 8-bit data

* Added more unit tests

* Fixed C++11 build errors

* Changed testing to accommodate C++11 better

* Cleaned up comments

* Cleaned up tests to be more consistent

* Make template matches mutually exclusive to prevent ambiguous behavior

* Added changes to u32 and wchar strings

* Changed const range tests to use const string
2025-10-08 09:39:26 +01:00
Roland Reichwein
05731c2786
Add etl::is_constant_evaluated (#1198)
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2025-10-08 09:32:43 +01:00
David Ockey
86b9e0903f
Added support for transitions on state enter for HFSM (#1199)
* Added support for transitions on state enter for HFSM

* Fixed unit test build error

* Comment clean-up

* Changed FSM so that self-transitions can also transition "on enter"

* Fixing C++03 build error for clang
2025-10-08 08:43:09 +01:00
John Wellbelove
85fc48302d Merge branch 'pull-request/#1188-etl-array-checks' into development 2025-10-04 08:08:10 +01:00
John Wellbelove
421edaf165 Merge branch 'pull-request/#1195-Added-conditional-support-of-noexcept-to-fix-IAR-support' into development 2025-10-04 08:07:47 +01:00
John Wellbelove
2c170118ff Merge branch 'pull-request/#1188-etl-array-checks' of https://github.com/ETLCPP/etl into pull-request/#1188-etl-array-checks 2025-10-04 08:05:58 +01:00
John Wellbelove
d21b0a27f0 Restore ETL_NOEXCEPT_FROM missing from merges 2025-10-04 08:02:56 +01:00
John Wellbelove
ed718a97e9 Added and fixed noexcept attributes
Added ETL_NOEXCEPT_FROM to set noexcept attributes based on an object or function.

# Conflicts:
#	include/etl/platform.h
2025-10-04 08:02:55 +01:00
mike919192
24e603b27d Vector checks (#1193)
* Add checks to vector and fix test failures

* Add tests to vector

* Add tests to external buffer and non trivial

* All tests should be implemented

* Add checks to vector_pointer and vector_pointer_ext

* Get bad iterators from a second vector
2025-10-04 08:02:54 +01:00
Igor Pugachev
e1126aafd2 fix variant_variadic documentation (#1194)
* fix variant_variadic default constructor documentation

* fix valueless doc
2025-10-04 08:02:54 +01:00
John Wellbelove
27a19f5c52 Restore ETL_NOEXCEPT_FROM missing from merges 2025-10-04 08:02:17 +01:00
John Wellbelove
d0feb3d175 Added and fixed noexcept attributes
Added ETL_NOEXCEPT_FROM to set noexcept attributes based on an object or function.

# Conflicts:
#	include/etl/platform.h
2025-10-03 10:49:43 +01:00
John Wellbelove
b90bcaaaab Minor layout changes 2025-10-03 10:49:25 +01:00
David Ockey
0323dabeff Added conditional support of noexcept to fix IAR support (#1195) 2025-10-03 10:49:24 +01:00
mike919192
2bf512dd42 Vector checks (#1193)
* Add checks to vector and fix test failures

* Add tests to vector

* Add tests to external buffer and non trivial

* All tests should be implemented

* Add checks to vector_pointer and vector_pointer_ext

* Get bad iterators from a second vector
2025-10-03 10:49:23 +01:00
John Wellbelove
b38feb17b5 Minor layout changes 2025-10-03 10:18:21 +01:00
mike919192
44e7516278
Vector checks (#1193)
* Add checks to vector and fix test failures

* Add tests to vector

* Add tests to external buffer and non trivial

* All tests should be implemented

* Add checks to vector_pointer and vector_pointer_ext

* Get bad iterators from a second vector
2025-10-03 10:10:15 +01:00
Igor Pugachev
077590838b
fix variant_variadic documentation (#1194)
* fix variant_variadic default constructor documentation

* fix valueless doc
2025-10-03 08:54:12 +01:00
David Ockey
15cbb12e4b
Added conditional support of noexcept to fix IAR support (#1195) 2025-10-03 08:44:16 +01:00
John Wellbelove
bcf7a95bb6 Renamed ETL_ASSERT_UNTYPED to ETL_ASSERT_GENERIC 2025-10-02 08:28:50 +01:00
John Wellbelove
a9265b1a71 Merge branch 'pull-request/#1191-Introduce-Cast-to-void-for-Condition-of-Assert' into development
# Conflicts:
#	include/etl/error_handler.h
2025-10-02 08:15:17 +01:00
John Wellbelove
f7cdf1bc3f Fixed indentation
Removed unused ETL_ASSERT
2025-10-02 07:45:54 +01:00
John Wellbelove
07bf063daa Added missing CI scripts to the project 2025-10-01 18:58:33 +01:00
Christoph Rüthing
018c7ce849
Introduce Cast to void for Condition of Assert (#1191)
* Removed ETL_NOEXCEPT from delegate operator(), call_if(), and call_or()

Removed ETL_NOEXCEPT from closureoperator(), call_if(), and call_or()

* Updated version and release notes

* Updated version and release notes

* Remove noexcept from delegate method stubs. (#1185)

In addition to removing noexcept from call_if, this is also needed to prevent
an abort when cancelling a pthread that is executing a delegate.

* Updated version and release notes

* Introduce Cast to void for Condition of Assert

Currently, in case we use a parameter of a function _only_ inside of an
ETL_ASSERT and the ETL configuration disables the ETL_ASSERT, we get a
compiler warning about an unused parameter. Therefore, this change casts
the condition of ETL_ASSERT to void.

* Use sizeof to avoid evaluation of Expression

In case we disable ASSERTs in e.g. non debug builds, we want to expand
it to "nothing", similar to how the std assert works. Introducing a cast
to void on the conidition would still evaluate it and potentially cause
side-effects. Therefore, we use the sizeof operator to ensure the
expression is not evaluated in case ASSERTs are disabled.

---------

Co-authored-by: John Wellbelove <john.wellbelove@asterconsulting.co.uk>
Co-authored-by: Marco Nilsson <marco@zyax.se>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2025-10-01 18:43:52 +01:00
Christoph Rüthing
4cbc601a69
Allow easy Creation of Generic Exceptions with just a Text (#1192)
* Removed ETL_NOEXCEPT from delegate operator(), call_if(), and call_or()

Removed ETL_NOEXCEPT from closureoperator(), call_if(), and call_or()

* Updated version and release notes

* Updated version and release notes

* Remove noexcept from delegate method stubs. (#1185)

In addition to removing noexcept from call_if, this is also needed to prevent
an abort when cancelling a pthread that is executing a delegate.

* Updated version and release notes

* Allow easy Creation of Generic Exceptions with just a Text

Today when using ETL_ASSERT you need to pass a concrete exception type.
However, it can be quite unhandy to define a custom exception type for
each assert, therefore we want to also allow to simply use the generic
etl::exception type and directly provide the message.

---------

Co-authored-by: John Wellbelove <john.wellbelove@asterconsulting.co.uk>
Co-authored-by: Marco Nilsson <marco@zyax.se>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2025-09-28 11:10:50 +01:00
Christoph Rüthing
813e26e3b4
Enforce Semicolon after ETL_ASSERT (#1190)
* Removed ETL_NOEXCEPT from delegate operator(), call_if(), and call_or()

Removed ETL_NOEXCEPT from closureoperator(), call_if(), and call_or()

* Updated version and release notes

* Updated version and release notes

* Remove noexcept from delegate method stubs. (#1185)

In addition to removing noexcept from call_if, this is also needed to prevent
an abort when cancelling a pthread that is executing a delegate.

* Updated version and release notes

* Enforce Semicolon after ETL_ASSERT

---------

Co-authored-by: John Wellbelove <john.wellbelove@asterconsulting.co.uk>
Co-authored-by: Marco Nilsson <marco@zyax.se>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2025-09-27 10:28:57 +01:00
mike919192
4cf522ed46 etl array checks (#1188)
* Regression fix: Support zero arguments emplace() in etl::optional (#1183)

* Added coderabbitai configuration

* Added builtin mem function tests

* Modified etl::typed_storage

* Modified etl::typed_storage

# Conflicts:
#	include/etl/alignment.h

* Added ETL_NOEXCEPT and ETL_NOEXCEPT_IF_NO_THROW

* Added etl::typed_storage_ext and swap for same

* Added etl::typed_storage_ext and swap for same

# Conflicts:
#	include/etl/alignment.h

* Added release notes

* Fixes to GCC -O2 errors

* Changed char* parameters to value_type* parameters

* Fixed compilation issues for const containers unit tests

* Added automatic selection of __builtin_memxxx functions for GCC and clang

* Added enhanced coderabbit configuration

* Updated version and release notes

* Disabled constexpr const container tests for C++11

* Attempted fixes for MacOS compilation

* Attempted fixes for MacOS compilation

* Attempted fixes for MacOS compilation

* Attempted fixes for MacOS compilation

* Updated version and release notes

* feat: removed unreachable break statements (#1169)

* Updated version and release notes

* Modified etl::typed_storage

# Conflicts:
#	include/etl/alignment.h

* Support zero arguments emplace() in etl::optional

For non-fundamental types, a recent change in etl::optional was
introduced that doesn't support zero arguments emplace() anymore.

This change fixes it and adds the respective test.

---------

Co-authored-by: John Wellbelove <john.wellbelove@asterconsulting.co.uk>
Co-authored-by: Drew Rife <darife@jlg.com>

* Fix etl::typed_storage by supporting omitted destructors (#1182)

* Added coderabbitai configuration

* Added builtin mem function tests

* Modified etl::typed_storage

* Modified etl::typed_storage

# Conflicts:
#	include/etl/alignment.h

* Added ETL_NOEXCEPT and ETL_NOEXCEPT_IF_NO_THROW

* Added etl::typed_storage_ext and swap for same

* Added etl::typed_storage_ext and swap for same

# Conflicts:
#	include/etl/alignment.h

* Added release notes

* Fixes to GCC -O2 errors

* Changed char* parameters to value_type* parameters

* Fixed compilation issues for const containers unit tests

* Added automatic selection of __builtin_memxxx functions for GCC and clang

* Added enhanced coderabbit configuration

* Updated version and release notes

* Disabled constexpr const container tests for C++11

* Attempted fixes for MacOS compilation

* Attempted fixes for MacOS compilation

* Attempted fixes for MacOS compilation

* Attempted fixes for MacOS compilation

* Updated version and release notes

* feat: removed unreachable break statements (#1169)

* Updated version and release notes

* Modified etl::typed_storage

# Conflicts:
#	include/etl/alignment.h

* Fix etl::typed_storage by supporting omitted destructors

In a recent change to alignment.h, the etl::typed_storage was
changed in a way that in case of an already constructed object,
the object is created via assignment.

However, this contradicts the original use case that led to
etl::typed_storage in the first place:
https://github.com/ETLCPP/etl/pull/1023

The goal is to omit destructors (and at the same time support
classes with deleted assignment operators), so they can be optimized out
at link time.

This change reverts commit ac7b268 to restore the original
functionality and changes the test to reflect the original
use case.

* Fix missing create() in non-C++11 typed_storage_ext constructor

* Typo fix

---------

Co-authored-by: John Wellbelove <john.wellbelove@asterconsulting.co.uk>
Co-authored-by: Drew Rife <darife@jlg.com>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>

* removed navis file from project

* Updated version and release notes

* Removed forced unsigned int cast in type_def bit-shift operators (#1178)

* Removed UB in type_def bit-shift operators

* Changed shift operators to allow both signed and unsigned operands for shifts
This allows the library user to explicitly use unsigned values to avoid UB

* Fixed constexpr errors for CPP11

* Changed is_arithmetic checks to use is_integral since valid shifts require integral operands

* Removed need for CPP11 since changes are CPP03 compatible

* Delete project navis files

* Add force CI check on piull requests

* Removed ETL_NOEXCEPT from delegate operator(), call_if(), and call_or()

Removed ETL_NOEXCEPT from closureoperator(), call_if(), and call_or()

* Updated version and release notes

* Updated version and release notes

* Remove noexcept from delegate method stubs. (#1185)

In addition to removing noexcept from call_if, this is also needed to prevent
an abort when cancelling a pthread that is executing a delegate.

* Updated version and release notes

* Re architect the extra checks

* Add CHECK_EXTRA

* Fix newline at end of file

* The check index macro also needs to be defined to throw

* Remove ETL_VERBOSE_ERRORS macros

---------

Co-authored-by: Roland Reichwein <Roland.Reichwein@bmw.de>
Co-authored-by: John Wellbelove <john.wellbelove@asterconsulting.co.uk>
Co-authored-by: Drew Rife <darife@jlg.com>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: David Ockey <2897027+ockeydockey@users.noreply.github.com>
Co-authored-by: Marco Nilsson <marco@zyax.se>
2025-09-26 09:57:00 +01:00
John Wellbelove
69c3f74b0f Modified to use new ETL_ASSERTs 2025-09-26 09:56:59 +01:00
John Wellbelove
5ac8070a8c Added more ETL_NOEXCEPT to etl::array 2025-09-26 09:56:59 +01:00
John Wellbelove
972aedd944 Removed #define ETL_DEBUG as this is a project define 2025-09-26 09:56:58 +01:00
mike919192
fbb92f85fc Debug assert (#1175)
* debug assert POC

* Swith to ETL_CONSTEXPR14

* Finish TODO checks

* First and last can be equal

* Add ETL_DEBUG_THROW_EXCEPTIONS

* Try allowing c++11 constexpr

* Add macro for throwing from c++11 constexpr

* Remove braces

* Add extra asserts in size_t overload functions

* Fill out debug asserts

* Line up comments
2025-09-26 09:55:40 +01:00
John Wellbelove
5face0d8f2 Updated version and release notes
# Conflicts:
#	support/Release notes.txt
2025-09-26 09:54:59 +01:00
John Wellbelove
1b5ff74a3d Fixed spelling of gdc to gcd 2025-09-26 09:53:49 +01:00
John Wellbelove
081b693e0b Merge branch 'pull-request/#1188-etl-array-checks' into development 2025-09-25 09:26:33 +01:00
mike919192
3295cb30ca
etl array checks (#1188)
* Regression fix: Support zero arguments emplace() in etl::optional (#1183)

* Added coderabbitai configuration

* Added builtin mem function tests

* Modified etl::typed_storage

* Modified etl::typed_storage

# Conflicts:
#	include/etl/alignment.h

* Added ETL_NOEXCEPT and ETL_NOEXCEPT_IF_NO_THROW

* Added etl::typed_storage_ext and swap for same

* Added etl::typed_storage_ext and swap for same

# Conflicts:
#	include/etl/alignment.h

* Added release notes

* Fixes to GCC -O2 errors

* Changed char* parameters to value_type* parameters

* Fixed compilation issues for const containers unit tests

* Added automatic selection of __builtin_memxxx functions for GCC and clang

* Added enhanced coderabbit configuration

* Updated version and release notes

* Disabled constexpr const container tests for C++11

* Attempted fixes for MacOS compilation

* Attempted fixes for MacOS compilation

* Attempted fixes for MacOS compilation

* Attempted fixes for MacOS compilation

* Updated version and release notes

* feat: removed unreachable break statements (#1169)

* Updated version and release notes

* Modified etl::typed_storage

# Conflicts:
#	include/etl/alignment.h

* Support zero arguments emplace() in etl::optional

For non-fundamental types, a recent change in etl::optional was
introduced that doesn't support zero arguments emplace() anymore.

This change fixes it and adds the respective test.

---------

Co-authored-by: John Wellbelove <john.wellbelove@asterconsulting.co.uk>
Co-authored-by: Drew Rife <darife@jlg.com>

* Fix etl::typed_storage by supporting omitted destructors (#1182)

* Added coderabbitai configuration

* Added builtin mem function tests

* Modified etl::typed_storage

* Modified etl::typed_storage

# Conflicts:
#	include/etl/alignment.h

* Added ETL_NOEXCEPT and ETL_NOEXCEPT_IF_NO_THROW

* Added etl::typed_storage_ext and swap for same

* Added etl::typed_storage_ext and swap for same

# Conflicts:
#	include/etl/alignment.h

* Added release notes

* Fixes to GCC -O2 errors

* Changed char* parameters to value_type* parameters

* Fixed compilation issues for const containers unit tests

* Added automatic selection of __builtin_memxxx functions for GCC and clang

* Added enhanced coderabbit configuration

* Updated version and release notes

* Disabled constexpr const container tests for C++11

* Attempted fixes for MacOS compilation

* Attempted fixes for MacOS compilation

* Attempted fixes for MacOS compilation

* Attempted fixes for MacOS compilation

* Updated version and release notes

* feat: removed unreachable break statements (#1169)

* Updated version and release notes

* Modified etl::typed_storage

# Conflicts:
#	include/etl/alignment.h

* Fix etl::typed_storage by supporting omitted destructors

In a recent change to alignment.h, the etl::typed_storage was
changed in a way that in case of an already constructed object,
the object is created via assignment.

However, this contradicts the original use case that led to
etl::typed_storage in the first place:
https://github.com/ETLCPP/etl/pull/1023

The goal is to omit destructors (and at the same time support
classes with deleted assignment operators), so they can be optimized out
at link time.

This change reverts commit ac7b268 to restore the original
functionality and changes the test to reflect the original
use case.

* Fix missing create() in non-C++11 typed_storage_ext constructor

* Typo fix

---------

Co-authored-by: John Wellbelove <john.wellbelove@asterconsulting.co.uk>
Co-authored-by: Drew Rife <darife@jlg.com>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>

* removed navis file from project

* Updated version and release notes

* Removed forced unsigned int cast in type_def bit-shift operators (#1178)

* Removed UB in type_def bit-shift operators

* Changed shift operators to allow both signed and unsigned operands for shifts
This allows the library user to explicitly use unsigned values to avoid UB

* Fixed constexpr errors for CPP11

* Changed is_arithmetic checks to use is_integral since valid shifts require integral operands

* Removed need for CPP11 since changes are CPP03 compatible

* Delete project navis files

* Add force CI check on piull requests

* Removed ETL_NOEXCEPT from delegate operator(), call_if(), and call_or()

Removed ETL_NOEXCEPT from closureoperator(), call_if(), and call_or()

* Updated version and release notes

* Updated version and release notes

* Remove noexcept from delegate method stubs. (#1185)

In addition to removing noexcept from call_if, this is also needed to prevent
an abort when cancelling a pthread that is executing a delegate.

* Updated version and release notes

* Re architect the extra checks

* Add CHECK_EXTRA

* Fix newline at end of file

* The check index macro also needs to be defined to throw

* Remove ETL_VERBOSE_ERRORS macros

---------

Co-authored-by: Roland Reichwein <Roland.Reichwein@bmw.de>
Co-authored-by: John Wellbelove <john.wellbelove@asterconsulting.co.uk>
Co-authored-by: Drew Rife <darife@jlg.com>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
Co-authored-by: David Ockey <2897027+ockeydockey@users.noreply.github.com>
Co-authored-by: Marco Nilsson <marco@zyax.se>
2025-09-23 16:26:19 +01:00
John Wellbelove
e88a74362b Modified to use new ETL_ASSERTs 2025-09-22 10:41:50 +01:00
John Wellbelove
cc62f212ab Rebased on development 2025-09-21 10:06:12 +01:00
John Wellbelove
62b5a4a6ae Rebased on development 2025-09-20 11:25:09 +01:00
John Wellbelove
1da478fa60 Merge branch 'hotfix/#1181-Compilation-errors-on-basic_string' into development
# Conflicts:
#	include/etl/optional.h
#	support/Release notes.txt
2025-09-18 09:09:53 +01:00
John Wellbelove
bc78ebb72e Fixed spelling of gdc to gcd 2025-09-18 09:07:34 +01:00
Roland Reichwein
16060ee0ae Guards around usage of std::initializer_list in optional.h (#1186)
* Guards around usage of std::initializer_list in optional.h

In optional.h, ETL_HAS_INITIALIZER_LIST is being used to
guard against cases where std::initializer_list is not available.
But not consistently. This changes fixes it by adding it in the
remaining places.

* Fixed #undef in optional.h

Instead of undefining ETL_OPTIONAL_ENABLE_CONSTEXPR_BOOL_RETURN_CPP14,
ETL_OPTIONAL_ENABLE_CONSTEXPR_BOOL_RETURN_CPP20_STL was undefined twice
(one of the misspelled).

* Fix comment typos
2025-09-18 09:01:25 +01:00
Roland Reichwein
191d4fb0f0 Guards around usage of std::initializer_list in optional.h (#1186)
* Guards around usage of std::initializer_list in optional.h

In optional.h, ETL_HAS_INITIALIZER_LIST is being used to
guard against cases where std::initializer_list is not available.
But not consistently. This changes fixes it by adding it in the
remaining places.

* Fixed #undef in optional.h

Instead of undefining ETL_OPTIONAL_ENABLE_CONSTEXPR_BOOL_RETURN_CPP14,
ETL_OPTIONAL_ENABLE_CONSTEXPR_BOOL_RETURN_CPP20_STL was undefined twice
(one of the misspelled).

* Fix comment typos
2025-09-18 08:52:30 +01:00
John Wellbelove
cabfa28401 Updated version and release notes 2025-09-18 08:52:30 +01:00
Marco Nilsson
9f7e4abd42 Remove noexcept from delegate method stubs. (#1185)
In addition to removing noexcept from call_if, this is also needed to prevent
an abort when cancelling a pthread that is executing a delegate.
2025-09-18 08:52:29 +01:00
John Wellbelove
f5bdca7216 Updated version and release notes 2025-09-18 08:52:28 +01:00
John Wellbelove
8ed8a47c55 Updated version and release notes 2025-09-18 08:52:28 +01:00
John Wellbelove
88e2aaeec0 Removed ETL_NOEXCEPT from delegate operator(), call_if(), and call_or()
Removed ETL_NOEXCEPT from closureoperator(), call_if(), and call_or()
2025-09-18 08:52:27 +01:00
Roland Reichwein
a21b96396e Guards around usage of std::initializer_list in optional.h (#1186)
* Guards around usage of std::initializer_list in optional.h

In optional.h, ETL_HAS_INITIALIZER_LIST is being used to
guard against cases where std::initializer_list is not available.
But not consistently. This changes fixes it by adding it in the
remaining places.

* Fixed #undef in optional.h

Instead of undefining ETL_OPTIONAL_ENABLE_CONSTEXPR_BOOL_RETURN_CPP14,
ETL_OPTIONAL_ENABLE_CONSTEXPR_BOOL_RETURN_CPP20_STL was undefined twice
(one of the misspelled).

* Fix comment typos
2025-09-18 08:50:28 +01:00
John Wellbelove
e4117e9eb4 Updated version and release notes 2025-09-18 08:50:27 +01:00
Marco Nilsson
c80939759c Remove noexcept from delegate method stubs. (#1185)
In addition to removing noexcept from call_if, this is also needed to prevent
an abort when cancelling a pthread that is executing a delegate.
2025-09-18 08:50:26 +01:00
John Wellbelove
df6d3b8f02 Updated version and release notes 2025-09-18 08:50:25 +01:00
John Wellbelove
5177f69994 Updated version and release notes 2025-09-18 08:50:25 +01:00
John Wellbelove
7a2c918b1e Removed ETL_NOEXCEPT from delegate operator(), call_if(), and call_or()
Removed ETL_NOEXCEPT from closureoperator(), call_if(), and call_or()
2025-09-18 08:50:24 +01:00
John Wellbelove
294720937f Added and fixed noexcept attributes
Added ETL_NOEXCEPT_FROM to set noexcept attributes based on an object or function.
2025-09-17 20:44:52 +01:00
Roland Reichwein
9028cf09b3
Guards around usage of std::initializer_list in optional.h (#1186)
* Guards around usage of std::initializer_list in optional.h

In optional.h, ETL_HAS_INITIALIZER_LIST is being used to
guard against cases where std::initializer_list is not available.
But not consistently. This changes fixes it by adding it in the
remaining places.

* Fixed #undef in optional.h

Instead of undefining ETL_OPTIONAL_ENABLE_CONSTEXPR_BOOL_RETURN_CPP14,
ETL_OPTIONAL_ENABLE_CONSTEXPR_BOOL_RETURN_CPP20_STL was undefined twice
(one of the misspelled).

* Fix comment typos
2025-09-17 20:16:57 +01:00
John Wellbelove
f9cf20d79a Updated version and release notes 2025-09-13 08:28:22 +01:00
Marco Nilsson
18caa159ac
Remove noexcept from delegate method stubs. (#1185)
In addition to removing noexcept from call_if, this is also needed to prevent
an abort when cancelling a pthread that is executing a delegate.
2025-09-13 08:23:15 +01:00
John Wellbelove
c2e7e8aca9 Updated version and release notes 2025-09-12 20:38:41 +01:00
John Wellbelove
54ba9a8aea Updated version and release notes 2025-09-12 20:20:19 +01:00
John Wellbelove
5c91f8b573 Removed ETL_NOEXCEPT from delegate operator(), call_if(), and call_or()
Removed ETL_NOEXCEPT from closureoperator(), call_if(), and call_or()
2025-09-12 20:19:27 +01:00
John Wellbelove
9a9a96f5c5 Moved and renamed common class to base 2025-09-12 12:48:18 +01:00
John Wellbelove
fd7edc937d Added insert/remove tests 2025-09-12 12:47:51 +01:00
John Wellbelove
4165448282 Changed timer to match the internal layout of other timers 2025-09-12 12:47:18 +01:00
John Wellbelove
95ff22821c Added more ETL_NOEXCEPT to etl::array 2025-09-11 19:57:19 +01:00
John Wellbelove
5dfdea7115 Removed #define ETL_DEBUG as this is a project define 2025-09-11 19:57:18 +01:00
John Wellbelove
59ec7855c1 Add force CI check on piull requests 2025-09-11 19:57:18 +01:00
John Wellbelove
bc027139e2 Delete project navis files 2025-09-11 19:57:17 +01:00
David Ockey
042a62154e Removed forced unsigned int cast in type_def bit-shift operators (#1178)
* Removed UB in type_def bit-shift operators

* Changed shift operators to allow both signed and unsigned operands for shifts
This allows the library user to explicitly use unsigned values to avoid UB

* Fixed constexpr errors for CPP11

* Changed is_arithmetic checks to use is_integral since valid shifts require integral operands

* Removed need for CPP11 since changes are CPP03 compatible
2025-09-11 19:57:16 +01:00
John Wellbelove
b5e065e1c8 Updated version and release notes 2025-09-11 19:57:16 +01:00
Roland Reichwein
193b6ba3e8 Fix etl::typed_storage by supporting omitted destructors (#1182)
* Added coderabbitai configuration

* Added builtin mem function tests

* Modified etl::typed_storage

* Modified etl::typed_storage

# Conflicts:
#	include/etl/alignment.h

* Added ETL_NOEXCEPT and ETL_NOEXCEPT_IF_NO_THROW

* Added etl::typed_storage_ext and swap for same

* Added etl::typed_storage_ext and swap for same

# Conflicts:
#	include/etl/alignment.h

* Added release notes

* Fixes to GCC -O2 errors

* Changed char* parameters to value_type* parameters

* Fixed compilation issues for const containers unit tests

* Added automatic selection of __builtin_memxxx functions for GCC and clang

* Added enhanced coderabbit configuration

* Updated version and release notes

* Disabled constexpr const container tests for C++11

* Attempted fixes for MacOS compilation

* Attempted fixes for MacOS compilation

* Attempted fixes for MacOS compilation

* Attempted fixes for MacOS compilation

* Updated version and release notes

* feat: removed unreachable break statements (#1169)

* Updated version and release notes

* Modified etl::typed_storage

# Conflicts:
#	include/etl/alignment.h

* Fix etl::typed_storage by supporting omitted destructors

In a recent change to alignment.h, the etl::typed_storage was
changed in a way that in case of an already constructed object,
the object is created via assignment.

However, this contradicts the original use case that led to
etl::typed_storage in the first place:
https://github.com/ETLCPP/etl/pull/1023

The goal is to omit destructors (and at the same time support
classes with deleted assignment operators), so they can be optimized out
at link time.

This change reverts commit ac7b268 to restore the original
functionality and changes the test to reflect the original
use case.

* Fix missing create() in non-C++11 typed_storage_ext constructor

* Typo fix

---------

Co-authored-by: John Wellbelove <john.wellbelove@asterconsulting.co.uk>
Co-authored-by: Drew Rife <darife@jlg.com>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2025-09-11 19:57:15 +01:00
Roland Reichwein
ea91dabee5 Regression fix: Support zero arguments emplace() in etl::optional (#1183)
* Added coderabbitai configuration

* Added builtin mem function tests

* Modified etl::typed_storage

* Modified etl::typed_storage

# Conflicts:
#	include/etl/alignment.h

* Added ETL_NOEXCEPT and ETL_NOEXCEPT_IF_NO_THROW

* Added etl::typed_storage_ext and swap for same

* Added etl::typed_storage_ext and swap for same

# Conflicts:
#	include/etl/alignment.h

* Added release notes

* Fixes to GCC -O2 errors

* Changed char* parameters to value_type* parameters

* Fixed compilation issues for const containers unit tests

* Added automatic selection of __builtin_memxxx functions for GCC and clang

* Added enhanced coderabbit configuration

* Updated version and release notes

* Disabled constexpr const container tests for C++11

* Attempted fixes for MacOS compilation

* Attempted fixes for MacOS compilation

* Attempted fixes for MacOS compilation

* Attempted fixes for MacOS compilation

* Updated version and release notes

* feat: removed unreachable break statements (#1169)

* Updated version and release notes

* Modified etl::typed_storage

# Conflicts:
#	include/etl/alignment.h

* Support zero arguments emplace() in etl::optional

For non-fundamental types, a recent change in etl::optional was
introduced that doesn't support zero arguments emplace() anymore.

This change fixes it and adds the respective test.

---------

Co-authored-by: John Wellbelove <john.wellbelove@asterconsulting.co.uk>
Co-authored-by: Drew Rife <darife@jlg.com>
2025-09-11 19:57:15 +01:00
John Wellbelove
df30de2877 removed navis file from project 2025-09-11 19:57:14 +01:00
John Wellbelove
91aa52988b Added insert and remove timer callback tests to test_message_timer_interrupt and test_message_timer_locked 2025-09-11 19:28:03 +01:00
John Wellbelove
14c9e9d48e Merge branch 'pull-request/#1155-Added-callbacks-when-a-timer-is-inserted-or-removed' of https://github.com/ETLCPP/etl into pull-request/#1155-Added-callbacks-when-a-timer-is-inserted-or-removed 2025-09-11 18:39:12 +01:00
Mario Luzeiro
5f70befa4a
Added callbacks when a timer is inserted or removed (#1155) 2025-09-11 18:38:48 +01:00
John Wellbelove
73cf38cc57 Merge branch 'pull-request/#1155-Added-callbacks-when-a-timer-is-inserted-or-removed' of https://github.com/ETLCPP/etl into pull-request/#1155-Added-callbacks-when-a-timer-is-inserted-or-removed
# Conflicts:
#	test/vs2022/etl.vcxproj.filters
2025-09-11 18:27:54 +01:00
John Wellbelove
96201f7919 Add force CI check on piull requests 2025-09-11 18:21:54 +01:00
John Wellbelove
96f494aeae Delete project navis files 2025-09-11 18:21:10 +01:00
David Ockey
603c977733
Removed forced unsigned int cast in type_def bit-shift operators (#1178)
* Removed UB in type_def bit-shift operators

* Changed shift operators to allow both signed and unsigned operands for shifts
This allows the library user to explicitly use unsigned values to avoid UB

* Fixed constexpr errors for CPP11

* Changed is_arithmetic checks to use is_integral since valid shifts require integral operands

* Removed need for CPP11 since changes are CPP03 compatible
2025-09-11 16:23:50 +01:00
John Wellbelove
db57df1e41 Merge branch 'development'
# Conflicts:
#	include/etl/alignment.h
2025-09-10 20:54:48 +01:00
John Wellbelove
476c965a1f Updated version and release notes 2025-09-10 20:52:16 +01:00
mike919192
999c210d28
Debug assert (#1175)
* debug assert POC

* Swith to ETL_CONSTEXPR14

* Finish TODO checks

* First and last can be equal

* Add ETL_DEBUG_THROW_EXCEPTIONS

* Try allowing c++11 constexpr

* Add macro for throwing from c++11 constexpr

* Remove braces

* Add extra asserts in size_t overload functions

* Fill out debug asserts

* Line up comments
2025-09-10 10:52:22 +01:00
John Wellbelove
5add8a94a7 Merge branch 'development' of https://github.com/ETLCPP/etl into development 2025-09-10 10:50:09 +01:00
John Wellbelove
02853e5bb6 removed navis file from project 2025-09-10 10:50:02 +01:00
Roland Reichwein
d6d78eb8bd
Fix etl::typed_storage by supporting omitted destructors (#1182)
* Added coderabbitai configuration

* Added builtin mem function tests

* Modified etl::typed_storage

* Modified etl::typed_storage

# Conflicts:
#	include/etl/alignment.h

* Added ETL_NOEXCEPT and ETL_NOEXCEPT_IF_NO_THROW

* Added etl::typed_storage_ext and swap for same

* Added etl::typed_storage_ext and swap for same

# Conflicts:
#	include/etl/alignment.h

* Added release notes

* Fixes to GCC -O2 errors

* Changed char* parameters to value_type* parameters

* Fixed compilation issues for const containers unit tests

* Added automatic selection of __builtin_memxxx functions for GCC and clang

* Added enhanced coderabbit configuration

* Updated version and release notes

* Disabled constexpr const container tests for C++11

* Attempted fixes for MacOS compilation

* Attempted fixes for MacOS compilation

* Attempted fixes for MacOS compilation

* Attempted fixes for MacOS compilation

* Updated version and release notes

* feat: removed unreachable break statements (#1169)

* Updated version and release notes

* Modified etl::typed_storage

# Conflicts:
#	include/etl/alignment.h

* Fix etl::typed_storage by supporting omitted destructors

In a recent change to alignment.h, the etl::typed_storage was
changed in a way that in case of an already constructed object,
the object is created via assignment.

However, this contradicts the original use case that led to
etl::typed_storage in the first place:
https://github.com/ETLCPP/etl/pull/1023

The goal is to omit destructors (and at the same time support
classes with deleted assignment operators), so they can be optimized out
at link time.

This change reverts commit ac7b268 to restore the original
functionality and changes the test to reflect the original
use case.

* Fix missing create() in non-C++11 typed_storage_ext constructor

* Typo fix

---------

Co-authored-by: John Wellbelove <john.wellbelove@asterconsulting.co.uk>
Co-authored-by: Drew Rife <darife@jlg.com>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2025-09-10 10:41:09 +01:00
Roland Reichwein
75606fc079
Regression fix: Support zero arguments emplace() in etl::optional (#1183)
* Added coderabbitai configuration

* Added builtin mem function tests

* Modified etl::typed_storage

* Modified etl::typed_storage

# Conflicts:
#	include/etl/alignment.h

* Added ETL_NOEXCEPT and ETL_NOEXCEPT_IF_NO_THROW

* Added etl::typed_storage_ext and swap for same

* Added etl::typed_storage_ext and swap for same

# Conflicts:
#	include/etl/alignment.h

* Added release notes

* Fixes to GCC -O2 errors

* Changed char* parameters to value_type* parameters

* Fixed compilation issues for const containers unit tests

* Added automatic selection of __builtin_memxxx functions for GCC and clang

* Added enhanced coderabbit configuration

* Updated version and release notes

* Disabled constexpr const container tests for C++11

* Attempted fixes for MacOS compilation

* Attempted fixes for MacOS compilation

* Attempted fixes for MacOS compilation

* Attempted fixes for MacOS compilation

* Updated version and release notes

* feat: removed unreachable break statements (#1169)

* Updated version and release notes

* Modified etl::typed_storage

# Conflicts:
#	include/etl/alignment.h

* Support zero arguments emplace() in etl::optional

For non-fundamental types, a recent change in etl::optional was
introduced that doesn't support zero arguments emplace() anymore.

This change fixes it and adds the respective test.

---------

Co-authored-by: John Wellbelove <john.wellbelove@asterconsulting.co.uk>
Co-authored-by: Drew Rife <darife@jlg.com>
2025-09-10 10:37:30 +01:00
John Wellbelove
73243883ce Merge branch 'master' of https://github.com/ETLCPP/etl
# Conflicts:
#	.coderabbit.yaml
#	include/etl/alignment.h
#	support/Release notes.txt
2025-09-07 09:36:47 +01:00
John Wellbelove
ac7b268c32 Modified etl::typed_storage
# Conflicts:
#	include/etl/alignment.h
2025-09-07 09:31:40 +01:00
John Wellbelove
7301617708 Updated version and release notes 2025-09-07 09:26:54 +01:00
John Wellbelove
0d0e290474 Changed #if ETL_USING_STL to #if ETL_USING_STD_OSTREAM around std::basic_ostream
Fixed warnings when using ETL_DEBUG_COUNT in non debug build
2025-09-06 20:51:13 +01:00
John Wellbelove
2fa82d579e Macro changes to fix issues 2025-09-06 20:51:12 +01:00
John Wellbelove
d27adeb510 #1171 optional of a const arary can't be emplaced with gcc-15 2025-09-06 20:51:11 +01:00
John Wellbelove
ea61ff7770 Updated version and release notes 2025-09-06 20:51:10 +01:00
John Wellbelove
0326edef42 Replaced ETL_NOEXCEPT_IF_NO_THROW with ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS) 2025-09-06 20:51:10 +01:00
Roland Reichwein
363d2e8ab5
Make call interfaces in etl::delegate and etl::closure conditionally noexcept (#1172)
* Make all call interfaces in etl::delegate conditionally noexcept

This covers the case when the invoked code can throw.

For operator(), this was already implemented. Do similarly for the
other call interfaces.

* Make all call interfaces in etl::closure conditionally noexcept

Similar to etl::delegate, the contained delegate might be
throwing. Apply the same solution as in etl::delegate to make
the call interfaces conditionally noexcept.
2025-09-06 20:50:58 +01:00
John Wellbelove
97cd7e90dc Changed #if ETL_USING_STL to #if ETL_USING_STD_OSTREAM around std::basic_ostream
Fixed warnings when using ETL_DEBUG_COUNT in non debug build
2025-09-06 20:49:39 +01:00
John Wellbelove
1b65c4ec91 Macro changes to fix issues 2025-09-06 16:25:20 +01:00
Roland Reichwein
92f07a66fc
Fix .clang-format (#1177)
* Added coderabbitai configuration

* Fix .clang-format

---------

Co-authored-by: John Wellbelove <john.wellbelove@asterconsulting.co.uk>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2025-09-06 14:12:34 +01:00
John Wellbelove
0536abe826 #1171 optional of a const arary can't be emplaced with gcc-15 2025-09-06 11:23:20 +01:00
John Wellbelove
228d789a6c Updated version and release notes 2025-09-06 10:19:31 +01:00
John Wellbelove
ce1c0e504b Replaced ETL_NOEXCEPT_IF_NO_THROW with ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS) 2025-09-06 09:46:11 +01:00
David Ockey
b85b071a3e
Made all 'noexcept' statements use ETL_NOEXCEPT macro (#1179)
* Added coderabbitai configuration

* Made all 'noexcept' statements use ETL_NOEXCEPT macro

---------

Co-authored-by: John Wellbelove <john.wellbelove@asterconsulting.co.uk>
Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2025-09-06 09:32:03 +01:00
John Wellbelove
8c29238116 Updated version and release notes 2025-09-04 19:53:15 +01:00
Drew Rife
4bdb55cfe6 feat: removed unreachable break statements (#1169) 2025-09-04 19:53:14 +01:00
John Wellbelove
8dc10b7a37 Updated version and release notes 2025-09-04 19:53:14 +01:00
John Wellbelove
c2143f5d6c Attempted fixes for MacOS compilation 2025-09-04 19:53:13 +01:00
John Wellbelove
99432a8e71 Attempted fixes for MacOS compilation 2025-09-04 19:53:12 +01:00
John Wellbelove
1216ab2247 Attempted fixes for MacOS compilation 2025-09-04 19:53:11 +01:00
John Wellbelove
dffb611036 Attempted fixes for MacOS compilation 2025-09-04 19:53:11 +01:00
John Wellbelove
57e52ba217 Disabled constexpr const container tests for C++11 2025-09-04 19:53:10 +01:00
John Wellbelove
90f933ff69 Updated version and release notes 2025-09-04 19:53:09 +01:00
John Wellbelove
475e6dd878 Added enhanced coderabbit configuration 2025-09-04 19:53:08 +01:00
John Wellbelove
eea7fe227d Added automatic selection of __builtin_memxxx functions for GCC and clang 2025-09-04 19:52:50 +01:00
John Wellbelove
f835daec50 Fixed compilation issues for const containers unit tests 2025-09-04 19:52:49 +01:00
John Wellbelove
ebd2edde8f Changed char* parameters to value_type* parameters 2025-09-04 19:52:48 +01:00
John Wellbelove
0676f8345f Fixes to GCC -O2 errors 2025-09-04 19:52:47 +01:00
John Wellbelove
9db992256f Added release notes 2025-09-04 19:52:47 +01:00
John Wellbelove
ece4b711f5 Added etl::typed_storage_ext and swap for same
# Conflicts:
#	include/etl/alignment.h
2025-09-04 19:52:46 +01:00
John Wellbelove
33302790ba Added etl::typed_storage_ext and swap for same 2025-09-04 19:52:45 +01:00
John Wellbelove
aea6e7da8b Added ETL_NOEXCEPT and ETL_NOEXCEPT_IF_NO_THROW 2025-09-04 19:52:45 +01:00
John Wellbelove
dffbd1e1ef Modified etl::typed_storage
# Conflicts:
#	include/etl/alignment.h
2025-09-04 19:52:44 +01:00
John Wellbelove
c52b6d0673 Modified etl::typed_storage 2025-09-04 19:52:07 +01:00
John Wellbelove
e2a07c98bf Added builtin mem function tests 2025-09-04 19:52:06 +01:00
John Wellbelove
e760e62dcd Updated version and release notes 2025-09-04 19:45:12 +01:00
Drew Rife
515dcf4bf6
feat: removed unreachable break statements (#1169) 2025-09-04 19:32:57 +01:00
John Wellbelove
efdfee8333 Updated version and release notes 2025-09-04 18:07:00 +01:00
John Wellbelove
bb628aa25d Attempted fixes for MacOS compilation 2025-09-04 15:00:22 +01:00
John Wellbelove
b5ea03133d Attempted fixes for MacOS compilation 2025-09-04 14:35:16 +01:00
John Wellbelove
73ae8f4d85 Attempted fixes for MacOS compilation 2025-09-04 14:26:01 +01:00
John Wellbelove
2d1af2dfb6 Attempted fixes for MacOS compilation 2025-09-04 13:51:32 +01:00
John Wellbelove
0deb855676 Disabled constexpr const container tests for C++11 2025-09-04 12:52:35 +01:00
John Wellbelove
958c331d49 Updated version and release notes 2025-09-04 11:29:02 +01:00
John Wellbelove
76d0a78463 Added enhanced coderabbit configuration 2025-09-04 11:27:27 +01:00
John Wellbelove
51675a6ce7 Added automatic selection of __builtin_memxxx functions for GCC and clang 2025-09-04 10:11:57 +01:00
John Wellbelove
119d381570 Fixed compilation issues for const containers unit tests 2025-09-04 10:10:52 +01:00
John Wellbelove
d92eb4d3ff Changed char* parameters to value_type* parameters 2025-09-04 10:10:02 +01:00
John Wellbelove
3837e36d71 Fixes to GCC -O2 errors 2025-09-02 13:51:45 +01:00
John Wellbelove
c93440dadb Added coderabbitai configuration 2025-08-30 18:29:52 +01:00
John Wellbelove
18f50d01c4 Added release notes 2025-08-28 14:09:17 +01:00
John Wellbelove
89c479ef15 Added etl::typed_storage_ext and swap for same
# Conflicts:
#	include/etl/alignment.h
2025-08-28 13:45:41 +01:00
John Wellbelove
18a7e79c56 Added etl::typed_storage_ext and swap for same 2025-08-28 10:30:24 +01:00
John Wellbelove
7c2804c1a9 Added ETL_NOEXCEPT and ETL_NOEXCEPT_IF_NO_THROW 2025-08-26 17:41:51 +01:00
John Wellbelove
bfe4f62574 Merge branch 'feature/#1170-Place-a-typed-pointer-instead-of-a-bool-into-etl--typed_storage' of https://github.com/ETLCPP/etl into feature/#1170-Place-a-typed-pointer-instead-of-a-bool-into-etl--typed_storage
# Conflicts:
#	include/etl/alignment.h
2025-08-26 17:39:08 +01:00
John Wellbelove
0081cfa794 Modified etl::typed_storage 2025-08-26 17:38:46 +01:00
John Wellbelove
0ca68938ff Modified etl::typed_storage 2025-08-26 16:43:33 +01:00
John Wellbelove
5f8b7f7120 Added builtin mem function tests 2025-08-22 19:20:15 +01:00
John Wellbelove
f801b9a093 Fix VS2022 filters 2025-08-20 09:25:50 +01:00
John Wellbelove
e3dac1e33e Merge branch 'development' 2025-08-19 19:13:31 +01:00
John Wellbelove
cde5bcff69 Updated release notes and version 2025-08-19 18:50:57 +01:00
John Wellbelove
2a970134da Removed releaser and destroyer in favour of lambdas and similar 2025-08-19 16:01:46 +01:00
John Wellbelove
6b7bfb8633 Merge branch 'development' of https://github.com/ETLCPP/etl into development 2025-08-19 13:18:34 +01:00
John Wellbelove
4d5cb98d29 Fixed ETL_NOEXCEPT_IF_NO_THROW and #define ETL_NOEXCEPT_IF_NO_THROW_EXPR(...) for C++03
Updated example

Added releaser and destroyer functors to etl::ipool to simplify integration with etl::unique_ptr
2025-08-19 13:18:21 +01:00
John Wellbelove
fb6c42ec78 Fixed ETL_NOEXCEPT_IF_NO_THROW and #define ETL_NOEXCEPT_IF_NO_THROW_EXPR(...) for C++03 2025-08-18 19:45:40 +01:00
John Wellbelove
5f37af3f83 Changed release() to destroy() to match create() 2025-08-18 19:44:51 +01:00
John Wellbelove
44ec1e4f25 Updated release notes 2025-08-18 17:34:53 +01:00
John Wellbelove
ac1d2c82d1 Added not_null comparison tests 2025-08-18 17:13:07 +01:00
John Wellbelove
0a5fcef331 Merge branch 'feature/#1166-Feature-Request--implement-not_null' of https://github.com/ETLCPP/etl into feature/#1166-Feature-Request--implement-not_null 2025-08-18 16:52:00 +01:00
John Wellbelove
3a25d5934a Added constexpr. Removed some member functions. Removed 'move' member functions for etl::not_null<etl::unique_ptr<T, TDeleter>> 2025-08-18 16:51:49 +01:00
John Wellbelove
3bc87f1045 Changed unique() to underlying_type()
Added underlying_type() to etl::not_null<T*>
2025-08-18 16:51:00 +01:00
John Wellbelove
2d22dfe236 Changed unique() to underlying_type()
Added underlying_type() to etl::not_null<T*>
2025-08-18 16:50:59 +01:00
John Wellbelove
877ef005ea Fixed file Id error
Updated CMakeLists.txt for tests and syntax checks
2025-08-18 16:50:58 +01:00
John Wellbelove
28d90aa80c Initial implementation 2025-08-18 16:50:57 +01:00
John Wellbelove
f6fd44a096 Initial implementation 2025-08-18 16:50:57 +01:00
John Wellbelove
63d7470685 Added etl::nontype_t, with C++11 and C++17 alternatives 2025-08-18 14:22:33 +01:00
John Wellbelove
450948933f Added example of the use of etl::unique_ptr with etl::pool 2025-08-18 14:20:45 +01:00
John Wellbelove
037029ea84 Added constexpr. Removed some member functions. Removed 'move' member functions for etl::not_null<etl::unique_ptr<T, TDeleter>> 2025-08-17 10:37:27 +01:00
John Wellbelove
ae8aff5ed8 Merge branch 'feature/#1166-Feature-Request--implement-not_null' of https://github.com/ETLCPP/etl into feature/#1166-Feature-Request--implement-not_null 2025-08-16 10:57:20 +01:00
John Wellbelove
2edde546c4 Merge branch 'feature/#1166-Feature-Request--implement-not_null' of https://github.com/ETLCPP/etl into feature/#1166-Feature-Request--implement-not_null 2025-08-16 10:57:14 +01:00
John Wellbelove
1963593159 Merge branch 'feature/#1166-Feature-Request--implement-not_null' of https://github.com/ETLCPP/etl into feature/#1166-Feature-Request--implement-not_null 2025-08-16 10:38:38 +01:00
John Wellbelove
94f7d9956d Changed unique() to underlying_type()
Added underlying_type() to etl::not_null<T*>
2025-08-16 10:38:29 +01:00
John Wellbelove
d7585508da Changed unique() to underlying_type()
Added underlying_type() to etl::not_null<T*>
2025-08-16 10:12:41 +01:00
John Wellbelove
109ba9350d Updated syntax check tests 2025-08-15 19:26:18 +01:00
John Wellbelove
08ed69bac7 Fixed file Id error
Updated CMakeLists.txt for tests and syntax checks
2025-08-15 18:04:50 +01:00
John Wellbelove
20f5c0402e Initial implementation 2025-08-15 17:18:15 +01:00
John Wellbelove
9c046b710c Initial implementation 2025-08-15 10:27:35 +01:00
John Wellbelove
f67ae46be6 Merge branch 'master' of https://github.com/ETLCPP/etl 2025-08-15 10:25:46 +01:00
John Wellbelove
efae99252b Fixed VS2022 project file list 2025-08-15 10:25:08 +01:00
John Wellbelove
5312f5eddd Added explicit check for remainder in divide_round_to_infinity 2025-08-15 10:24:45 +01:00
John Wellbelove
2a32826b86 Merge branch 'master' of https://github.com/ETLCPP/etl 2025-08-13 21:07:03 +01:00
John Wellbelove
3553f5db22 Fixed VS2022 project file list 2025-08-13 21:06:35 +01:00
John Wellbelove
8c49e67702 Added return_type and argument_types to etl::delegate 2025-08-13 19:51:31 +01:00
John Wellbelove
2d470d20f5 Fixed VS2022 project file list 2025-08-13 17:51:03 +01:00
John Wellbelove
1af74206d2 Updated PlatformIO action 2025-08-13 16:10:35 +01:00
John Wellbelove
534fcc6ebe Updated fsm generator 2025-08-13 10:46:14 +01:00
John Wellbelove
e449a09b3e Added automated PlatformIO update CI action 2025-08-13 10:37:59 +01:00
John Wellbelove
ca5f5394f7 Minor style change 2025-08-13 10:14:13 +01:00
John Wellbelove
87f121222f Merge branch 'development' of https://github.com/ETLCPP/etl into development
# Conflicts:
#	test/test_delegate_observable.cpp
2025-08-13 09:32:12 +01:00
John Wellbelove
f973d31ad1 Merge branch 'development' of https://github.com/ETLCPP/etl into development
# Conflicts:
#	test/test_delegate_observable.cpp
2025-08-13 09:31:42 +01:00
John Wellbelove
85b15552ba Merge branch 'development' of https://github.com/ETLCPP/etl into development
# Conflicts:
#	test/test_delegate_observable.cpp
2025-08-13 08:53:26 +01:00
John Wellbelove
b734df629b Attempt to fix Github CI
GCC 11 incompatibility
2025-08-13 08:53:03 +01:00
John Wellbelove
4beadd18f4 Attempt to fix Github CI
GCC 11 incompatibility
2025-08-13 08:49:23 +01:00
John Wellbelove
8f94ef619a Attempt to fix Github CI
GCC 11 incompatibility
2025-08-12 21:32:51 +01:00
John Wellbelove
5c24ae2f0d Attempt to fix Github CI
GCC 11 incompatibility
2025-08-12 21:21:16 +01:00
John Wellbelove
3e95e772c3 Attempt to fix Github CI 2025-08-12 18:28:04 +01:00
John Wellbelove
310cc6e501 Attempt to fix Github CI 2025-08-12 18:22:52 +01:00
John Wellbelove
86f76933c1 Added full rounded integral division 2025-08-12 15:13:03 +01:00
John Wellbelove
ddfd3fa443 Added remaining limits tests
Fixed divide_round_half_odd and added tests
2025-08-11 20:19:18 +01:00
John Wellbelove
5c52fd19cc Added new unit tests
Fixed integer overflow issue at limits
2025-08-11 09:49:37 +01:00
John Wellbelove
ff1e4296bc Added complete set of rounded integral division 2025-08-07 18:45:46 +01:00
John Wellbelove
2de4057021 Added transition_to member function to change state
Pulled out the core state change code to process_state_change
2025-08-05 18:48:15 +01:00
John Wellbelove
2ae0a422cd Updated release notes 2025-08-04 20:36:02 +01:00
John Wellbelove
0fc2cfeff3 Updated fsm_generator.h to match edited fsm.h 2025-08-04 17:20:05 +01:00
John Wellbelove
5d694e7aa8 Added ETL_UNLIKELY to ETL_ASSERT if (!(b)) conditions 2025-08-04 16:11:20 +01:00
John Wellbelove
1d4dbc8976 Added etl::fsm_state_pack and corresponding constructor 2025-08-04 16:10:04 +01:00
John Wellbelove
7504646301 Added delegate_observable 2025-08-03 16:22:50 +01:00
John Wellbelove
51a4d0e8da Update templates for pentential macro name conflicts 2025-08-03 16:22:10 +01:00
John Wellbelove
e67066b788 Added emplace type constructors to etl::optional 2025-08-02 13:47:33 +01:00
John Wellbelove
2cd28ce7c5 Fixed minor issues 2025-08-01 09:23:42 +01:00
John Wellbelove
5a2aeb683e Update templates for potential macro name conflicts 2025-07-28 09:32:10 +01:00
John Wellbelove
fa25b8cd5e Added instructions and scripts the convert ETL header guards 2025-07-27 11:23:20 +01:00
John Wellbelove
5fc7e33228 Added basic instructions for using guard2once and once2guard 2025-07-27 10:39:40 +01:00
John Wellbelove
43385fea63 Very minor layout change 2025-07-27 10:38:49 +01:00
John Wellbelove
e60f68bad8 Removed asserts from copy_s and move_s algorithms 2025-07-27 10:38:20 +01:00
John Wellbelove
c26e2de7ec Changed generate scripts to use python3 2025-07-27 10:35:49 +01:00
John Wellbelove
833e352dcb Merge branch 'hotfix/#1154-etl-20.42.2-not-compiling-with-IAR-Arm-compiler-v9.20' into development 2025-07-26 19:35:57 +01:00
John Wellbelove
b7de57fbf1 Update templates for pentential macro name conflicts 2025-07-26 14:10:01 +01:00
John Wellbelove
05e45117ea Update templates for pentential macro name conflicts 2025-07-26 13:23:02 +01:00
John Wellbelove
b77698810f hotfix #1154-etl-20.42.2-not-compiling-with-IAR-Arm-compiler-v9.20 2025-07-24 15:40:10 +01:00
John Wellbelove
5df08645da Updated release notes 2025-07-20 12:45:14 +01:00
John Wellbelove
7858d66884 Removed redundant VS2022 project settings 2025-07-20 11:14:23 +01:00
John Wellbelove
5d7573e513 Minor changes 2025-07-20 11:05:44 +01:00
John Wellbelove
42677dd9ee Merge branch 'pull-request/#955-Implements-deferred-callback-timer-with-optional-priority' of https://github.com/ETLCPP/etl into pull-request/#955-Implements-deferred-callback-timer-with-optional-priority
# Conflicts:
#	test/CMakeLists.txt
2025-07-20 08:42:59 +01:00
Mario Luzeiro
5c5e5df788 Implements deferred callback timer with optional priority (#955)
* Refactored callback_timer_locked to allow base class extention of tick method

* Implement callback timer deferred with priority option

---------

Co-authored-by: Mario Luzeiro <mluzeiro@gliderbits.com>
2025-07-20 08:36:04 +01:00
John Wellbelove
f07b7e75fc Updated release notes 2025-07-19 16:12:00 +01:00
John Wellbelove
2c904baf80 Updated release notes 2025-07-19 16:10:08 +01:00
John Wellbelove
0e6e961039 #1126 to_arithmetic does not compile on C++98 2025-07-19 15:54:06 +01:00
John Wellbelove
7f53572b53 Fix gamma tests 2025-07-18 16:33:23 +01:00
John Wellbelove
8de211acd9 #1151 test failure in i386 in 20.42.1: test_replace_strings in test_string_utilities.c fails 2025-07-18 14:59:25 +01:00
John Wellbelove
13fa2801a3 Updated version and release notes 2025-07-15 11:12:05 +01:00
John Wellbelove
d7875adf9e Added CRC64-ISO added 2025-07-15 10:36:43 +01:00
John Wellbelove
481e29896a Merge branch 'pull-request/#1149-Fix-bug-in-the-void-etl--unlink(first,-last)-for-bidirectional-links' into development 2025-07-14 09:53:40 +01:00
Sergei
4979c8a20b
Fix bug in the void etl::unlink(first, last) for bidirectional links. (#1149)
* Reproduce bug in the `void etl::unlink(first, last)` for bidirectional links.

- correct `test_unlink_range_bidirectional_link` unit test according to the documentation - now this test fails.
- enhance `test_intrusive_list::test_splice_range_self` unit test to verify also `etl_previous` links after splicing lists - now unit test crashes.

* Fix bug in the `void etl::unlink(first, last)` for bidirectional links.

- `test_unlink_range_bidirectional_link` unit test now is green.
- `test_intrusive_list::test_splice_range_self` is not crashing anymore and green.
2025-07-14 08:50:28 +01:00
John Wellbelove
be5a6e2951 Added CRC8 and CRC16 opensafety algorithms 2025-07-14 08:43:20 +01:00
John Wellbelove
73e354c3be Added constexpr for delegate invocations 2025-07-14 08:42:27 +01:00
John Wellbelove
8e02bb3059 Strengthened static assert tests
Changed enable_if checks to static asserts
2025-07-13 10:33:30 +01:00
John Wellbelove
dffd86544c Added etl::type_lists_are_convertible 2025-07-13 10:33:29 +01:00
John Wellbelove
400f438958
Update README.md 2025-07-13 10:19:09 +01:00
John Wellbelove
69f34515e0
Update README.md 2025-07-13 09:32:17 +01:00
John Wellbelove
e4620be180
Update README.md 2025-07-13 09:23:28 +01:00
John Wellbelove
fa77f58247 Updated version and release notes 2025-07-11 15:48:55 +01:00
Roland Reichwein
1a430f4029
Fix compile error in closure.h by using etl::forward (#1147) 2025-07-11 15:44:59 +01:00
John Wellbelove
0f9a845050 Merge branch 'pull-request/#955-Implements-deferred-callback-timer-with-optional-priority' of https://github.com/ETLCPP/etl into pull-request/#955-Implements-deferred-callback-timer-with-optional-priority 2025-06-02 10:53:45 +01:00
Mario Luzeiro
acad52a9a4 Implements deferred callback timer with optional priority (#955)
* Refactored callback_timer_locked to allow base class extention of tick method

* Implement callback timer deferred with priority option

---------

Co-authored-by: Mario Luzeiro <mluzeiro@gliderbits.com>
2025-06-02 10:48:01 +01:00
Mario Luzeiro
7f86d07628
Implements deferred callback timer with optional priority (#955)
* Refactored callback_timer_locked to allow base class extention of tick method

* Implement callback timer deferred with priority option

---------

Co-authored-by: Mario Luzeiro <mluzeiro@gliderbits.com>
2025-02-04 10:05:20 +00:00
920 changed files with 143414 additions and 89157 deletions

View File

@ -1,51 +1,184 @@
---
#------------------------------------
# Configuration for clang-format v12
#------------------------------------
BasedOnStyle: LLVM
Standard: Auto # let the formatter accept any C++ standard
Language: Cpp
# =============================================================================
# Indentation
# =============================================================================
TabWidth: 2
ContinuationIndentWidth: 2
ConstructorInitializerIndentWidth: 2
NamespaceIndentation: All # everything inside namespace is indented
IndentCaseLabels: true # case labels at switch-body indent level
IndentCaseBlocks: true # indent block inside case label
IndentExternBlock: Indent
IndentWrappedFunctionNames: true # keep function name at same indent as return type
IndentPPDirectives: BeforeHash # nested #if / #include get indented before the #
PPIndentWidth: 2
SortIncludes: true
# =============================================================================
# Braces & line-break style
# =============================================================================
BreakBeforeBraces: Allman
BreakConstructorInitializers: BeforeComma # colon on new line, commas lead
BreakInheritanceList: BeforeComma
BreakBeforeBinaryOperators: NonAssignment
BreakStringLiterals: false
AlwaysBreakTemplateDeclarations: Yes # template <…> always on its own line
BreakAfterAttributes: Always
BasedOnStyle: Chromium
# =============================================================================
# Short statements
# =============================================================================
AllowShortBlocksOnASingleLine: Empty
AllowShortFunctionsOnASingleLine: Empty # only empty bodies: void f() {}
AllowShortCaseLabelsOnASingleLine: true # case X: stmt; break; on one line
AllowShortLoopsOnASingleLine: true
AllowShortLambdasOnASingleLine: Inline
BinPackParameters: false
BitFieldColonSpacing: Both
# =============================================================================
# Empty lines
# =============================================================================
KeepEmptyLinesAtTheStartOfBlocks: false
EmptyLineBeforeAccessModifier: Always # blank line before public:/private:/protected:
EmptyLineAfterAccessModifier: Always # blank line after public:/private:/protected:
InsertNewlineAtEOF: true
BreakBeforeBraces: Allman
BreakConstructorInitializers: BeforeComma
# =============================================================================
# Spacing
# =============================================================================
SpacesInAngles: Leave # preserve C++03 "> >" vs C++11 ">>"
SpacesInContainerLiterals: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
ConstructorInitializerIndentWidth: '2'
NamespaceIndentation: All
IndentPPDirectives: BeforeHash
PointerAlignment: Left
ColumnLimit: '0'
ContinuationIndentWidth: '2'
UseTab: Never
TabWidth: '2'
IndentWidth: '2'
AccessModifierOffset : '-2'
IndentCaseLabels: false
Cpp11BracedListStyle: 'true'
AlignAfterOpenBracket: Align
# =============================================================================
# Alignment
# =============================================================================
PointerAlignment: Left # T* ptr, const T& ref
ReferenceAlignment: Left
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignConsecutiveBitFields: true
AlignConsecutiveMacros: true # align macro bodies
#------------------------------------
# Configurations not supported by clang-format v12
#------------------------------------
# BreakInheritanceList: AfterComma
# EmptyLineBeforeAccessModifier: Always
# EmptyLineAfterAccessModifier: Always
# ReferenceAlignment: Left
# =============================================================================
# Line length and wrapping
# =============================================================================
ColumnLimit: 150
ReflowComments: true # preserve hand-formatted comment rulers
AlignEscapedNewlines: Left
...
# =============================================================================
# Includes
# =============================================================================
IncludeCategories:
- Regex: '^(<|")(.*/)?platform\.h(>|")$'
Priority: -1
- Regex: 'private'
Priority: 1
- Regex: '.*'
Priority: 0
# =============================================================================
# Arguments, parameters and constructor initialisers
# =============================================================================
PackConstructorInitializers: Never # each initialiser on its own line
# =============================================================================
# Namespaces and using declarations
# =============================================================================
SortUsingDeclarations: Lexicographic
# =============================================================================
# Macro-aware formatting
# =============================================================================
# ETL-specific macros that should be treated as statement-level constructs
StatementMacros:
- ETL_DECLARE_DEBUG_COUNT
- ETL_INCREMENT_DEBUG_COUNT
- ETL_DECREMENT_DEBUG_COUNT
- ETL_ADD_DEBUG_COUNT
- ETL_STATIC_ASSERT
- ETL_ASSERT
- ETL_ASSERT_OR_RETURN
- ETL_ASSERT_OR_RETURN_VALUE
- ETL_ASSERT_FAIL
- ETL_ASSERT_FAIL_AND_RETURN
- ETL_ASSERT_FAIL_AND_RETURN_VALUE
- ETL_MOVE
- ETL_ENUM_CLASS
- ETL_ENUM_CLASS_TYPE
- ETL_IF_CONSTEXPR
# Macros that behave like attributes or specifiers.
AttributeMacros:
- ETL_NORETURN
- ETL_FINAL
- ETL_OVERRIDE
- ETL_EXPLICIT
- ETL_DELETE
- ETL_CONSTANT
- ETL_CONSTEXPR
- ETL_CONSTEXPR11
- ETL_CONSTEXPR14
- ETL_CONSTEXPR17
- ETL_CONSTEXPR20
- ETL_CONSTEXPR23
- ETL_CONSTEVAL
- ETL_NODISCARD
- ETL_NORETURN
- ETL_DEPRECATED
- ETL_DEPRECATED_REASON
- ETL_LIKELY
- ETL_UNLIKELY
- ETL_FALLTHROUGH
- ETL_MAYBE_UNUSED
- ETL_INLINE_VAR
- ETL_ASSUME
- ETL_LVALUE_REF_QUALIFIER
- ETL_RVALUE_REF_QUALIFIER
- ETL_NOEXCEPT
- ETL_NOEXCEPT_EXPR
- ETL_NOEXCEPT_IF
- ETL_NOEXCEPT_FROM
Macros:
- ETL_NORETURN=[[noreturn]]
- ETL_FINAL=final
- ETL_OVERRIDE=override
- ETL_EXPLICIT=explicit
- ETL_DELETE=delete
- ETL_CONSTANT=const
- ETL_CONSTEXPR=constexpr
- ETL_CONSTEXPR11=constexpr
- ETL_CONSTEXPR14=constexpr
- ETL_CONSTEXPR17=constexpr
- ETL_CONSTEXPR20=constexpr
- ETL_CONSTEXPR23=constexpr
- ETL_CONSTEVAL=consteval
- ETL_NODISCARD=[[nodiscard]]
- ETL_NORETURN=[[noreturn]]
- ETL_DEPRECATED=[[deprecated]]
# - ETL_DEPRECATED_REASON=[[deprecated(%0)]] # Hangs with clang-format 18
- ETL_LIKELY=[[likely]]
- ETL_UNLIKELY=[[unlikely]]
- ETL_FALLTHROUGH=[[fallthrough]]
- ETL_MAYBE_UNUSED=[[maybe_unused]]
- ETL_INLINE_VAR=inline
- ETL_ASSUME=[[assume(&0)]]
- ETL_LVALUE_REF_QUALIFIER=&
- ETL_RVALUE_REF_QUALIFIER=&&
- ETL_NOEXCEPT=noexcept
# - ETL_NOEXCEPT_EXPR=noexcept(&0)) # Hangs with clang-format 18
# - ETL_NOEXCEPT_IF=noexcept(&0) # Hangs with clang-format 18
# - ETL_NOEXCEPT_FROM=noexcept(&0) # Hangs with clang-format 18
# Macros that behave like type names
TypenameMacros:
- ETL_OR_STD
# Do not reformat these macros — they contain DSL-like content
WhitespaceSensitiveMacros:
- ETL_ERROR_TEXT
- ETL_DECLARE_ENUM_TYPE
- ETL_ENUM_TYPE
- ETL_END_ENUM_TYPE

200
.coderabbit.yaml Normal file
View File

@ -0,0 +1,200 @@
language: "en-GB"
early_access: false
reviews:
profile: "chill"
request_changes_workflow: false
high_level_summary: false
high_level_summary_in_walkthrough: false
poem: false
review_status: false
collapse_walkthrough: false
changed_files_summary: false
sequence_diagrams: false
estimate_code_review_effort: false
assess_linked_issues: false
related_issues: false
related_prs: false
suggested_labels: false
suggested_reviewers: false
auto_review:
enabled: true
drafts: false
path_instructions:
- path: "include/etl/*.h"
instructions: |
Review the C++ code in these directories. The code must not use
STL containers but must instead rely on Embedded Template Library
(ETL) for data structures and algorithms.
When answering questions, provide accurate and concise information based on the ETL documentation and codebase. If you don't know the answer, just say "I don't know". Do not make up answers.
When providing code examples, ensure they are relevant to the ETL and follow its conventions.
Always be polite and professional in your responses.
Header files should start with the ETL's standard MIT comment block.
Header files should have include guards in the format '#ifndef ETL_<FILENAME>>_INCLUDED #define ETL_<FILENAME>_INCLUDED #endif'
Headers should be organized in the following order
- The first header include should be '#include "platform.h"'
- Headers from the ETL
- Headers from the path 'private/**'
- C++ standard library headers
- C standard library headers
Pay extra attention to the following
- Buffer overflows
- Memory leaks
- Undefined behavior
Check that the following conventions are used
- Variable names should be in `snake_case`
- Macro constants should be `ALL_CAPS_WITH_UNDERSCORES`
- Macro constants should be prefixed with 'ETL_'
- Function, class, and type names should be `snake_case`
- enum members should be `Caps_Snake_Case`
Please keep your outputs short and to the point, unless otherwise asked
- Keep your responses short, describe small issues in a few sentences
- Don't output tips, analysis chains or anything else with a collapsible view
- Don't output `comment summaries` or `fix prompts for AIs`
- If the highlighted issue is complex, don't suggest a solution
- Don't use emojis
- path: "include/etl/atomic/*.h"
instructions: |
Review the C++ code in these directories. The code must not use
STL containers but must instead rely on Embedded Template Library
(ETL) for data structures and algorithms.
When answering questions, provide accurate and concise information based on the ETL documentation and codebase. If you don't know the answer, just say "I don't know". Do not make up answers.
When providing code examples, ensure they are relevant to the ETL and follow its conventions.
Always be polite and professional in your responses.
Header files should start with the ETL's standard MIT comment block.
Header files are allowed to not have include guards
Headers should be organized in the following order
- Headers from the ETL
- Headers from the path 'private/**'
- C++ standard library headers
- C standard library headers
Pay extra attention to the following
- Buffer overflows
- Memory leaks
- Undefined behavior
Check that the following conventions are used
- Variable names should be in `snake_case`
- Macro constants should be `ALL_CAPS_WITH_UNDERSCORES`
- Macro constants should be prefixed with 'ETL_'
- Function, class, and type names should be `snake_case`
- enum members should be `Caps_Snake_Case`
Please keep your outputs short and to the point, unless otherwise asked
- Keep your responses short, describe small issues in a few sentences
- Don't output tips, analysis chains or anything else with a collapsible view
- Don't output `comment summaries` or `fix prompts for AIs`
- If the highlighted issue is complex, don't suggest a solution
- Don't use emojis
- path: "include/etl/atomic/*.h"
instructions: |
Review the C++ code in these directories. The code must not use
STL containers but must instead rely on Embedded Template Library
(ETL) for data structures and algorithms.
When answering questions, provide accurate and concise information based on the ETL documentation and codebase. If you don't know the answer, just say "I don't know". Do not make up answers.
When providing code examples, ensure they are relevant to the ETL and follow its conventions.
Always be polite and professional in your responses.
Header files should start with the ETL's standard MIT comment block.
Header files are allowed to not have include guards
Headers should be organized in the following order
- Headers from the ETL
- Headers from the path 'private/**'
- C++ standard library headers
- C standard library headers
Pay extra attention to the following
- Buffer overflows
- Memory leaks
- Undefined behavior
Check that the following conventions are used
- Variable names should be in `snake_case`
- Macro constants should be `ALL_CAPS_WITH_UNDERSCORES`
- Macro constants should be prefixed with 'ETL_'
- Function, class, and type names should be `snake_case`
- enum members should be `Caps_Snake_Case`
Please keep your outputs short and to the point, unless otherwise asked
- Keep your responses short, describe small issues in a few sentences
- Don't output tips, analysis chains or anything else with a collapsible view
- Don't output `comment summaries` or `fix prompts for AIs`
- If the highlighted issue is complex, don't suggest a solution
- Don't use emojis
- path: "include/etl/mutex/*.h"
instructions: |
Review the C++ code in these directories. The code must not use
STL containers but must instead rely on Embedded Template Library
(ETL) for data structures and algorithms.
When answering questions, provide accurate and concise information based on the ETL documentation and codebase. If you don't know the answer, just say "I don't know". Do not make up answers.
When providing code examples, ensure they are relevant to the ETL and follow its conventions.
Always be polite and professional in your responses.
Header files should start with the ETL's standard MIT comment block.
Header files are allowed to not have include guards
Headers should be organized in the following order
- Headers from the ETL
- Headers from the path 'private/**'
- C++ standard library headers
- C standard library headers
Pay extra attention to the following
- Buffer overflows
- Memory leaks
- Undefined behavior
Check that the following conventions are used
- Variable names should be in `snake_case`
- Macro constants should be `ALL_CAPS_WITH_UNDERSCORES`
- Macro constants should be prefixed with 'ETL_'
- Function, class, and type names should be `snake_case`
- enum members should be `Caps_Snake_Case`
Please keep your outputs short and to the point, unless otherwise asked
- Keep your responses short, describe small issues in a few sentences
- Don't output tips, analysis chains or anything else with a collapsible view
- Don't output `comment summaries` or `fix prompts for AIs`
- If the highlighted issue is complex, don't suggest a solution
- Don't use emojis
- path: "include/etl/deprecated/*.h"
instructions: |
Ingnore files in this directory
- path: "include/etl/experimental/*.h"
instructions: |
Ingnore files in this directory
- path: "include/etl/generators/*.h"
instructions: |
Ingnore files in this directory
- path: "include/etl/profiles/*.h"
instructions: |
Ingnore files in this directory
chat:
art: false
auto_reply: true

View File

@ -1,18 +1,61 @@
ARG BASE_IMAGE_NAME="clang:latest"
ARG BASE_IMAGE_NAME="mcr.microsoft.com/devcontainers/cpp:2@sha256:a5eb5a1e9109af88bf82ebb0f71903608a68144851ed1e4b852e31b251ac59c6"
FROM ${BASE_IMAGE_NAME}
ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="3.31.7"
ARG DEBIAN_SNAPSHOT="20260223T000000Z"
# Optionally install the cmake for vcpkg
COPY ./reinstall-cmake.sh /tmp/
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
git \
wget
ENV LANG=C.UTF-8 \
LC_ALL=C.UTF-8 \
TZ=UTC
RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \
chmod +x /tmp/reinstall-cmake.sh && /tmp/reinstall-cmake.sh ${REINSTALL_CMAKE_VERSION_FROM_SOURCE}; \
RUN set -eux \
&& export DEBIAN_FRONTEND=noninteractive \
&& if [[ "${DEBIAN_SNAPSHOT}" != "none" ]]; then \
snapshot_main="http://snapshot.debian.org/archive/debian/${DEBIAN_SNAPSHOT}"; \
snapshot_security="http://snapshot.debian.org/archive/debian-security/${DEBIAN_SNAPSHOT}"; \
if [[ -f /etc/apt/sources.list.d/debian.sources ]]; then \
sed -ri "s|^URIs: https?://deb.debian.org/debian$|URIs: ${snapshot_main}|g" /etc/apt/sources.list.d/debian.sources; \
sed -ri "s|^URIs: https?://deb.debian.org/debian-security$|URIs: ${snapshot_security}|g" /etc/apt/sources.list.d/debian.sources; \
elif [[ -f /etc/apt/sources.list ]] || compgen -G "/etc/apt/sources.list.d/*.list" > /dev/null; then \
for list_file in /etc/apt/sources.list /etc/apt/sources.list.d/*.list; do \
[[ -f "${list_file}" ]] || continue; \
sed -ri "s|https?://deb.debian.org/debian|${snapshot_main}|g" "${list_file}"; \
sed -ri "s|https?://security.debian.org/debian-security|${snapshot_security}|g" "${list_file}"; \
sed -ri "s|https?://deb.debian.org/debian-security|${snapshot_security}|g" "${list_file}"; \
done; \
else \
echo "ERROR: DEBIAN_SNAPSHOT='${DEBIAN_SNAPSHOT}' is set, but no supported apt source files were found."; \
echo "Expected /etc/apt/sources.list.d/debian.sources or one or more .list files under /etc/apt/."; \
exit 1; \
fi; \
printf 'Acquire::Check-Valid-Until "false";\n' > /etc/apt/apt.conf.d/99snapshot; \
fi \
&& rm -f /tmp/reinstall-cmake.sh
&& apt-get update \
&& apt-get -y install --no-install-recommends \
python3-full \
python3-pip \
git \
wget \
cmake \
&& rm -rf /var/lib/apt/lists/* \
&& if pip help install | grep -q '\-\-break-system-packages'; then \
pip install --no-cache-dir --break-system-packages cogapp; \
else \
pip install --no-cache-dir cogapp; \
fi
RUN set -eux \
&& echo "Pip version: " \
&& pip --version \
&& echo "Cogapp version: " \
&& pip show cogapp \
&& echo "Git version: " \
&& git --version \
&& echo "Wget version: " \
&& wget --version \
&& echo "Cmake version: " \
&& cmake --version \
&& echo "Make version: " \
&& make --version

View File

@ -5,7 +5,8 @@
"build": {
"dockerfile": "../Dockerfile",
"args": {
"BASE_IMAGE_NAME": "silkeh/clang:10"
"BASE_IMAGE_NAME": "silkeh/clang:10",
"DEBIAN_SNAPSHOT": "none"
},
"context": "../context"
}

View File

@ -5,7 +5,8 @@
"build": {
"dockerfile": "../Dockerfile",
"args": {
"BASE_IMAGE_NAME": "silkeh/clang:11"
"BASE_IMAGE_NAME": "silkeh/clang:11",
"DEBIAN_SNAPSHOT": "none"
},
"context": "../context"
}

View File

@ -5,7 +5,8 @@
"build": {
"dockerfile": "../Dockerfile",
"args": {
"BASE_IMAGE_NAME": "silkeh/clang:12"
"BASE_IMAGE_NAME": "silkeh/clang:12",
"DEBIAN_SNAPSHOT": "none"
},
"context": "../context"
}

View File

@ -5,7 +5,8 @@
"build": {
"dockerfile": "../Dockerfile",
"args": {
"BASE_IMAGE_NAME": "silkeh/clang:13"
"BASE_IMAGE_NAME": "silkeh/clang:13",
"DEBIAN_SNAPSHOT": "none"
},
"context": "../context"
}

View File

@ -5,7 +5,8 @@
"build": {
"dockerfile": "../Dockerfile",
"args": {
"BASE_IMAGE_NAME": "silkeh/clang:14"
"BASE_IMAGE_NAME": "silkeh/clang:14",
"DEBIAN_SNAPSHOT": "none"
},
"context": "../context"
}

View File

@ -5,7 +5,8 @@
"build": {
"dockerfile": "../Dockerfile",
"args": {
"BASE_IMAGE_NAME": "silkeh/clang:15"
"BASE_IMAGE_NAME": "silkeh/clang:15",
"DEBIAN_SNAPSHOT": "none"
},
"context": "../context"
}

View File

@ -5,7 +5,8 @@
"build": {
"dockerfile": "../Dockerfile",
"args": {
"BASE_IMAGE_NAME": "silkeh/clang:16"
"BASE_IMAGE_NAME": "silkeh/clang:16",
"DEBIAN_SNAPSHOT": "none"
},
"context": "../context"
}

View File

@ -5,7 +5,8 @@
"build": {
"dockerfile": "../Dockerfile",
"args": {
"BASE_IMAGE_NAME": "silkeh/clang:17"
"BASE_IMAGE_NAME": "silkeh/clang:17",
"DEBIAN_SNAPSHOT": "none"
},
"context": "../context"
}

View File

@ -5,7 +5,8 @@
"build": {
"dockerfile": "../Dockerfile",
"args": {
"BASE_IMAGE_NAME": "silkeh/clang:18-bullseye"
"BASE_IMAGE_NAME": "silkeh/clang:18-bullseye",
"DEBIAN_SNAPSHOT": "none"
},
"context": "../context"
}

View File

@ -5,7 +5,8 @@
"build": {
"dockerfile": "../Dockerfile",
"args": {
"BASE_IMAGE_NAME": "silkeh/clang:19-bullseye"
"BASE_IMAGE_NAME": "silkeh/clang:19-bullseye",
"DEBIAN_SNAPSHOT": "none"
},
"context": "../context"
}

View File

@ -5,7 +5,8 @@
"build": {
"dockerfile": "../Dockerfile",
"args": {
"BASE_IMAGE_NAME": "silkeh/clang:20-bullseye"
"BASE_IMAGE_NAME": "silkeh/clang:20-bullseye",
"DEBIAN_SNAPSHOT": "none"
},
"context": "../context"
}

View File

@ -0,0 +1,13 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/cpp
{
"name": "Clang 21",
"build": {
"dockerfile": "../Dockerfile",
"args": {
"BASE_IMAGE_NAME": "silkeh/clang:21-bullseye",
"DEBIAN_SNAPSHOT": "none"
},
"context": "../context"
}
}

View File

@ -5,7 +5,8 @@
"build": {
"dockerfile": "../Dockerfile",
"args": {
"BASE_IMAGE_NAME": "silkeh/clang:7"
"BASE_IMAGE_NAME": "silkeh/clang:7",
"DEBIAN_SNAPSHOT": "none"
},
"context": "../context"
}

View File

@ -5,7 +5,8 @@
"build": {
"dockerfile": "../Dockerfile",
"args": {
"BASE_IMAGE_NAME": "silkeh/clang:8"
"BASE_IMAGE_NAME": "silkeh/clang:8",
"DEBIAN_SNAPSHOT": "none"
},
"context": "../context"
}

View File

@ -5,7 +5,8 @@
"build": {
"dockerfile": "../Dockerfile",
"args": {
"BASE_IMAGE_NAME": "silkeh/clang:9"
"BASE_IMAGE_NAME": "silkeh/clang:9",
"DEBIAN_SNAPSHOT": "none"
},
"context": "../context"
}

View File

@ -5,7 +5,8 @@
"build": {
"dockerfile": "./Dockerfile",
"args": {
"BASE_IMAGE_NAME": "mcr.microsoft.com/devcontainers/cpp:debian-12"
"BASE_IMAGE_NAME": "mcr.microsoft.com/devcontainers/cpp:2@sha256:a5eb5a1e9109af88bf82ebb0f71903608a68144851ed1e4b852e31b251ac59c6",
"DEBIAN_SNAPSHOT": "20260223T000000Z"
},
"context": "./context"
}

View File

@ -5,7 +5,8 @@
"build": {
"dockerfile": "../Dockerfile",
"args": {
"BASE_IMAGE_NAME": "gcc:9"
"BASE_IMAGE_NAME": "gcc:9",
"DEBIAN_SNAPSHOT": "none"
},
"context": "../context"
}

View File

@ -5,7 +5,8 @@
"build": {
"dockerfile": "../Dockerfile",
"args": {
"BASE_IMAGE_NAME": "gcc:10"
"BASE_IMAGE_NAME": "gcc:10",
"DEBIAN_SNAPSHOT": "none"
},
"context": "../context"
}

View File

@ -5,7 +5,8 @@
"build": {
"dockerfile": "../Dockerfile",
"args": {
"BASE_IMAGE_NAME": "gcc:11"
"BASE_IMAGE_NAME": "gcc:11",
"DEBIAN_SNAPSHOT": "none"
},
"context": "../context"
}

View File

@ -5,7 +5,8 @@
"build": {
"dockerfile": "../Dockerfile",
"args": {
"BASE_IMAGE_NAME": "gcc:12"
"BASE_IMAGE_NAME": "gcc:12",
"DEBIAN_SNAPSHOT": "none"
},
"context": "../context"
}

View File

@ -5,7 +5,8 @@
"build": {
"dockerfile": "../Dockerfile",
"args": {
"BASE_IMAGE_NAME": "gcc:13"
"BASE_IMAGE_NAME": "gcc:13",
"DEBIAN_SNAPSHOT": "none"
},
"context": "../context"
}

View File

@ -5,7 +5,8 @@
"build": {
"dockerfile": "../Dockerfile",
"args": {
"BASE_IMAGE_NAME": "gcc:14"
"BASE_IMAGE_NAME": "gcc:14",
"DEBIAN_SNAPSHOT": "none"
},
"context": "../context"
}

View File

@ -5,7 +5,8 @@
"build": {
"dockerfile": "../Dockerfile",
"args": {
"BASE_IMAGE_NAME": "gcc:15"
"BASE_IMAGE_NAME": "gcc:15",
"DEBIAN_SNAPSHOT": "none"
},
"context": "../context"
}

View File

@ -0,0 +1,40 @@
# s390x Big-Endian Test Environment for ETL
# Uses QEMU user-mode emulation to run s390x binaries on x64 host
FROM debian:trixie
# Avoid prompts from apt
ENV DEBIAN_FRONTEND=noninteractive
# Install QEMU user-mode emulation and s390x cross-compilation tools
RUN dpkg --add-architecture s390x && \
apt-get update && apt-get install -y --no-install-recommends\
qemu-user-static \
qemu-user \
binfmt-support \
gcc-s390x-linux-gnu \
g++-s390x-linux-gnu \
cmake \
make \
ninja-build \
git \
wget \
file \
libc6:s390x \
libstdc++6:s390x \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /workspaces/etl
# Verify QEMU and cross-compilation setup
RUN echo "=== Host Architecture ===" && \
uname -m && \
echo "" && \
echo "=== s390x Cross Compiler ===" && \
s390x-linux-gnu-gcc --version && \
echo "" && \
echo "=== QEMU s390x ===" && \
qemu-s390x-static --version | head -n1
# Default command
CMD ["/bin/bash"]

View File

@ -0,0 +1,29 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/cpp
{
"name": "s390x Big Endian (Debian)",
"build": {
"dockerfile": "./Dockerfile",
"context": "."
},
"customizations": {
"vscode": {
"extensions": [
"ms-vscode.cpptools",
"ms-vscode.cmake-tools"
],
"settings": {
"cmake.sourceDirectory": "${workspaceFolder}/test",
"cmake.configureArgs": [
"-DCMAKE_TOOLCHAIN_FILE=${workspaceFolder}/.devcontainer/s390x/toolchain-s390x.cmake",
"-DBUILD_TESTS=ON",
"-DNO_STL=OFF",
"-DETL_CXX_STANDARD=17"
],
"cmake.buildDirectory": "${workspaceFolder}/build-s390x",
"cmake.generator": "Ninja"
}
}
},
"remoteUser": "root"
}

View File

@ -0,0 +1,21 @@
# CMake toolchain file for s390x cross-compilation
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR s390x)
# Specify the cross compiler
set(CMAKE_C_COMPILER s390x-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER s390x-linux-gnu-g++)
set(CMAKE_AR s390x-linux-gnu-ar)
set(CMAKE_RANLIB s390x-linux-gnu-ranlib)
set(CMAKE_STRIP s390x-linux-gnu-strip)
# Search for programs in the build host directories
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# For libraries and headers in the target directories
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
# Set QEMU for running tests
set(CMAKE_CROSSCOMPILING_EMULATOR /usr/bin/qemu-s390x-static CACHE FILEPATH "Path to the emulator for cross-compiled binaries")

View File

@ -3,7 +3,8 @@ on:
push:
branches: [ master, development, pull-request/* ]
pull_request:
branches: [ master, pull-request/* ]
branches: [ master, development, pull-request/* ]
types: [opened, synchronize, reopened]
jobs:
@ -27,7 +28,7 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v
build-clang-cpp11-linux-no-stl:
name: Clang C++11 Linux - No STL
@ -49,4 +50,4 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v

View File

@ -3,7 +3,8 @@ on:
push:
branches: [ master, development, pull-request/* ]
pull_request:
branches: [ master, pull-request/* ]
branches: [ master, development, pull-request/* ]
types: [opened, synchronize, reopened]
jobs:
@ -27,7 +28,7 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v
build-clang-cpp14-linux-no-stl:
name: Clang C++14 Linux - No STL
@ -49,4 +50,4 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v

View File

@ -3,7 +3,8 @@ on:
push:
branches: [ master, development, pull-request/* ]
pull_request:
branches: [ master, pull-request/* ]
branches: [ master, development, pull-request/* ]
types: [opened, synchronize, reopened]
jobs:
@ -27,7 +28,7 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v
build-clang-cpp17-linux-no-stl:
name: Clang C++17 Linux - No STL
@ -49,4 +50,4 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v

View File

@ -3,7 +3,8 @@ on:
push:
branches: [ master, development, pull-request/* ]
pull_request:
branches: [ master, pull-request/* ]
branches: [ master, development, pull-request/* ]
types: [opened, synchronize, reopened]
jobs:
@ -34,7 +35,7 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v
build-clang-cpp20-linux-stl-force-cpp03:
name: Clang C++20 Linux - STL - Force C++03
@ -63,7 +64,7 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v
build-clang-cpp20-linux-no-stl-force-cpp03:
name: Clang C++20 Linux - No STL - Force C++03
@ -92,14 +93,14 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v
build-clang-cpp20-osx-stl:
name: Clang C++20 OSX - STL
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-13]
os: [macos-15]
steps:
- uses: actions/checkout@v4
@ -114,14 +115,14 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v
build-clang-cpp20-osx-no-stl:
name: Clang C++20 OSX - No STL
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-13]
os: [macos-15]
steps:
- uses: actions/checkout@v4
@ -136,14 +137,14 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v
build-clang-cpp20-osx-stl-force-cpp03:
name: Clang C++20 OSX - STL - Force C++03
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-13]
os: [macos-15]
steps:
- uses: actions/checkout@v4
@ -158,14 +159,14 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v
build-clang-cpp20-osx-no-stl-force-cpp03:
name: Clang C++20 OSX - No STL - Force C++03
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-13]
os: [macos-15]
steps:
- uses: actions/checkout@v4
@ -180,5 +181,5 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v

View File

@ -3,7 +3,8 @@ on:
push:
branches: [ master, development, pull-request/* ]
pull_request:
branches: [ master, pull-request/* ]
branches: [ master, development, pull-request/* ]
types: [opened, synchronize, reopened]
jobs:
@ -34,7 +35,7 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v
build-clang-cpp23-linux-stl-force-cpp03:
name: Clang C++23 Linux - STL - Force C++03
@ -63,7 +64,7 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v
build-clang-cpp2-linux-no-stl-force-cpp03:
name: Clang C++23 Linux - No STL - Force C++03
@ -92,14 +93,14 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v
build-clang-cpp23-osx-stl:
name: Clang C++23 OSX - STL
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-13]
os: [macos-15]
steps:
- uses: actions/checkout@v4
@ -114,14 +115,14 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v
build-clang-cpp23-osx-no-stl:
name: Clang C++23 OSX - No STL
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-13]
os: [macos-15]
steps:
- uses: actions/checkout@v4
@ -136,14 +137,14 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v
build-clang-cpp23-osx-stl-force-cpp03:
name: Clang C++23 OSX - STL - Force C++03
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-13]
os: [macos-15]
steps:
- uses: actions/checkout@v4
@ -158,14 +159,14 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v
build-clang-cpp23-osx-no-stl-force-cpp03:
name: Clang C++23 OSX - No STL - Force C++03
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-13]
os: [macos-15]
steps:
- uses: actions/checkout@v4
@ -180,5 +181,5 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v

43
.github/workflows/clang-format.yaml vendored Normal file
View File

@ -0,0 +1,43 @@
name: clang-format
on:
push:
branches: [ master, development, pull-request/* ]
pull_request:
branches: [ master, development, pull-request/* ]
types: [opened, synchronize, reopened]
jobs:
clang-format:
name: clang-format
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install clang-format and git
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends git clang-format
clang-format --version
- name: Run clang-format on added/changed files
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
BEFORE="origin/${{ github.base_ref }}"
elif [ "${{ github.event_name }}" = "push" ]; then
BEFORE="${{ github.event.before }}"
else
echo "Unsupported event: ${{ github.event_name }}"
echo "This is likely a bug in the workflow configuration. Please report it to the maintainers."
exit 1
fi
git diff --name-only -z --diff-filter=AMCR "$BEFORE"..HEAD -- \
'*.c' '*.cc' '*.cxx' '*.cpp' \
'*.h' '*.hh' '*.hpp' '*.hxx' \
'*.ipp' '*.inl' \
':(exclude)include/etl/generators/*' \
':(exclude)include/etl/private/*_cpp03.h' \
| xargs -0 --no-run-if-empty clang-format --Werror -n --style=file

View File

@ -0,0 +1,21 @@
name: clang-format-update
on:
workflow_dispatch:
jobs:
clang-format:
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install clang-format
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends clang-format
clang-format --version
- name: Run clang-format
run: |
find . \( -name '*.cpp' -o -name '*.h' -o -name '*.c' \) | xargs clang-format --dry-run --Werror

View File

@ -3,7 +3,8 @@ on:
push:
branches: [ master, development, pull-request/* ]
pull_request:
branches: [ master, pull-request/* ]
branches: [ master, development, pull-request/* ]
types: [opened, synchronize, reopened]
jobs:
build-clang-cpp03-linux-STL:

72
.github/workflows/coverage.yml vendored Normal file
View File

@ -0,0 +1,72 @@
name: coverage
on:
push:
branches: [ master, pull-request/* ]
pull_request:
branches: [ master, pull-request/* ]
types: [opened, synchronize, reopened]
# Allow only one concurrent deployment to GitHub Pages
concurrency:
group: coverage-${{ github.ref }}
cancel-in-progress: true
# Grant GITHUB_TOKEN the minimum permissions needed at the workflow level
permissions:
contents: read
jobs:
coverage:
name: Generate Coverage Report
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y lcov llvm gcc g++ clang cmake
- name: Build, test, and collect coverage
run: |
cd test
./run-coverage.sh
- name: Upload coverage report artifact
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: test/build-coverage/coverage/
retention-days: 30
- name: Upload Pages artifact
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: actions/upload-pages-artifact@v3
with:
path: test/build-coverage/coverage/
deploy-pages:
name: Deploy to GitHub Pages
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs: coverage
runs-on: ubuntu-22.04
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
# GitHub Repository settings
# -> Settings -> Pages
# -> Source: gh actions

View File

@ -3,7 +3,8 @@ on:
push:
branches: [ master, development, pull-request/* ]
pull_request:
branches: [ master, pull-request/* ]
branches: [ master, development, pull-request/* ]
types: [opened, synchronize, reopened]
jobs:
@ -28,7 +29,7 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v
build-gcc-cpp11-linux-no-stl:
name: GCC C++11 Linux - No STL
@ -51,4 +52,4 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v

View File

@ -3,7 +3,8 @@ on:
push:
branches: [ master, development, pull-request/* ]
pull_request:
branches: [ master, pull-request/* ]
branches: [ master, development, pull-request/* ]
types: [opened, synchronize, reopened]
jobs:
@ -27,7 +28,7 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v
build-gcc-cpp14-linux-no-stl:
name: GCC C++14 Linux - No STL
@ -49,4 +50,4 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v

View File

@ -3,7 +3,8 @@ on:
push:
branches: [ master, development, pull-request/* ]
pull_request:
branches: [ master, pull-request/* ]
branches: [ master, development, pull-request/* ]
types: [opened, synchronize, reopened]
jobs:
@ -27,7 +28,7 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v
build-gcc-cpp17-linux-no-stl:
name: GCC C++17 Linux - No STL
@ -49,4 +50,4 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v

View File

@ -3,7 +3,8 @@ on:
push:
branches: [ master, development, pull-request/* ]
pull_request:
branches: [ master, pull-request/* ]
branches: [ master, development, pull-request/* ]
types: [opened, synchronize, reopened]
jobs:
@ -27,7 +28,7 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v
build-gcc-cpp20-linux-no-stl:
name: GCC C++20 Linux - No STL
@ -49,7 +50,7 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v
build-gcc-cpp20-linux-stl-force-cpp03:
name: GCC C++20 Linux - STL - Force C++03
@ -71,7 +72,7 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v
build-gcc-cpp20-linux-no-stl-force-cpp03:
name: GCC C++20 Linux - No STL - Force C++03
@ -93,4 +94,4 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v

View File

@ -3,7 +3,8 @@ on:
push:
branches: [ master, development, pull-request/* ]
pull_request:
branches: [ master, pull-request/* ]
branches: [ master, development, pull-request/* ]
types: [opened, synchronize, reopened]
jobs:
@ -27,7 +28,7 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v
build-gcc-cpp23-linux-no-stl:
name: GCC C++23 Linux - No STL
@ -49,7 +50,7 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v
build-gcc-cpp23-linux-stl-force-cpp03:
name: GCC C++23 Linux - STL - Force C++03
@ -71,7 +72,7 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v
build-gcc-cpp23-linux-no-stl-force-cpp03:
name: GCC C++23 Linux - No STL - Force C++03
@ -93,4 +94,4 @@ jobs:
make -j $(getconf _NPROCESSORS_ONLN)
- name: Run tests
run: ./test/etl_tests
run: ./test/etl_tests -v

View File

@ -3,7 +3,8 @@ on:
push:
branches: [ master, development, pull-request/* ]
pull_request:
branches: [ master, pull-request/* ]
branches: [ master, development, pull-request/* ]
types: [opened, synchronize, reopened]
jobs:
build-gcc-cpp03-linux-STL:

25
.github/workflows/generator.yml vendored Normal file
View File

@ -0,0 +1,25 @@
name: generator checks
on:
push:
branches: [ master, development, pull-request/* ]
pull_request:
branches: [ master, pull-request/* ]
types: [opened, synchronize, reopened]
jobs:
generator-run:
name: Header Generator
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Generate
run: |
sudo apt-get update
sudo apt-get install -y python3-cogapp
cd include/etl/generators && bash generate.bat
- name: Check Generated Headers For Changes
run: |
git diff --exit-code

View File

@ -3,7 +3,8 @@ on:
push:
branches: [ master, development, pull-request/* ]
pull_request:
branches: [ master, pull-request/* ]
branches: [ master, development, pull-request/* ]
types: [opened, synchronize, reopened]
jobs:
build-windows-msvc-stl:
@ -21,12 +22,12 @@ jobs:
- name: Build
run: |
cmake -G "Visual Studio 17 2022" -AWin32 -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=20 ./
cmake -G "Visual Studio 17 2022" -AWin32 -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=17 ./
MSBuild.exe -version
MSBuild.exe .\etl.sln
- name: Run tests
run: test/Debug/etl_tests.exe
run: test/Debug/etl_tests.exe -v
build-windows-msvc-no-stl:
name: Windows - No STL
@ -47,7 +48,7 @@ jobs:
MSBuild.exe .\etl.sln
- name: Run tests
run: test/Debug/etl_tests.exe
run: test/Debug/etl_tests.exe -v
build-windows-msvc-stl-force-cpp03:
name: Windows - STL - Force C++03
@ -69,7 +70,7 @@ jobs:
MSBuild.exe .\etl.sln
- name: Run tests
run: test/Debug/etl_tests.exe
run: test/Debug/etl_tests.exe -v
build-windows-msvc-no-stl-force-cpp03:
name: Windows - No STL - Force C++03
@ -91,5 +92,5 @@ jobs:
MSBuild.exe .\etl.sln
- name: Run tests
run: test/Debug/etl_tests.exe
run: test/Debug/etl_tests.exe -v

26
.github/workflows/platformio-update.yml vendored Normal file
View File

@ -0,0 +1,26 @@
name: Publish ETL to PlatformIO
on:
release:
types: [published] # Trigger only when a GitHub release is published
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install PlatformIO
run: pip install platformio
- name: Publish to PlatformIO Registry
run: pio package publish --owner etlcpp --non-interactive
env:
PLATFORMIO_AUTH_TOKEN: ${{ secrets.PLATFORMIO_TOKEN }}

16
.gitignore vendored
View File

@ -3,6 +3,8 @@
## Personal
#################
docs/html
hugo/public
hugo/.hugo_build.lock
include/etl/html/
include/etl/latex/
test/vs2013/Debug
@ -403,3 +405,17 @@ test/syntax_check/bgcc
test/vs2022/Debug MSVC C++23
test/vs2022/Debug MSVC C++23 - No STL
.vs
examples/UniquePtrWithPool/CMakeFiles
examples/UniquePtrWithPool/cmake_install.cmake
examples/UniquePtrWithPool/Makefile
examples/UniquePtrWithPool/CMakeCache.txt
examples/UniquePtrWithPool/UniquePtrWithPool
test/vs2022/Debug Clang C++20 - Optimised -O2
include/etl/header_file_list.txt
temp
test/syntax_check/build-make
hugo/public
hugo/resources
hugo/.hugo_build.lock
docs/*.html
test/build-coverage

45
.treefmt.toml Normal file
View File

@ -0,0 +1,45 @@
[global]
excludes = [
"**/Doxyfile",
"**/Makefile",
"*.*-format",
"*.S",
"*.cmm",
"*.css",
"*.dld",
"*.gdb",
"*.gif",
"*.gitignore",
"*.html",
"*.ini",
"*.josh",
"*.json",
"*.md",
"*.png",
"*.puml",
"*.py",
"*.rb",
"*.rst",
"*.s",
"*.sh",
"*.spec",
"*.toml",
"*.txt",
"*.yaml",
"*.yml",
"docker/**",
"temp/**",
"scripts/clang-format-wrapper",
"include/etl/generators/**",
"include/etl/private/*_cpp03.h",
"subprojects/**",
"test/UnitTest++/**",
"test/Deprecated/**",
"test/Performance/**",
"test/temp/**"
]
[formatter.cpp]
command = "scripts/clang-format-wrapper"
options = [ "-i", "--style=file" ]
includes = [ "*.c", "*.cc", "*.cpp", "*.h", "*.hh", "*.hpp" ]

View File

@ -1,13 +1,17 @@
# How to contribute
If your are considering creating a pull request, please observe the following:
Thanks for considering a contribution! Heres what you need to know before opening a pull request:
- If you are adding or modifying a feature, add *new* unit tests that test that feature.
- If you are fixing a bug, add a unit test that *fails* before the bug fix is implemented.
- Do not initiate a pull request until all of the units tests pass.
- Branches should be based on the branch `master`.
- Do not initiate a pull request until all of the units tests pass. See below for information on project files and test scripts.
- Branches should be based on the branch `master`. If `development` has pending updates, Ill rebase the PR against it before pulling..
- For formatting help, you can use clang-format, or the convenience wrapper treefmt. See also [docs/source-formatting.md](docs/source-formatting.md)
There is a project file for VS2022 for C++14, 17, 20, and bash scripts that run the tests for C++11, 14, 17, 20 under Linux with GCC and Clang.
There is a project file for VS2022 for C++14, 17, 20, 23, and bash scripts that run the tests for C++11, 14, 17, 20, 23 under Linux with GCC and Clang.
There are syntax-only check bash scripts that cover C++03, 11, 14, 17, 20, 23 under Linux with GCC and Clang.
If you are thinking of adding a new feature then raise this on the GitHub Issues page for discussion as the maintainers and user of the ETL may have questions or suggestions.
It is possible that the maintainer of the ETL or another contributor is already working on the same or a related feature.
It is possible that the maintainer of the ETL or another contributor is already working on the same or a related feature.
Take a look through our current issues and see if anything sparks your interest!

View File

@ -0,0 +1,12 @@
How to convert the ETL header beween #include guards and #pragma once.
Install
python3 -m pip install guardonce
Navigate to etl/scripts
Change from #include guard to #pragma once
./convert_headers_to_use_once.bat
Change from #pragma once to #include guard
./convert_headers_to_use_guards.bat

192
README.md
View File

@ -1,16 +1,14 @@
Embedded Template Library (ETL)
-------------------------
# ![alt text](https://github.com/ETLCPP/etl/blob/master/images/etl64.png?raw=true) Embedded Template Library (ETL)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/jwellbelove/etl)
[![Release date](https://img.shields.io/github/release-date/jwellbelove/etl?color=%231182c3)](https://img.shields.io/github/release-date/jwellbelove/etl?color=%231182c3)
[![Standard](https://img.shields.io/badge/c%2B%2B-98/03/11/14/17/20-blue.svg)](https://en.wikipedia.org/wiki/C%2B%2B#Standardization)
[![Standard](https://img.shields.io/badge/c%2B%2B-98/03/11/14/17/20/23-blue.svg)](https://en.wikipedia.org/wiki/C%2B%2B#Standardization)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
![GitHub contributors](https://img.shields.io/github/contributors-anon/ETLCPP/etl)
![GitHub forks](https://img.shields.io/github/forks/ETLCPP/etl?style=flat)
![GitHub Repo stars](https://img.shields.io/github/stars/ETLCPP/etl?style=flat)
![CI](https://github.com/ETLCPP/etl/workflows/msvc/badge.svg?branch=master)
[![Build status](https://ci.appveyor.com/api/projects/status/b7jgecv7unqjw4u0/branch/master?svg=true)](https://ci.appveyor.com/project/jwellbelove/etl/branch/master)
![CI](https://github.com/ETLCPP/etl/actions/workflows/msvc.yml/badge.svg?branch=master)
![CI](https://github.com/ETLCPP/etl/actions/workflows/gcc-c++11.yml/badge.svg?branch=master)
![CI](https://github.com/ETLCPP/etl/actions/workflows/gcc-c++14.yml/badge.svg?branch=master)
@ -34,47 +32,87 @@ Embedded Template Library (ETL)
## Motivation
C++ is a great language to use for embedded applications and templates are a powerful aspect. The standard library can offer a great deal of well tested functionality, but there are some parts of the standard library that do not fit well with deterministic behaviour and limited resource requirements. These limitations usually preclude the use of dynamically allocated memory and containers with open ended sizes.
C++ is a powerful language for embedded systems development, with templates offering a great deal of flexibility and type safety. While the C++ Standard Library provides a wealth of well-tested functionality, its often not well suited to environments with strict deterministic behavior and limited resources.
What is needed is a template library where the user can declare the size, or maximum size of any object upfront. Most embedded compilers do not currently support the standard beyond C++ 03, therefore excluding the programmer from using the enhanced features of the later library.
In many embedded applications, dynamic memory allocation is discouraged or outright prohibited, making standard STL containers and many other components impractical or unusable.
This is what the ETL attempts to achieve.
Whats needed is a template library specifically designed for embedded systems — one that allows developers to define fixed or maximum sizes for containers and other objects at compile time. Additionally, since many embedded toolchains still lack full support for standards beyond C++03, it's valuable to have access to a library that backports select features from later versions of the C++ Standard Library.
## Summary
## About the ETL
The ETL is not designed to completely replace the STL, but complement it.
Its design objective covers three areas.
The Embedded Template Library (ETL) is not intended as a full replacement for the C++ Standard Template Library (STL), but rather as a complementary solution tailored specifically for embedded systems.
- Create a set of containers where the size or maximum size is determined at compile time. These containers are direct equivalents of those supplied in the STL.
- Be compatible with C++ 03 but implement as many of the C++ 11/14/17/20/23 additions as possible.
- Add other useful components that are not present in the standard library.
Its design goals include:
The embedded template library has been designed for lower resource embedded applications.
It contains a set of containers, algorithms and utilities, some of which emulate parts of the STL.
There is no dynamic memory allocation. The library makes no use of the heap. All of the containers have a fixed capacity allowing all memory allocation to be determined at compile time.
The library is intended for any compiler that supports C++98/03/11/14/17/20/23.
- Providing a set of containers with fixed or maximum sizes defined at compile-time.
## Main features
- Offering APIs that closely resemble those of the STL, enabling familiar and consistent usage.
- Cross platform. This library is not specific to any processor type.
- No dynamic memory allocation
- No RTTI required
- Very little use of virtual functions. They are used only when they are absolutely necessary for the required functionality
- A set of fixed capacity containers. (array, bitset, deque, forward_list, list, queue, stack, vector, map, set, etc.)
- As the storage for all of the container types is allocated as a contiguous block, they are extremely cache friendly
- Templated compile time constants
- Templated design pattern base classes (Visitor, Observer)
- Reverse engineered C++ 0x11 features (type traits, algorithms, containers etc.)
- Type-safe enumerations
- Type-safe typedefs
- 8, 16, 32 & 64 bit CRC calculations
- Checksums & hash functions
- Variants (a type that can store many types in a type-safe interface)
- Choice of asserts, exceptions, error handler or no checks on errors
- Unit tested (currently over 9400 tests), using VS2022, GCC 12, Clang 14.
- Many utilities for template support.
- Easy to read and documented source.
- Free support via email, GitHub and Slack
- Maintaining compatibility with C++98 while implementing many features introduced in later standards
(C++11/14/17/20/23) where possible.
- Ensuring deterministic behavior, which is critical in real-time and resource-constrained environments.
- Introducing additional components and utilities useful in embedded contexts but absent from the STL.
The ETL avoids dynamic memory allocation entirely; the heap is never used. All non-intrusive containers have a fixed capacity, allowing memory requirements to be fully determined at compile-time. This makes the ETL ideal for lower-resource embedded applications where predictability, performance, and memory control are essential.
The library is compatible with any compiler that supports C++03 or later.
Help on integrating the ETL with your project may be found here.
## Key features of the ETL
- Actively Maintained: Developed and maintained on GitHub since 2014.
- Open Source: MIT licensed.
- No STL Dependency: Designed to operate independently of the C++ Standard Template Library.
- No Dynamic Memory Allocation: All storage is allocated either at compile-time or on the stack; heap usage is entirely avoided.
- RTTI and Virtual Functions: No runtime type information (RTTI) is required. Virtual functions are used sparingly and only when strictly necessary.
- Header-Only Library: All functionality is provided via header files; No separate compilation needed.
- Fixed-Capacity Containers: Offers STL-like containers with fixed or maximum capacity, plus additional non-standard container types.
- Cache Efficiency: Containers use contiguous memory layouts for optimal cache performance.
- Compact Codebase: Shared base classes (based on type) help reduce overall container code size.
- Compile-Time Features:
- Templated compile-time constants
- Template-based design pattern base classes (e.g., Visitor, Observer)
- Type-safe smart enumerations
- Type-safe typedefs and constants
- Embedded System Frameworks:
- Message routing
- Finite state machines
- Task scheduling
- C++11 Backports: Implements many C++11 features (type traits, algorithms, containers) for use in C++03 environments.
- Utilities:
- CRC calculations (8, 16, 32 & 64-bit)
- Checksums and hash functions
- Variants (type-safe unions)
- Extensive template support utilities
- Robust Error Handling: Configurable error checking using asserts, exceptions, error handlers, or no checks; users choice.
- Thoroughly Tested:
- Over 10,000 unit tests
- Tested with Visual Studio 2022, GCC 12, and Clang 14
- Continuous integration via GitHub Actions.
- Readable and Well-Documented: Clean, maintainable source code with clear documentation.
- Support: Free email support available. A Slack group is available. Paid support on request.
- Archived: A snapshot of the ETL is preserved in the Arctic Code Vault for long-term digital preservation.
Any help porting the library to work under different platforms and compilers would be gratefully received.
I am especially interested in people who are using Keil, IAR, Green Hills, TI Code Composer etc, bare metal or RTOS, and DSPs.
@ -144,6 +182,84 @@ add_executable(foo main.cpp)
target_link_libraries(foo PRIVATE etl::etl)
```
## Profile definition
When using ETL in a project, there is typically an `etl_profile.h` defined to
adjust ETL to the project needs. ETL will automatically find `etl_profile.h`
if it is available in the include path(s). If it's not available, ETL will
work with default values.
### Example
```
#ifndef __ETL_PROFILE_H__
#define __ETL_PROFILE_H__
#define ETL_TARGET_DEVICE_GENERIC
#define ETL_TARGET_OS_NONE
#define ETL_NO_STL
#endif
```
## Platform specific implementation
Although ETL is generally a self-contained header-only library, some interfaces need to be
implemented in every project or platform, at least if those interfaces are actually being
used, due to project specifics:
| ETL header | Platform specific API to be implemented | Needed when using |
|------------|-----------------------------------------|-------------------------------------|
| `chrono.h` | `etl_get_high_resolution_clock()` | `etl::high_resolution_clock::now()` |
| | `etl_get_system_clock()` | `etl::system_clock::now()` |
| | `etl_get_steady_clock()` | `etl::steady_clock::now()` |
| `print.h` | `etl_putchar()` | `etl::print()` |
| | | `etl::println()` |
### Example
```
#include <etl/chrono.h>
#include <etl/print.h>
extern "C"
{
etl::chrono::high_resolution_clock::rep etl_get_high_resolution_clock()
{
return etl::chrono::high_resolution_clock::rep(static_cast<int64_t>(getSystemTimeNs()));
}
etl::chrono::system_clock::rep etl_get_system_clock()
{
return etl::chrono::system_clock::rep(static_cast<int64_t>(getSystemTimeNs()));
}
etl::chrono::system_clock::rep etl_get_steady_clock()
{
return etl::chrono::system_clock::rep(static_cast<int64_t>(getSystemTimeNs()));
}
void etl_putchar(int c)
{
putByteToStdout(static_cast<uint8_t>(c));
}
}
```
The following default values apply if the respective macros are not defined
(e.g. in `etl_profile.h`):
| Macro | Default |
|-----------------------------------------------|----------------------------|
| `ETL_CHRONO_SYSTEM_CLOCK_DURATION` | `etl::chrono::nanoseconds` |
| `ETL_CHRONO_SYSTEM_CLOCK_IS_STEADY` | `true` |
| `ETL_CHRONO_HIGH_RESOLUTION_CLOCK_DURATION` | `etl::chrono::nanoseconds` |
| `ETL_CHRONO_HIGH_RESOLUTION_CLOCK_IS_STEADY` | `true` |
| `ETL_CHRONO_STEADY_CLOCK_DURATION` | `etl::chrono::nanoseconds` |
## Arduino library
The content of this repo is available as a library in the Arduino IDE (search for the "Embedded Template Library" in the IDE library manager). The Arduino library repository is available at ```https://github.com/ETLCPP/etl-arduino```, see there for more details.

View File

@ -2,79 +2,79 @@
#ifndef ETL_EMBEDDED_TEMPLATE_LIBRARY_INCLUDED
#define ETL_EMBEDDED_TEMPLATE_LIBRARY_INCLUDED
#if defined(TEENSYDUINO)
#if defined(TEENSYDUINO)
#if defined(__AVR_ATmega32U4__)
#define ARDUINO_BOARD "Teensy 2.0"
#elif defined(__AVR_AT90USB1286__)
#define ARDUINO_BOARD "Teensy++ 2.0"
#elif defined(__MK20DX128__)
#define ARDUINO_BOARD "Teensy 3.0"
#elif defined(__MK20DX256__)
#define ARDUINO_BOARD "Teensy 3.2" // and Teensy 3.1
#elif defined(__MKL26Z64__)
#define ARDUINO_BOARD "Teensy LC"
#elif defined(__MK64FX512__)
#define ARDUINO_BOARD "Teensy 3.5"
#elif defined(__MK66FX1M0__)
#define ARDUINO_BOARD "Teensy 3.6"
#else
#define ARDUINO_BOARD "Unknown"
#endif
#if defined(__AVR_ATmega32U4__)
#define ARDUINO_BOARD "Teensy 2.0"
#elif defined(__AVR_AT90USB1286__)
#define ARDUINO_BOARD "Teensy++ 2.0"
#elif defined(__MK20DX128__)
#define ARDUINO_BOARD "Teensy 3.0"
#elif defined(__MK20DX256__)
#define ARDUINO_BOARD "Teensy 3.2" // and Teensy 3.1
#elif defined(__MKL26Z64__)
#define ARDUINO_BOARD "Teensy LC"
#elif defined(__MK64FX512__)
#define ARDUINO_BOARD "Teensy 3.5"
#elif defined(__MK66FX1M0__)
#define ARDUINO_BOARD "Teensy 3.6"
#else
#define ARDUINO_BOARD "Unknown"
#endif
#else // --------------- Arduino ------------------
#if defined(ARDUINO_AVR_ADK)
#define ARDUINO_BOARD "Mega Adk"
#elif defined(ARDUINO_AVR_BT)
#define ARDUINO_BOARD "Bt"
#elif defined(ARDUINO_AVR_DUEMILANOVE)
#define ARDUINO_BOARD "Duemilanove"
#elif defined(ARDUINO_AVR_ESPLORA)
#define ARDUINO_BOARD "Esplora"
#elif defined(ARDUINO_AVR_ETHERNET)
#define ARDUINO_BOARD "Ethernet"
#elif defined(ARDUINO_AVR_FIO)
#define ARDUINO_BOARD "Fio"
#elif defined(ARDUINO_AVR_GEMMA)
#define ARDUINO_BOARD "Gemma"
#elif defined(ARDUINO_AVR_LEONARDO)
#define ARDUINO_BOARD "Leonardo"
#elif defined(ARDUINO_AVR_LILYPAD)
#define ARDUINO_BOARD "Lilypad"
#elif defined(ARDUINO_AVR_LILYPAD_USB)
#define ARDUINO_BOARD "Lilypad Usb"
#elif defined(ARDUINO_AVR_MEGA)
#define ARDUINO_BOARD "Mega"
#elif defined(ARDUINO_AVR_MEGA2560)
#define ARDUINO_BOARD "Mega 2560"
#elif defined(ARDUINO_AVR_MICRO)
#define ARDUINO_BOARD "Micro"
#elif defined(ARDUINO_AVR_MINI)
#define ARDUINO_BOARD "Mini"
#elif defined(ARDUINO_AVR_NANO)
#define ARDUINO_BOARD "Nano"
#elif defined(ARDUINO_AVR_NG)
#define ARDUINO_BOARD "NG"
#elif defined(ARDUINO_AVR_PRO)
#define ARDUINO_BOARD "Pro"
#elif defined(ARDUINO_AVR_ROBOT_CONTROL)
#define ARDUINO_BOARD "Robot Ctrl"
#elif defined(ARDUINO_AVR_ROBOT_MOTOR)
#define ARDUINO_BOARD "Robot Motor"
#elif defined(ARDUINO_AVR_UNO)
#define ARDUINO_BOARD "Uno"
#elif defined(ARDUINO_AVR_YUN)
#define ARDUINO_BOARD "Yun"
#elif defined(ARDUINO_SAM_DUE)
#define ARDUINO_BOARD "Due"
#elif defined(ARDUINO_SAMD_ZERO)
#define ARDUINO_BOARD "Zero"
#elif defined(ARDUINO_ARC32_TOOLS)
#define ARDUINO_BOARD "101"
#else
#define ARDUINO_BOARD "Unknown"
#endif
#if defined(ARDUINO_AVR_ADK)
#define ARDUINO_BOARD "Mega Adk"
#elif defined(ARDUINO_AVR_BT)
#define ARDUINO_BOARD "Bt"
#elif defined(ARDUINO_AVR_DUEMILANOVE)
#define ARDUINO_BOARD "Duemilanove"
#elif defined(ARDUINO_AVR_ESPLORA)
#define ARDUINO_BOARD "Esplora"
#elif defined(ARDUINO_AVR_ETHERNET)
#define ARDUINO_BOARD "Ethernet"
#elif defined(ARDUINO_AVR_FIO)
#define ARDUINO_BOARD "Fio"
#elif defined(ARDUINO_AVR_GEMMA)
#define ARDUINO_BOARD "Gemma"
#elif defined(ARDUINO_AVR_LEONARDO)
#define ARDUINO_BOARD "Leonardo"
#elif defined(ARDUINO_AVR_LILYPAD)
#define ARDUINO_BOARD "Lilypad"
#elif defined(ARDUINO_AVR_LILYPAD_USB)
#define ARDUINO_BOARD "Lilypad Usb"
#elif defined(ARDUINO_AVR_MEGA)
#define ARDUINO_BOARD "Mega"
#elif defined(ARDUINO_AVR_MEGA2560)
#define ARDUINO_BOARD "Mega 2560"
#elif defined(ARDUINO_AVR_MICRO)
#define ARDUINO_BOARD "Micro"
#elif defined(ARDUINO_AVR_MINI)
#define ARDUINO_BOARD "Mini"
#elif defined(ARDUINO_AVR_NANO)
#define ARDUINO_BOARD "Nano"
#elif defined(ARDUINO_AVR_NG)
#define ARDUINO_BOARD "NG"
#elif defined(ARDUINO_AVR_PRO)
#define ARDUINO_BOARD "Pro"
#elif defined(ARDUINO_AVR_ROBOT_CONTROL)
#define ARDUINO_BOARD "Robot Ctrl"
#elif defined(ARDUINO_AVR_ROBOT_MOTOR)
#define ARDUINO_BOARD "Robot Motor"
#elif defined(ARDUINO_AVR_UNO)
#define ARDUINO_BOARD "Uno"
#elif defined(ARDUINO_AVR_YUN)
#define ARDUINO_BOARD "Yun"
#elif defined(ARDUINO_SAM_DUE)
#define ARDUINO_BOARD "Due"
#elif defined(ARDUINO_SAMD_ZERO)
#define ARDUINO_BOARD "Zero"
#elif defined(ARDUINO_ARC32_TOOLS)
#define ARDUINO_BOARD "101"
#else
#define ARDUINO_BOARD "Unknown"
#endif
#endif
#endif

View File

@ -1,6 +1,6 @@
{
"name": "Embedded Template Library ETL",
"version": "20.42.0",
"version": "20.47.1",
"authors": {
"name": "John Wellbelove",
"email": "john.wellbelove@etlcpp.com"

View File

@ -1,5 +1,5 @@
name=Embedded Template Library ETL
version=20.42.0
version=20.47.1
author= John Wellbelove <john.wellbelove@etlcpp.com>
maintainer=John Wellbelove <john.wellbelove@etlcpp.com>
license=MIT

6
docs/_config.yml Normal file
View File

@ -0,0 +1,6 @@
plugins:
- jekyll-relative-links
relative_links:
enabled: true
include:
- manchester.md

7
docs/index.md Normal file
View File

@ -0,0 +1,7 @@
---
title: ETL documentation
---
## Pages
* [Manchester](manchester.md)

259
docs/manchester.md Normal file
View File

@ -0,0 +1,259 @@
---
title: Manchester encoding and decoding
---
Efficient Manchester encoding and decoding of data. The Manchester code represents a data bit as a sequence of a 'high' and a 'low' value. In software this translates to a conversion from one to two bits, or in a practical situation, from `n` bytes to `n*2` bytes.
## See also
[Manchester code](https://en.wikipedia.org/wiki/Manchester_code)
## Features
- Normal and inverted Manchester encoding
- Support for multiple encoding chunk sizes: 8-bit, 16-bit and 32-bit
- Span-based operations or chunk-based operations
- Constexpr functions for compile-time encoding/decoding
- Validation of encoded data
- Chunked span I/O uses little-endian byte order for multi-byte chunks, independent of host platform endianness
## Algorithm background
To encode the value `0b11001100` we must first duplicate all bits to create the value `0b1111000011110000`. We then perform an XOR of this value with the constant `0b1010101010101010` (`0xAAAA`) to obtain the Manchester coded value of `0b1010010110100101`. We have now replaced each `1` bit with the sequence `10` and each `0` bit with the sequence `01`.
### 2. Bit duplication
Bit duplication is achieved with the following steps. This is also called binary interleaving. The example shows encoding of an 8-bit value.
| Step | High Byte | Low Byte | Operation |
|------|--------------------|--------------------|----------------------------|
| 0 | `_ _ _ _ _ _ _ _` | `A B C D E F G H` | input value (i) |
| 1 | `_ _ _ _ A B C D` | `_ _ _ _ E F G H` | `(i \| (i << 4)) & 0x0F0F` |
| 2 | `_ _ A B _ _ C D` | `_ _ E F _ _ G H` | `(i \| (i << 2)) & 0x3333` |
| 3 | `_ A _ B _ C _ D` | `_ E _ F _ G _ H` | `(i \| (i << 1)) & 0x5555` |
| 4 | `A A B B C C D D` | `E E F F G G H H` | `(i \| (i << 1))` |
This process can be easily extended to 16-bit or 32-bit values by adding additional steps to the bit duplication.
### 3. Manchester Decoding
Manchester decoding is done in a similar, but reversed way.
### 4. Error Detection
Error detection in Manchester coded data is done by comparing 2 neighboring bits. If they are
equal, then there is an error in the encoded input data.
Comparing all 8 bit pairs in a 16-bit word is done as follows.
| Step | Binary Value | Operation | Description |
|------|--------------|-------------------|-----------------------------------------------------------------------------------------------|
| 1 | `11011000` | Original | First bit pair (lsb, 00) is invalid. Last bit pair is also invalid. Other bit pairs are valid |
| 2 | `01101100` | Shift right by 1 | Shift the original value right by one bit |
| 3 | `10110100` | XOR | XOR the original with the shifted value |
| 4 | `01010101` | Mask with 0x55 | Apply mask to isolate bit pairs |
| 5 | `00010100` | Result | If result is not equal to 0x55, there was an error in the input |
## Analysis
Most traditional ways to Manchester encode data consist of a loop over all bits and a nested if-statement to check the value of the current bit. This approach does not scale well to increasing number of bits. The algorithm implemented here contains no conditional code and scales well. Doubling the number of processed bits per step (the chunk size) adds a single row to the bit duplication table. Because of the lack of loops and conditional code, this algorithm is likely to perform better than traditional ones on simple processors or when compiler optimization is disabled. On modern, powerful processors with caches and advanced optimization possibilities this algorithm may not show much benefit. In any case, the performance of the algorithm depends heavily on the processor type, compiler and compiler (optimization) settings.
## API Reference
### Classes
Classes `etl::manchester` and `etl::manchester_inverted` contain static functions for encoding, decoding and validity checking. It is not necessary to instantiate objects of these classes.
#### etl::manchester
```cpp
typedef manchester_base<private_manchester::manchester_type_normal> manchester;
```
Manchester encoder using normal encoding (no inversion).
#### etl::manchester_inverted
```cpp
typedef manchester_base<private_manchester::manchester_type_inverted> manchester_inverted;
```
Manchester encoder using inverted encoding.
### Encoding Functions
#### Encode single value
```cpp
template <typename TDecoded>
static ETL_CONSTEXPR14 typename encoded<TDecoded>::type encode(TDecoded decoded)
```
Encodes a single value using Manchester encoding.
**Parameters:**
- `decoded`: The value to encode (`uint8_t`, `uint16_t`, or `uint32_t`)
**Returns:**
- The Manchester encoded value (twice the bit width of input)
**Example:**
```cpp
uint16_t encoded = etl::manchester::encode(0x55);
```
#### Encode range
```cpp
template <typename TChunk = uint_least8_t>
static ETL_CONSTEXPR14 void encode(etl::span<const uint_least8_t> decoded,
etl::span<uint_least8_t> encoded)
```
Encodes a span of data using the specified chunk size.
**Parameters:**
- `decoded`: Source data to encode
- `encoded`: Destination for encoded data (must be twice the size of `decoded`)
**Template Parameters:**
- `TChunk`: Chunk size for encoding (`uint8_t`, `uint16_t` or `uint32_t`)
**Example:**
```cpp
std::array<uint8_t, 4> data = {0x12, 0x34, 0x56, 0x78};
std::array<uint8_t, 8> encoded_data1{};
std::array<uint8_t, 8> encoded_data2{};
// Encode with TChunk == uint8_t
etl::manchester::encode(data, encoded_data1);
// Encode with TChunk == uint32_t
etl::manchester::encode<uint32_t>(data, encoded_data2);
```
### Decoding Functions
#### Decode single value
```cpp
template <typename TEncoded>
static ETL_CONSTEXPR14 typename decoded<TEncoded>::type decode(TEncoded encoded)
```
Decodes a single Manchester encoded value.
**Parameters:**
- `encoded`: The encoded value to decode (`uint16_t`, `uint32_t`, or `uint64_t`)
**Returns:**
- The Manchester decoded value (half the bit width of input)
**Example:**
```cpp
uint8_t decoded = etl::manchester::decode(0x5A5A);
```
#### Decode range
```cpp
template <typename TChunk = typename private_manchester::encoded<uint_least8_t>::type>
static ETL_CONSTEXPR14 void decode(etl::span<const uint_least8_t> encoded,
etl::span<uint_least8_t> decoded)
```
Decodes a span of Manchester encoded data.
**Parameters:**
- `encoded`: Source data to decode
- `decoded`: Destination for decoded data (must be half the size of `encoded`)
**Template Parameters:**
- `TChunk`: Chunk type for decoding (`uint16_t`, `uint32_t`, or `uint64_t`)
**Example:**
```cpp
std::array<uint8_t, 8> encoded = {/* ... */};
std::array<uint8_t, 4> decoded1 {};
std::array<uint8_t, 4> decoded2 {};
// Decode with TChunk == uint16_t
etl::manchester::decode(encoded, decoded1);
// Decode with TChunk == uint64_t
etl::manchester::decode<uint64_t>(encoded, decoded2);
```
### Validation Functions
#### Single value
```cpp
template <typename TChunk>
static ETL_CONSTEXPR14 bool is_valid(TChunk encoded)
```
Validates that a single value contains valid Manchester encoded data.
**Parameters:**
- `encoded`: The encoded value to validate
**Returns:**
- `true` if the value contains valid Manchester encoded data, `false` otherwise
**Example:**
```cpp
bool valid = etl::manchester::is_valid(0x5A5A);
```
#### Range
```cpp
static ETL_CONSTEXPR14 bool is_valid(etl::span<const uint_least8_t> encoded)
```
Validates that a range contains valid Manchester encoded data.
**Parameters:**
- `encoded`: The range of encoded data to validate
**Returns:**
- `true` if all data is valid Manchester encoding, `false` otherwise
**Example:**
```cpp
std::array<uint8_t, 8> encoded_data = {/* ... */};
bool valid = etl::manchester::is_valid(encoded_data);
```
## Supported Types
### Input/chunk types for encoding
- `uint8_t``uint16_t` (if 8-bit types are supported)
- `uint16_t``uint32_t`
- `uint32_t``uint64_t` (if 64-bit types are supported)
### Input/chunk types for decoding
- `uint16_t``uint8_t` (if 8-bit types are supported)
- `uint32_t``uint16_t`
- `uint64_t``uint32_t` (if 64-bit types are supported)

328
docs/ranges.md Normal file
View File

@ -0,0 +1,328 @@
# ETL C++17 Ranges Implementation
## Overview
The Embedded Template Library provides a C++17-compatible implementation of ranges, inspired by the C++20 ranges library. This implementation enables range-based algorithms and views for embedded and resource-constrained environments where full C++20 support may not be available.
## Features
- **Ranges**: Provides range types and iterator wrappers for composing operations over sequences.
- **Views**: Includes lightweight, composable views such as `filter_view`, `transform_view`, and `subrange`.
- **Algorithms**: Supports range-based algorithms compatible with ETL containers and standard containers.
- **Compatibility**: Designed for C++17, with minimal dependencies and no reliance on C++20 features.
## Getting Started
Include the main header in your project:
```cpp
#include <etl/ranges.h>
```
### Example Usage
#### Using Ranges
```cpp
#include <etl/print.h>
#include <etl/ranges.h>
#include <etl/vector.h>
...
etl::vector<int, 10> data = {6, 1, 3, 3, 2};
etl::ranges::sort(data);
etl::ranges::for_each(data, [](const int& i){etl::print(" {}", i);});
```
Output:
```text
1 2 3 3 6
```
#### Using Views
```cpp
#include <etl/print.h>
#include <etl/ranges.h>
#include <etl/vector.h>
...
etl::vector<int, 10> data = {1, 2, 3, 4, 5};
auto even = [](int v) { return v % 2 == 0; };
auto filtered = etl::ranges::filter_view(data, even);
etl::ranges::for_each(filtered, [](const int& i){etl::print(" {}", i);});
```
Output:
```text
2 4
```
#### Transforming Elements
```cpp
#include <etl/print.h>
#include <etl/ranges.h>
#include <etl/vector.h>
...
etl::vector<int, 10> data = {1, 2, 3, 4, 5};
auto squared = etl::ranges::transform_view(data, [](int v) { return v * v; });
etl::ranges::for_each(squared, [](const int& i){etl::print(" {}", i);});
```
Output:
```text
1 4 9 16 25
```
#### Composition
Views can be composed using the pipe (`|`) operator, allowing you to chain multiple transformations in a readable, left-to-right style:
```cpp
#include <etl/print.h>
#include <etl/ranges.h>
#include <etl/vector.h>
namespace views = etl::ranges::views;
...
etl::vector<int, 10> data = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
auto result = data
| views::filter([](const int& v) { return v % 2 == 0; })
| views::transform([](const int& v) { return v * v; });
etl::ranges::for_each(result, [](const int& i){ etl::print(" {}", i); });
```
Output:
```text
4 16 36 64 100
```
This first filters the even numbers and then squares them. Each `|` passes the result of the previous stage as input to the next view adaptor.
## Supported Views
All views are in the `etl::ranges` namespace. Corresponding range adaptor objects are available in `etl::ranges::views`.
### Range Factories
| View | `views::` adaptor | Description |
|---|---|---|
| `empty_view<T>` | `views::empty<T>` | A view with no elements. |
| `single_view` | `views::single` | A view containing exactly one element. |
| `iota_view` | `views::iota` | A view of sequentially increasing values. |
| `repeat_view` | `views::repeat` | A view that repeats a value a given number of times. |
### Range Adaptors
| View | `views::` adaptor | Description |
|---|---|---|
| `ref_view` | `views::ref` | A non-owning view that wraps a reference to a range. |
| `owning_view` | `views::owning` | A view that takes ownership of a range via move. |
| — | `views::all` | Returns the range itself (if already a view), a `ref_view`, or an `owning_view`. |
| `filter_view` | `views::filter` | Filters elements based on a predicate. |
| `transform_view` | `views::transform` | Applies a transformation to each element. |
| `as_rvalue_view` | `views::as_rvalue` | Casts each element to an rvalue reference. |
| `as_const_view` | `views::as_const` | Provides a const view of the elements. |
| `cache_latest_view` | `views::cache_latest` | Caches the most recently accessed element (avoids recomputation). |
| `reverse_view` | `views::reverse` | Reverses the order of elements. |
| `drop_view` | `views::drop` | Skips the first *n* elements. |
| `drop_while_view` | `views::drop_while` | Skips leading elements while a predicate is true. |
| `take_view` | `views::take` | Takes the first *n* elements. |
| `take_while_view` | `views::take_while` | Takes leading elements while a predicate is true. |
| `join_view` | `views::join` | Flattens a range of ranges into a single range. |
| `join_with_view` | `views::join_with` | Flattens a range of ranges, inserting a delimiter between each. |
| `split_view` | `views::split` | Splits a range into subranges around a delimiter pattern. |
| `lazy_split_view` | `views::lazy_split` | Lazily splits a range by a pattern (inner ranges discovered on iteration). |
| — | `views::counted` | Creates a view of *n* elements starting from an iterator. |
| `concat_view` | `views::concat` | Concatenates multiple ranges into a single view. |
| `zip_view` | `views::zip` | Zips multiple ranges into a view of tuples (length of shortest range). |
| `zip_transform_view` | `views::zip_transform` | Zips multiple ranges and applies a function to each tuple of elements. |
| `common_view` | `views::common` | Adapts a view so that its iterator and sentinel types are the same. |
| `enumerate_view` | `views::enumerate` | Pairs each element with its index, producing tuples of (index, value). |
| `elements_view` | `views::elements` | Extracts the *N*-th element from each tuple-like value. |
| `keys_view` | `views::keys` | Alias for `elements_view` with *N*=0 (extracts first element of pairs/tuples). |
| `values_view` | `views::values` | Alias for `elements_view` with *N*=1 (extracts second element of pairs/tuples). |
| `adjacent_view` | `views::adjacent` | Produces a view of tuples of *N* adjacent elements (sliding window of tuples). |
| — | `views::pairwise` | Alias for `views::adjacent<2>`. |
| `adjacent_transform_view` | `views::adjacent_transform` | Applies a function to each group of *N* adjacent elements. |
| — | `views::pairwise_transform` | Alias for `views::adjacent_transform<2>`. |
| `chunk_view` | `views::chunk` | Splits a range into non-overlapping chunks of a given size. |
| `slide_view` | `views::slide` | Produces overlapping subranges (sliding windows) of a given size. |
| `chunk_by_view` | `views::chunk_by` | Splits a range into subranges between adjacent elements where a predicate is false. |
| `stride_view` | `views::stride` | Yields every *N*-th element from the underlying range. |
| `cartesian_product_view` | `views::cartesian_product` | Produces the Cartesian product of multiple ranges as a view of tuples. |
| `to_input_view` | `views::to_input` | Downgrades iterator category to input iterator while preserving elements and order. |
| `subrange` | — | Represents a sub-range defined by an iteratorsentinel pair. |
All views support range-based for-loop iteration and can be composed with the pipe (`|`) operator.
## Supported Algorithms
All algorithms are callable objects in the `etl::ranges` namespace. Each supports both an iterator-pair overload and a range overload (where applicable), and most accept optional projection and comparator arguments.
### Non-modifying Sequence Operations
| Algorithm | Description |
|---|---|
| `for_each` | Applies a function to each element in a range. |
| `for_each_n` | Applies a function to the first *n* elements. |
| `find` | Finds the first element equal to a value. |
| `find_if` | Finds the first element satisfying a predicate. |
| `find_if_not` | Finds the first element not satisfying a predicate. |
| `find_end` | Finds the last occurrence of a subsequence. |
| `find_first_of` | Finds the first element matching any in a second range. |
| `adjacent_find` | Finds the first pair of adjacent equal elements. |
| `count` | Counts elements equal to a value. |
| `count_if` | Counts elements satisfying a predicate. |
| `all_of` | Checks if all elements satisfy a predicate. |
| `any_of` | Checks if any element satisfies a predicate. |
| `none_of` | Checks if no elements satisfy a predicate. |
| `mismatch` | Finds the first position where two ranges differ. |
| `equal` | Checks if two ranges are equal. |
| `is_permutation` | Checks if one range is a permutation of another. |
| `search` | Searches for the first occurrence of a subsequence. |
| `search_n` | Searches for *n* consecutive copies of a value. |
| `starts_with` | Checks if a range starts with another range. |
| `ends_with` | Checks if a range ends with another range. |
| `lexicographical_compare` | Compares two ranges lexicographically. |
### Fold Operations
| Algorithm | Description |
|---|---|
| `fold_left` | Left-folds elements with a binary operation. |
| `fold_left_with_iter` | Left-folds, returning both the result and an iterator. |
| `fold_left_first` | Left-folds using the first element as the initial value. |
| `fold_left_first_with_iter` | Like `fold_left_first`, also returning an iterator. |
| `fold_right` | Right-folds elements with a binary operation. |
| `fold_right_last` | Right-folds using the last element as the initial value. |
### Modifying Sequence Operations
| Algorithm | Description |
|---|---|
| `copy` | Copies elements to a destination range. |
| `copy_n` | Copies *n* elements to a destination range. |
| `copy_if` | Copies elements satisfying a predicate. |
| `copy_backward` | Copies elements backwards to a destination range. |
| `move` | Moves elements to a destination range. |
| `move_backward` | Moves elements backwards to a destination range. |
| `swap_ranges` | Swaps elements between two ranges. |
| `replace` | Replaces elements equal to a value. |
| `replace_if` | Replaces elements satisfying a predicate. |
| `replace_copy` | Copies, replacing elements equal to a value. |
| `replace_copy_if` | Copies, replacing elements satisfying a predicate. |
| `remove` | Removes elements equal to a value. |
| `remove_if` | Removes elements satisfying a predicate. |
| `remove_copy` | Copies, omitting elements equal to a value. |
| `fill` | Fills a range with a value. |
| `fill_n` | Fills *n* elements with a value. |
| `generate` | Assigns each element the result of a generator function. |
| `generate_n` | Assigns *n* elements the result of a generator function. |
| `iota` | Fills a range with sequentially increasing values. |
| `unique` | Removes consecutive duplicate elements. |
| `unique_copy` | Copies, removing consecutive duplicates. |
| `transform` | Applies a transformation to each element. |
| `reverse` | Reverses the order of elements. |
| `reverse_copy` | Copies elements in reverse order. |
| `rotate` | Rotates elements in a range. |
| `rotate_copy` | Copies elements with rotation. |
| `shift_left` | Shifts elements to the left. |
| `shift_right` | Shifts elements to the right. |
| `shuffle` | Randomly reorders elements. |
| `sample` | Selects *n* random elements from a range. |
### Sorting Operations
| Algorithm | Description |
|---|---|
| `sort` | Sorts elements in a range. |
| `stable_sort` | Sorts elements preserving relative order of equivalent elements. |
| `partial_sort` | Partially sorts a range so that the first *n* elements are sorted. |
| `partial_sort_copy` | Copies and partially sorts elements. |
| `nth_element` | Partially sorts so that the *n*-th element is in its sorted position. |
| `is_sorted` | Checks if a range is sorted. |
| `is_sorted_until` | Finds the first unsorted element. |
### Partitioning Operations
| Algorithm | Description |
|---|---|
| `partition` | Partitions elements by a predicate. |
| `stable_partition` | Partitions elements, preserving relative order. |
| `is_partitioned` | Checks if a range is partitioned. |
| `partition_copy` | Copies elements into two ranges based on a predicate. |
| `partition_point` | Finds the partition point. |
### Binary Search (on sorted ranges)
| Algorithm | Description |
|---|---|
| `lower_bound` | Finds the first element not less than a value. |
| `upper_bound` | Finds the first element greater than a value. |
| `equal_range` | Returns the range of elements equal to a value. |
| `binary_search` | Checks if a sorted range contains a value. |
### Set Operations (on sorted ranges)
| Algorithm | Description |
|---|---|
| `includes` | Checks if one sorted range includes another. |
| `merge` | Merges two sorted ranges. |
| `inplace_merge` | Merges two consecutive sorted sub-ranges in place. |
| `set_union` | Computes the union of two sorted ranges. |
| `set_intersection` | Computes the intersection of two sorted ranges. |
| `set_difference` | Computes the difference of two sorted ranges. |
| `set_symmetric_difference` | Computes the symmetric difference of two sorted ranges. |
### Heap Operations
| Algorithm | Description |
|---|---|
| `make_heap` | Creates a heap from a range. |
| `push_heap` | Pushes an element onto a heap. |
| `pop_heap` | Pops the top element from a heap. |
| `sort_heap` | Sorts a heap into a sorted range. |
| `is_heap` | Checks if a range is a heap. |
| `is_heap_until` | Finds the first element that breaks the heap property. |
### Min/Max Operations
| Algorithm | Description |
|---|---|
| `min` | Returns the smaller of two values or the smallest in an initializer list. |
| `min_element` | Finds the smallest element in a range. |
| `max` | Returns the larger of two values or the largest in an initializer list. |
| `max_element` | Finds the largest element in a range. |
| `minmax` | Returns the smaller and larger of two values. |
| `minmax_element` | Finds both the smallest and largest elements in a range. |
| `clamp` | Clamps a value between a minimum and maximum. |
### Permutation Operations
| Algorithm | Description |
|---|---|
| `next_permutation` | Generates the next lexicographic permutation. |
| `prev_permutation` | Generates the previous lexicographic permutation. |
## Reference
For reference to the STD implementation, see also:
- Algorithms: https://en.cppreference.com/w/cpp/algorithm.html
- Ranges/Views: https://en.cppreference.com/w/cpp/ranges.html
## Limitations
- Not all C++20 range features are available due to limitation to C++17. Especially C++20 concepts are not used.
- Designed for ETL containers but can work with standard containers if compatible with ETL's iterator requirements.

100
docs/source-formatting.md Normal file
View File

@ -0,0 +1,100 @@
# Source Formatting
This project uses **clang-format** (version 18) to enforce a consistent coding style
for C and C++ source files. For convenience, **treefmt** is also configured as a
single-command wrapper that discovers and formats every file in the tree.
---
## clang-format
### Configuration file
The formatting rules live in [`.clang-format`](../.clang-format) at the repository
root. The style is based on **LLVM**.
See the `.clang-format` file itself for the complete list.
### Version requirement
clang-format **18** is required.
The helper script [`scripts/clang-format-wrapper`](../scripts/clang-format-wrapper)
automatically resolves the correct binary: it first looks for `clang-format-18` on
`PATH`, then falls back to `clang-format` and verifies that its major version is 18.
All other tooling in the repo calls this wrapper instead of `clang-format` directly.
### Running clang-format manually
Format every tracked source file in the repository:
```bash
git ls-files -z \
'*.c' '*.cc' '*.cpp' \
'*.h' '*.hh' '*.hpp' \
':(exclude)include/etl/generators/*' \
':(exclude)include/etl/private/*_cpp03.h' | xargs -0 scripts/clang-format-wrapper -i --verbose --style=file
```
You can also format individual files directly:
```bash
scripts/clang-format-wrapper -i --style=file path/to/file.cpp
```
---
## treefmt
[treefmt](https://treefmt.com) is a language-agnostic source-tree formatter.
It reads a single configuration file and dispatches each file to the appropriate
formatter. In this project, it delegates all C/C++ formatting to the same
`clang-format-wrapper` described above.
In comparison to calling clang-format directly, it brings a significant speedup.
### Configuration file
The configuration lives in [`.treefmt.toml`](../.treefmt.toml) at the repository root.
### Installing treefmt
treefmt is a standalone Go binary. Install it with any of:
```bash
# Using the official install script
curl -fsSL https://raw.githubusercontent.com/numtide/treefmt/main/install.sh | bash
# Or via Homebrew
brew install treefmt
# Or via Nix
nix profile install nixpkgs#treefmt2
```
See the [treefmt documentation](https://treefmt.com) for more options.
### Running treefmt
From the repository root:
```bash
# Format everything
treefmt
# Check formatting without modifying files (useful in CI)
treefmt --fail-on-change
```
---
## Excluded paths
`.treefmt.toml` excludes generated files under
`include/etl/generators/`. Do **not** format those files manually via clang-format or treefmt.
## Pre-commit
Before submitting a PR / contribution, run `treefmt --fail-on-change` to catch
unformatted code before merge.
Alternatively, a plain `treefmt` automatically fixes any issues.

View File

@ -10,6 +10,6 @@
#define ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK
#define ETL_NO_STL
//#include "etl/profiles/auto.h"
// #include "etl/profiles/auto.h"
#endif

View File

@ -1,23 +1,23 @@
#include <stdio.h>
//#if (__cplusplus < 201103L)
// #if (__cplusplus < 201103L)
extern "C"
{
//#endif
#include "Board_LED.h" // ::Board Support:LED
// #endif
#include "Board_Buttons.h" // ::Board Support:Buttons
//#if (__cplusplus < 201103L)
#include "Board_LED.h" // ::Board Support:LED
// #if (__cplusplus < 201103L)
}
//#endif
// #endif
#include "stm32f4xx.h" // Device header
#include "stm32f4xx.h" // Device header
#include "etl/function.h"
#include "etl/callback_timer.h"
#include "etl/vector.h"
#include "etl/iterator.h"
#include "etl/binary.h"
#include "etl/callback_timer.h"
#include "etl/function.h"
#include "etl/iterator.h"
#include "etl/vector.h"
struct FP
{
@ -28,7 +28,7 @@ static etl::vector<FP, 10> power_callbacks;
void register_poweroff_callback(void (*function)())
{
FP fp = { function };
FP fp = {function};
power_callbacks.push_back(fp);
}
@ -45,38 +45,38 @@ etl::timer::id::type swap_timers;
* SystemCoreClockConfigure: configure SystemCoreClock using HSI
(HSE is not populated on Nucleo board)
*----------------------------------------------------------------------------*/
void SystemCoreClockConfigure(void) {
void SystemCoreClockConfigure(void)
{
RCC->CR |= ((uint32_t)RCC_CR_HSION); // Enable HSI
while ((RCC->CR & RCC_CR_HSIRDY) == 0); // Wait for HSI Ready
RCC->CR |= ((uint32_t)RCC_CR_HSION); // Enable HSI
while ((RCC->CR & RCC_CR_HSIRDY) == 0); // Wait for HSI Ready
RCC->CFGR = RCC_CFGR_SW_HSI; // HSI is system clock
while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_HSI); // Wait for HSI used as system clock
RCC->CFGR = RCC_CFGR_SW_HSI; // HSI is system clock
while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_HSI); // Wait for HSI used as system clock
FLASH->ACR = FLASH_ACR_PRFTEN; // Enable Prefetch Buffer
FLASH->ACR |= FLASH_ACR_ICEN; // Instruction cache enable
FLASH->ACR |= FLASH_ACR_DCEN; // Data cache enable
FLASH->ACR |= FLASH_ACR_LATENCY_5WS; // Flash 5 wait state
FLASH->ACR = FLASH_ACR_PRFTEN; // Enable Prefetch Buffer
FLASH->ACR |= FLASH_ACR_ICEN; // Instruction cache enable
FLASH->ACR |= FLASH_ACR_DCEN; // Data cache enable
FLASH->ACR |= FLASH_ACR_LATENCY_5WS; // Flash 5 wait state
RCC->CFGR |= RCC_CFGR_HPRE_DIV1; // HCLK = SYSCLK
RCC->CFGR |= RCC_CFGR_PPRE1_DIV4; // APB1 = HCLK/4
RCC->CFGR |= RCC_CFGR_PPRE2_DIV2; // APB2 = HCLK/2
RCC->CFGR |= RCC_CFGR_HPRE_DIV1; // HCLK = SYSCLK
RCC->CFGR |= RCC_CFGR_PPRE1_DIV4; // APB1 = HCLK/4
RCC->CFGR |= RCC_CFGR_PPRE2_DIV2; // APB2 = HCLK/2
RCC->CR &= ~RCC_CR_PLLON; // Disable PLL
RCC->CR &= ~RCC_CR_PLLON; // Disable PLL
// PLL configuration: VCO = HSI/M * N, Sysclk = VCO/P
RCC->PLLCFGR = ( 16ul | // PLL_M = 16
(384ul << 6U) | // PLL_N = 384
( 3ul << 16U) | // PLL_P = 8
(RCC_PLLCFGR_PLLSRC_HSI) | // PLL_SRC = HSI
( 8ul << 24U) ); // PLL_Q = 8
RCC->PLLCFGR = (16ul | // PLL_M = 16
(384ul << 6U) | // PLL_N = 384
(3ul << 16U) | // PLL_P = 8
(RCC_PLLCFGR_PLLSRC_HSI) | // PLL_SRC = HSI
(8ul << 24U)); // PLL_Q = 8
RCC->CR |= RCC_CR_PLLON; // Enable PLL
while((RCC->CR & RCC_CR_PLLRDY) == 0) __NOP(); // Wait till PLL is ready
RCC->CR |= RCC_CR_PLLON; // Enable PLL
while ((RCC->CR & RCC_CR_PLLRDY) == 0) __NOP(); // Wait till PLL is ready
RCC->CFGR &= ~RCC_CFGR_SW; // Select PLL as system clock source
RCC->CFGR |= RCC_CFGR_SW_PLL;
while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL); // Wait till PLL is system clock src
RCC->CFGR &= ~RCC_CFGR_SW; // Select PLL as system clock source
RCC->CFGR |= RCC_CFGR_SW_PLL;
while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL); // Wait till PLL is system clock src
}
void StartTimers()
@ -123,7 +123,7 @@ void LedToggle()
int main()
{
SystemCoreClockConfigure(); // configure HSI as System Clock
SystemCoreClockConfigure(); // configure HSI as System Clock
SystemCoreClockUpdate();
LED_Initialize();
@ -131,10 +131,10 @@ int main()
// The LEDs will start flashing fast after 2 seconds.
// After another 5 seconds they will start flashing slower.
short_toggle = callback_timer.register_timer(LedToggle, 50, etl::timer::mode::REPEATING);
long_toggle = callback_timer.register_timer(LedToggle, 100, etl::timer::mode::REPEATING);
short_toggle = callback_timer.register_timer(LedToggle, 50, etl::timer::mode::REPEATING);
long_toggle = callback_timer.register_timer(LedToggle, 100, etl::timer::mode::REPEATING);
start_timers = callback_timer.register_timer(StartTimers, 2000, etl::timer::mode::SINGLE_SHOT);
swap_timers = callback_timer.register_timer(SwapTimers, 1500, etl::timer::mode::SINGLE_SHOT);
swap_timers = callback_timer.register_timer(SwapTimers, 1500, etl::timer::mode::SINGLE_SHOT);
SysTick_Config(SystemCoreClock / 1000);
@ -152,7 +152,7 @@ extern "C"
{
void SysTick_Handler()
{
const uint32_t TICK = 1U;
const uint32_t TICK = 1U;
static uint32_t nticks = TICK;
if (callback_timer.tick(nticks))

View File

@ -11,8 +11,8 @@ enum VectorId
USART1_IRQ_HANDLER = 52,
USART2_IRQ_HANDLER = 53,
VECTOR_ID_END,
VECTOR_ID_OFFSET = TIM1_CC_IRQ_HANDLER,
VECTOR_ID_RANGE = VECTOR_ID_END - VECTOR_ID_OFFSET
VECTOR_ID_OFFSET = TIM1_CC_IRQ_HANDLER,
VECTOR_ID_RANGE = VECTOR_ID_END - VECTOR_ID_OFFSET
};
typedef etl::delegate_service<VECTOR_ID_RANGE, VECTOR_ID_OFFSET> InterruptVectors;
@ -91,8 +91,8 @@ public:
// Constructor.
Uart(int port_id, size_t interruptId)
: port_id(port_id),
callback(etl::delegate<void(size_t)>::create<Uart, &Uart::InterruptHandler>(*this))
: port_id(port_id)
, callback(etl::delegate<void(size_t)>::create<Uart, &Uart::InterruptHandler>(*this))
{
GetInterruptVectorsInstance().register_delegate(interruptId, callback);
}
@ -119,7 +119,8 @@ Uart uart1(0, USART1_IRQ_HANDLER);
Uart uart2(1, USART2_IRQ_HANDLER);
// Declare a global callback for the timer.
// Uses the most efficient callback type for a class, as everything is known at compile time.
// Uses the most efficient callback type for a class, as everything is known at
// compile time.
etl::delegate<void(size_t)> timer_member_callback = etl::delegate<void(size_t)>::create<Timer, timer, &Timer::InterruptHandler>();
// Declare the callbacks for the free functions.

View File

@ -1,7 +1,7 @@
#include <iostream>
#include "etl/function.h"
#include "etl/callback_service.h"
#include "etl/function.h"
enum VectorId
{
@ -11,8 +11,8 @@ enum VectorId
USART1_IRQ_HANDLER = 52,
USART2_IRQ_HANDLER = 53,
VECTOR_ID_END,
VECTOR_ID_OFFSET = TIM1_CC_IRQ_HANDLER,
VECTOR_ID_RANGE = VECTOR_ID_END - VECTOR_ID_OFFSET
VECTOR_ID_OFFSET = TIM1_CC_IRQ_HANDLER,
VECTOR_ID_RANGE = VECTOR_ID_END - VECTOR_ID_OFFSET
};
typedef etl::callback_service<VECTOR_ID_RANGE, VECTOR_ID_OFFSET> InterruptVectors;
@ -91,8 +91,8 @@ public:
// Constructor.
Uart(int port_id, int interruptId)
: port_id(port_id),
callback(*this)
: port_id(port_id)
, callback(*this)
{
GetInterruptVectorsInstance().register_callback(interruptId, callback);
}
@ -119,7 +119,8 @@ Uart uart1(0, USART1_IRQ_HANDLER);
Uart uart2(1, USART2_IRQ_HANDLER);
// Declare a global callback for the timer.
// Uses the most efficient callback type for a class, as everything is known at compile time.
// Uses the most efficient callback type for a class, as everything is known at
// compile time.
etl::function_imp<Timer, size_t, timer, &Timer::InterruptHandler> timer_member_callback;
// Declare the callbacks for the free functions.

View File

@ -1,13 +1,13 @@
#include <iostream>
#include <thread>
#include <atomic>
#include <string>
#include <chrono>
#include <iostream>
#include <string>
#include <thread>
#include "etl/mutex.h"
#include "etl/message.h"
#include "etl/message_router.h"
#include "etl/mutex.h"
//*************************************
struct Message1 : public etl::message<1>
@ -48,9 +48,7 @@ public:
}
//*****************
void on_receive_unknown(const etl::imessage&)
{
}
void on_receive_unknown(const etl::imessage&) {}
std::string result;
@ -61,7 +59,7 @@ private:
//*************************************
etl::atomic<bool> start = false;
Router router;
Router router;
//*************************************
void thread1()
@ -106,5 +104,3 @@ int main()
return 0;
}

View File

@ -31,9 +31,9 @@ SOFTWARE.
// derived class.
//*****************************************************************************
#include "etl/queue.h"
#include "etl/fsm.h"
#include "etl/message_packet.h"
#include "etl/queue.h"
#include <iostream>
#include <string>
@ -122,7 +122,7 @@ public:
while (!queue.empty())
{
message_packet& packet = queue.front();
etl::imessage& msg = packet.get();
etl::imessage& msg = packet.get();
std::cout << "Processing message " << int(msg.get_message_id()) << std::endl;
// Call the base class's receive function.
@ -258,7 +258,7 @@ int main()
State2 state2;
// The list of states.
etl::ifsm_state* state_list[] = { &state1, &state2 };
etl::ifsm_state* state_list[] = {&state1, &state2};
// Define some messages.
Message1 m1(1);
@ -285,4 +285,3 @@ int main()
return 0;
}

View File

@ -1,6 +1,6 @@
#include "etl/queue.h"
#include "etl/message_router.h"
#include "etl/queue.h"
#include <iostream>
#include <string>
@ -81,7 +81,7 @@ public:
while (!queue.empty())
{
message_packet& packet = queue.front();
etl::imessage& msg = packet.get();
etl::imessage& msg = packet.get();
std::cout << "Processing message " << int(msg.get_message_id()) << std::endl;
// Call the base class's receive function.
@ -146,4 +146,3 @@ int main()
return 0;
}

View File

@ -31,9 +31,9 @@ SOFTWARE.
// Experiment with the different scheduling policies.
//*****************************************************************************
#include "etl/function.h"
#include "etl/scheduler.h"
#include "etl/task.h"
#include "etl/function.h"
#include <iostream>
#include <string>
@ -50,13 +50,13 @@ public:
: task(1)
, work(3)
{
}
//*************************************
uint32_t task_request_work() const
{
return work; // How much work do we still have to do? This could be a message queue length.
return work; // How much work do we still have to do? This could be a
// message queue length.
}
//*************************************
@ -83,13 +83,13 @@ public:
: task(2)
, work(4)
{
}
//*************************************
uint32_t task_request_work() const
{
return work; // How much work do we still have to do? This could be a message queue length.
return work; // How much work do we still have to do? This could be a
// message queue length.
}
//*************************************
@ -115,7 +115,6 @@ public:
Idle(etl::ischeduler& scheduler_)
: scheduler(scheduler_)
{
}
//*************************************
@ -181,4 +180,3 @@ int main()
return 0;
}

View File

@ -2,18 +2,18 @@
// Shared message example
//*****************************************************************************
#include "etl/shared_message.h"
#include "etl/message.h"
#include "etl/reference_counted_message_pool.h"
#include "etl/message_router.h"
#include "etl/message_bus.h"
#include "etl/fixed_sized_memory_block_allocator.h"
#include "etl/message.h"
#include "etl/message_bus.h"
#include "etl/message_router.h"
#include "etl/queue.h"
#include "etl/reference_counted_message_pool.h"
#include "etl/shared_message.h"
#include <iostream>
#include <atomic>
#include <string>
#include <iostream>
#include <mutex>
#include <string>
constexpr etl::message_router_id_t RouterId1 = 1U;
constexpr etl::message_router_id_t RouterId2 = 2U;
@ -26,9 +26,8 @@ struct Message1 : public etl::message<1>
Message1(std::string s_)
: s(s_)
{
}
std::string s;
};
@ -40,10 +39,10 @@ struct Message2 : public etl::message<2>
Message2(std::string s_)
: s(s_)
{
}
std::string s;
char data[100];
};
@ -55,7 +54,6 @@ struct Message3 : public etl::message<3>
Message3(std::string s_)
: s(s_)
{
}
std::string s;
@ -199,7 +197,7 @@ struct Bus : public etl::message_bus<2U>
//*****************************************************************************
MessageRouter1 router1;
MessageRouter2 router2;
Bus bus;
Bus bus;
//*****************************************************************************
// The thread safe message pool. Uses atomic uint32_t for counting.
@ -230,8 +228,8 @@ private:
};
//*****************************************************************************
// The memory block allocator that supplies the pool with memory
// to store reference counted messages in.
// The memory block allocator that supplies the pool with memory
// to store reference counted messages in.
// The reference counted message parameters type for the messages we will use.
using message_parameters_small = MessagePool::pool_message_parameters<Message1, Message3>;
@ -243,10 +241,12 @@ constexpr size_t max_alignment_small = message_parameters_small::max_alignment;
constexpr size_t max_size_large = message_parameters_large::max_size;
constexpr size_t max_alignment_large = message_parameters_large::max_alignment;
// A fixed memory block allocator for 4 items, using the parameters from the smaller messages.
// A fixed memory block allocator for 4 items, using the parameters from the
// smaller messages.
etl::fixed_sized_memory_block_allocator<max_size_small, max_alignment_small, 4U> memory_allocator;
// A fixed memory block allocator for 4 items, using the parameters from the larger message.
// A fixed memory block allocator for 4 items, using the parameters from the
// larger message.
etl::fixed_sized_memory_block_allocator<max_size_large, max_alignment_large, 4U> memory_allocator_successor;
//*****************************************************************************
@ -256,8 +256,8 @@ etl::fixed_sized_memory_block_allocator<max_size_large, max_alignment_large, 4U>
MessagePool message_pool(memory_allocator);
//*****************************************************************************
// A statically allocated reference counted message that is never allocated or released by a pool.
// Contains a copy of Message3("Three").
// A statically allocated reference counted message that is never allocated or
// released by a pool. Contains a copy of Message3("Three").
//*****************************************************************************
etl::persistent_message<Message3> pm3(Message3("Three"));
@ -269,10 +269,15 @@ int main()
Message1 m1("One");
Message2 m2("Two");
etl::shared_message sm1(message_pool, m1); // Created a shared message by allocating a reference counted message from message_pool containing a copy of m1.
etl::shared_message sm2(message_pool, m2); // Created a shared message by allocating a reference counted message from message_pool containing a copy of m2.
etl::shared_message sm3(pm3); // Created a shared message from a statically allocated persistent message.
etl::shared_message sm1(message_pool,
m1); // Created a shared message by allocating a reference counted message
// from message_pool containing a copy of m1.
etl::shared_message sm2(message_pool,
m2); // Created a shared message by allocating a reference counted message
// from message_pool containing a copy of m2.
etl::shared_message sm3(pm3); // Created a shared message from a statically
// allocated persistent message.
bus.subscribe(router1); // Subscribe router1 to the bus.
bus.subscribe(router2); // Subscribe router2 to the bus.

View File

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.10)
project(UniquePtrWithPool LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Add source files
add_executable(UniquePtrWithPool Main.cpp)
target_include_directories(UniquePtrWithPool PRIVATE ../../include)

View File

@ -0,0 +1,38 @@
#include <iostream>
#include "etl/memory.h"
#include "etl/pool.h"
struct S
{
S(int a_, double b_)
: a(a_)
, b(b_)
{
}
int a;
double b;
};
int main()
{
etl::pool<S, 10> pool;
auto pool_deleter = [&pool](auto ptr)
{
std::cout << "Releasing S(" << ptr->a << ", " << ptr->b << ") back to pool." << std::endl;
pool.destroy(ptr);
};
using Unique = etl::unique_ptr<S, decltype(pool_deleter)>;
Unique us1(pool.create(1, 2), pool_deleter);
std::cout << "Created S(" << us1->a << ", " << us1->b << ") from pool." << std::endl;
{
Unique us2(pool.create(3, 4), pool_deleter);
std::cout << "Created S(" << us2->a << ", " << us2->b << ") from pool." << std::endl;
}
Unique us3(pool.create(5, 6), pool_deleter);
std::cout << "Created S(" << us3->a << ", " << us3->b << ") from pool." << std::endl;
}

View File

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.36408.4 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UniquePtrWithPool", "UniquePtrWithPool.vcxproj", "{B9ED2FDF-2529-4315-9AEF-02A98B804DEC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B9ED2FDF-2529-4315-9AEF-02A98B804DEC}.Debug|x64.ActiveCfg = Debug|x64
{B9ED2FDF-2529-4315-9AEF-02A98B804DEC}.Debug|x64.Build.0 = Debug|x64
{B9ED2FDF-2529-4315-9AEF-02A98B804DEC}.Debug|x86.ActiveCfg = Debug|Win32
{B9ED2FDF-2529-4315-9AEF-02A98B804DEC}.Debug|x86.Build.0 = Debug|Win32
{B9ED2FDF-2529-4315-9AEF-02A98B804DEC}.Release|x64.ActiveCfg = Release|x64
{B9ED2FDF-2529-4315-9AEF-02A98B804DEC}.Release|x64.Build.0 = Release|x64
{B9ED2FDF-2529-4315-9AEF-02A98B804DEC}.Release|x86.ActiveCfg = Release|Win32
{B9ED2FDF-2529-4315-9AEF-02A98B804DEC}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D21FA849-65C8-4A81-BD9D-B38BFBD73494}
EndGlobalSection
EndGlobal

View File

@ -19,36 +19,36 @@
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<VCProjectVersion>17.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{0523db70-0955-4eb0-a042-04514987a602}</ProjectGuid>
<RootNamespace>etlinitialiserlist</RootNamespace>
<ProjectGuid>{b9ed2fdf-2529-4315-9aef-02a98b804dec}</ProjectGuid>
<RootNamespace>UniquePtrWithPool</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
@ -70,26 +70,13 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;ETL_NO_STL;ETL_IN_UNIT_TEST_INITIALIZER_LIST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>../../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalIncludeDirectories>../../include/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -104,11 +91,10 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>../../include/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
@ -135,13 +121,11 @@
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\test_initializer_list.cpp" />
<ClCompile Include="Main.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -88,35 +88,35 @@ public:
// Notify observers about a position event.
void Position_Event()
{
Position position = { 100, 200 };
Position position = {100, 200};
notify_observers(position);
}
// Notify observers about a button up event.
void Button_Event_Up()
{
Button button = { Button::Up };
Button button = {Button::Up};
notify_observers(button);
}
// Notify observers about a button down event.
void Button_Event_Down()
{
Button button = { Button::Down };
Button button = {Button::Down};
notify_observers(button);
}
// Notify observers about a wheel up event.
void Wheel_Event_Up()
{
Wheel wheel = { 50 };
Wheel wheel = {50};
notify_observers(wheel);
}
// Notify observers about a wheel down event.
void Wheel_Event_Down()
{
Wheel wheel = { -25 };
Wheel wheel = {-25};
notify_observers(wheel);
}
};
@ -137,6 +137,6 @@ int main()
mouse_driver.Position_Event();
mouse_driver.Wheel_Event_Down();
mouse_driver.Wheel_Event_Up();
return 0;
}

View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ .Title }} | {{ .Site.Title }}</title>
</head>
<body>
<main>
{{ block "main" . }}{{ end }}
</main>
{{ partial "footer.html" . }}
</body>
</html>

View File

@ -0,0 +1,4 @@
<footer style="text-align: center;">
<p>© 2014{{ now.Format "2006" }} {{ .Site.Title }}. All rights reserved.</p>
<p></p>
</footer>

BIN
images/QR Github.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -31,19 +31,41 @@ SOFTWARE.
#ifndef ETL_ABSOLUTE_INCLUDED
#define ETL_ABSOLUTE_INCLUDED
#include "type_traits.h"
#include "platform.h"
#include "error_handler.h"
#include "integral_limits.h"
#include "type_traits.h"
namespace etl
{
namespace private_absolute
{
//*************************************************************************
// Non-constexpr function that is never called for valid inputs.
// If reached during constant evaluation, the compiler emits an error
// because it's not constexpr.
// At runtime, triggers the ETL assert handler.
//*************************************************************************
template <typename T>
inline T signed_min_error()
{
ETL_ASSERT_FAIL(ETL_ERROR_GENERIC("absolute value of minimum signed integer is undefined"));
return T(0);
}
} // namespace private_absolute
//***************************************************************************
// For signed types.
//***************************************************************************
template <typename T>
ETL_NODISCARD
ETL_CONSTEXPR
typename etl::enable_if<etl::is_signed<T>::value, T>::type
absolute(T value) ETL_NOEXCEPT
ETL_NODISCARD ETL_CONSTEXPR typename etl::enable_if< etl::is_signed<T>::value && etl::is_integral<T>::value, T>::type absolute(T value)
{
return (value == etl::integral_limits<T>::min) ? etl::private_absolute::signed_min_error<T>() : static_cast<T>((value < T(0)) ? -value : value);
}
template <typename T>
ETL_NODISCARD ETL_CONSTEXPR typename etl::enable_if< etl::is_signed<T>::value && !etl::is_integral<T>::value, T>::type absolute(T value)
ETL_NOEXCEPT
{
return (value < T(0)) ? -value : value;
}
@ -52,10 +74,7 @@ namespace etl
// For unsigned types.
//***************************************************************************
template <typename T>
ETL_NODISCARD
ETL_CONSTEXPR
typename etl::enable_if<etl::is_unsigned<T>::value, T>::type
absolute(T value) ETL_NOEXCEPT
ETL_NODISCARD ETL_CONSTEXPR typename etl::enable_if<etl::is_unsigned<T>::value, T>::type absolute(T value) ETL_NOEXCEPT
{
return value;
}
@ -64,18 +83,15 @@ namespace etl
// For signed types.
// Returns the result as the unsigned type.
//***************************************************************************
#if ETL_USING_CPP11
template <typename T, typename TReturn = typename etl::make_unsigned<T>::type>
#else
template <typename T, typename TReturn>
#endif
ETL_NODISCARD
ETL_CONSTEXPR
typename etl::enable_if<etl::is_signed<T>::value, TReturn>::type
absolute_unsigned(T value) ETL_NOEXCEPT
template <typename T>
ETL_NODISCARD ETL_CONSTEXPR typename etl::enable_if<etl::is_signed<T>::value, typename etl::make_unsigned<T>::type>::type absolute_unsigned(T value)
ETL_NOEXCEPT
{
typedef typename etl::make_unsigned<T>::type TReturn;
return (value == etl::integral_limits<T>::min) ? (etl::integral_limits<TReturn>::max / 2U) + 1U
: (value < T(0)) ? TReturn(-value) : TReturn(value);
: (value < T(0)) ? TReturn(-value)
: TReturn(value);
}
//***************************************************************************
@ -83,14 +99,10 @@ namespace etl
// Returns the result as the unsigned type.
//***************************************************************************
template <typename T>
ETL_NODISCARD
ETL_CONSTEXPR
typename etl::enable_if<etl::is_unsigned<T>::value, T>::type
absolute_unsigned(T value) ETL_NOEXCEPT
ETL_NODISCARD ETL_CONSTEXPR typename etl::enable_if<etl::is_unsigned<T>::value, T>::type absolute_unsigned(T value) ETL_NOEXCEPT
{
return etl::absolute(value);
}
}
} // namespace etl
#endif

File diff suppressed because it is too large Load Diff

View File

@ -32,10 +32,10 @@ SOFTWARE.
#define ETL_ALIGNMENT_INCLUDED
#include "platform.h"
#include "type_traits.h"
#include "static_assert.h"
#include "error_handler.h"
#include "exception.h"
#include "static_assert.h"
#include "type_traits.h"
#include "utility.h"
#include <stdint.h>
@ -124,28 +124,28 @@ namespace etl
// Matching alignment.
template <size_t Alignment, typename T1, typename... TRest>
class type_with_alignment_matcher<true, Alignment, T1, TRest...>
class type_with_alignment_matcher<true, Alignment, T1, TRest...>
{
public:
typedef T1 type;
};
// Non-matching alignment
template <size_t Alignment, typename T1, typename T2, typename... TRest>
class type_with_alignment_matcher <false, Alignment, T1, T2, TRest...>
class type_with_alignment_matcher<false, Alignment, T1, T2, TRest...>
{
public:
typedef typename type_with_alignment_matcher < Alignment <= etl::alignment_of<T2>::value , Alignment, T2, TRest... > ::type type;
typedef typename type_with_alignment_matcher< Alignment <= etl::alignment_of<T2>::value, Alignment, T2, TRest... >::type type;
};
// Non-matching alignment, none left.
template <size_t Alignment, typename T1>
class type_with_alignment_matcher <false, Alignment, T1>
class type_with_alignment_matcher<false, Alignment, T1>
{
public:
typedef char type;
};
@ -153,23 +153,23 @@ namespace etl
// Helper.
//***************************************************************************
template <size_t Alignment, typename T1, typename... T>
class type_with_alignment_helper
class type_with_alignment_helper
{
public:
typedef typename type_with_alignment_matcher<Alignment <= etl::alignment_of<T1>::value, Alignment, T1, T...>::type type;
};
#else
//***************************************************************************
// Matcher.
//***************************************************************************
template <bool Is_Match, const size_t Alignment, typename T1 = void, typename T2 = void, typename T3 = void, typename T4 = void,
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void>
template <bool Is_Match, const size_t Alignment, typename T1 = void, typename T2 = void, typename T3 = void, typename T4 = void,
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void>
class type_with_alignment_matcher;
// Matching alignment.
template <size_t Alignment, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
class type_with_alignment_matcher <true, Alignment, T1, T2, T3, T4, T5, T6, T7, T8>
class type_with_alignment_matcher<true, Alignment, T1, T2, T3, T4, T5, T6, T7, T8>
{
public:
@ -178,16 +178,17 @@ namespace etl
// Non-matching alignment.
template <size_t Alignment, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
class type_with_alignment_matcher <false, Alignment, T1, T2, T3, T4, T5, T6, T7, T8>
class type_with_alignment_matcher<false, Alignment, T1, T2, T3, T4, T5, T6, T7, T8>
{
public:
typedef typename type_with_alignment_matcher<Alignment <= etl::alignment_of<T2>::value, Alignment, T2, T3, T4, T5, T6, T7, T8, void>::type type;
typedef
typename type_with_alignment_matcher< Alignment <= etl::alignment_of<T2>::value, Alignment, T2, T3, T4, T5, T6, T7, T8, void>::type type;
};
// Non-matching alignment, none left.
template <size_t Alignment>
class type_with_alignment_matcher <false, Alignment, void, void, void, void, void, void, void, void>
class type_with_alignment_matcher<false, Alignment, void, void, void, void, void, void, void, void>
{
public:
@ -197,16 +198,16 @@ namespace etl
//***************************************************************************
// Helper.
//***************************************************************************
template <size_t Alignment, typename T1, typename T2 = void, typename T3 = void, typename T4 = void,
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void>
template <size_t Alignment, typename T1, typename T2 = void, typename T3 = void, typename T4 = void, typename T5 = void, typename T6 = void,
typename T7 = void, typename T8 = void>
class type_with_alignment_helper
{
public:
typedef typename type_with_alignment_matcher<Alignment <= etl::alignment_of<T1>::value, Alignment, T1, T2, T3, T4, T5, T6, T7, T8>::type type;
typedef typename type_with_alignment_matcher< Alignment <= etl::alignment_of<T1>::value, Alignment, T1, T2, T3, T4, T5, T6, T7, T8>::type type;
};
#endif
}
} // namespace private_alignment
//***************************************************************************
/// Gets a type that has the same as the specified alignment.
@ -218,12 +219,17 @@ namespace etl
public:
#if ETL_USING_CPP11
typedef struct { alignas(Alignment) char dummy; } type;
typedef struct
{
alignas(Alignment) char dummy;
} type;
#else
#if ETL_NOT_USING_64BIT_TYPES
typedef typename private_alignment::type_with_alignment_helper<Alignment, int_least8_t, int_least16_t, int32_t, float, double, void*>::type type;
typedef typename private_alignment::type_with_alignment_helper< Alignment, int_least8_t, int_least16_t, int32_t, float, double, void*>::type type;
#else
typedef typename private_alignment::type_with_alignment_helper<Alignment, int_least8_t, int_least16_t, int32_t, int64_t, float, double, void*>::type type;
typedef
typename private_alignment::type_with_alignment_helper< Alignment, int_least8_t, int_least16_t, int32_t, int64_t, float, double, void*>::type
type;
#endif
#endif
@ -245,42 +251,37 @@ namespace etl
{
struct type
{
//type()
// : data()
//{
//}
/// Convert to T reference.
template <typename T>
operator T& ()
operator T&()
{
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
ETL_STATIC_ASSERT((etl::is_same<T*, void*>::value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
T* t = *this;
return *t;
}
/// Convert to const T reference.
template <typename T>
operator const T& () const
operator const T&() const
{
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
ETL_STATIC_ASSERT((etl::is_same<T*, void*>::value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
const T* t = *this;
return *t;
}
/// Convert to T pointer.
template <typename T>
operator T* ()
operator T*()
{
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
ETL_STATIC_ASSERT((etl::is_same<T*, void*>::value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
return reinterpret_cast<T*>(data);
}
/// Convert to const T pointer.
template <typename T>
operator const T* () const
operator const T*() const
{
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
ETL_STATIC_ASSERT((etl::is_same<T*, void*>::value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
return reinterpret_cast<const T*>(data);
}
@ -288,7 +289,7 @@ namespace etl
template <typename T>
T& get_reference()
{
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
ETL_STATIC_ASSERT((etl::is_same<T*, void*>::value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
T* t = *this;
return *t;
}
@ -297,7 +298,7 @@ namespace etl
template <typename T>
const T& get_reference() const
{
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
ETL_STATIC_ASSERT((etl::is_same<T*, void*>::value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
const T* t = *this;
return *t;
}
@ -306,7 +307,7 @@ namespace etl
template <typename T>
T* get_address()
{
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
ETL_STATIC_ASSERT((etl::is_same<T*, void*>::value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
return reinterpret_cast<T*>(data);
}
@ -314,7 +315,7 @@ namespace etl
template <typename T>
const T* get_address() const
{
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
ETL_STATIC_ASSERT((etl::is_same<T*, void*>::value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
return reinterpret_cast<const T*>(data);
}
@ -323,8 +324,9 @@ namespace etl
#else
union
{
char data[Length];
typename etl::type_with_alignment<Alignment>::type etl_alignment_type; // A POD type that has the same alignment as Alignment.
char data[Length];
typename etl::type_with_alignment<Alignment>::type etl_alignment_type; // A POD type that has the same alignment
// as Alignment.
};
#endif
};
@ -368,149 +370,496 @@ namespace etl
typedef T* pointer;
typedef const T* const_pointer;
// Constructor
typed_storage()
//***************************************************************************
// Default constructor
//***************************************************************************
ETL_CONSTEXPR typed_storage() ETL_NOEXCEPT
: valid(false)
{
}
#if ETL_USING_CPP11
//***************************************************************************
/// Default destructor which will NOT call the destructor of the object which
/// was created by calling create().
/// Constructs the instance of T forwarding the given \p args to its
/// constructor.
//***************************************************************************
~typed_storage()
template <typename... TArgs>
typed_storage(TArgs&&... args) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
: valid(false)
{
create(etl::forward<TArgs>(args)...);
}
#else
//***************************************************************************
/// Constructs the instance of T with type T1
//***************************************************************************
template <typename T1>
typed_storage(const T1& t1)
: valid(false)
{
create(t1);
}
//***************************************************************************
/// Constructs the instance of T with types T1, T2
//***************************************************************************
template <typename T1, typename T2>
typed_storage(const T1& t1, const T2& t2)
: valid(false)
{
create(t1, t2);
}
//***************************************************************************
/// Constructs the instance of T with types T1, T2, T3
//***************************************************************************
template <typename T1, typename T2, typename T3>
typed_storage(const T1& t1, const T2& t2, const T3& t3)
: valid(false)
{
create(t1, t2, t3);
}
//***************************************************************************
/// Constructs the instance of T with types T1, T2, T3, T4
//***************************************************************************
template <typename T1, typename T2, typename T3, typename T4>
typed_storage(const T1& t1, const T2& t2, const T3& t3, const T4& t4)
: valid(false)
{
create(t1, t2, t3, t4);
}
#endif
//***************************************************************************
/// Default destructor which will NOT call the destructor of the object
/// which was created by calling create().
//***************************************************************************
~typed_storage() ETL_NOEXCEPT
{
// Intentionally empty.
}
//***************************************************************************
/// \returns <b>true</b> if object has been constructed using create().
/// \returns <b>false</b> otherwise.
//***************************************************************************
bool has_value() const
bool has_value() const ETL_NOEXCEPT
{
return valid;
}
#if ETL_USING_CPP11
//***************************************************************************
/// Constructs the instance of T forwarding the given \p args to its constructor and
/// asserts if has_value() is false.
///
/// \returns the instance of T which has been constructed in the internal byte array.
/// Constructs the instance of T forwarding the given \p args to its
/// constructor. \returns the instance of T which has been constructed in
/// the internal byte array.
//***************************************************************************
template<typename... Args>
reference create(Args&&... args)
template <typename... TArgs>
reference create(TArgs&&... args) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
{
ETL_ASSERT(!has_value(), ETL_ERROR(etl::typed_storage_error));
valid = true;
return *::new (data.template get_address<char>()) value_type(etl::forward<Args>(args)...);
pointer p = ::new (&storage.value) value_type(etl::forward<TArgs>(args)...);
valid = true;
return *p;
}
#else
//***************************************************************************
/// Constructs the instance of T with type T1
/// asserts if has_value() is false.
///
/// \returns the instance of T which has been constructed in the internal byte array.
/// \returns the instance of T which has been constructed in the internal
/// byte array.
//***************************************************************************
template<typename T1>
template <typename T1>
reference create(const T1& t1)
{
ETL_ASSERT(!has_value(), ETL_ERROR(etl::typed_storage_error));
valid = true;
return *::new (data.template get_address<char>()) value_type(t1);
pointer p = ::new (&storage.value) value_type(t1);
valid = true;
return *p;
}
//***************************************************************************
/// Constructs the instance of T with types T1, T2
/// asserts if has_value() is false.
///
/// \returns the instance of T which has been constructed in the internal byte array.
/// \returns the instance of T which has been constructed in the internal
/// byte array.
//***************************************************************************
template<typename T1, typename T2>
template <typename T1, typename T2>
reference create(const T1& t1, const T2& t2)
{
ETL_ASSERT(!has_value(), ETL_ERROR(etl::typed_storage_error));
valid = true;
return *::new (data.template get_address<char>()) value_type(t1, t2);
pointer p = ::new (&storage.value) value_type(t1, t2);
valid = true;
return *p;
}
//***************************************************************************
/// Constructs the instance of T with types T1, T2, T3
/// asserts if has_value() is false.
///
/// \returns the instance of T which has been constructed in the internal byte array.
/// \returns the instance of T which has been constructed in the internal
/// byte array.
//***************************************************************************
template<typename T1, typename T2, typename T3>
template <typename T1, typename T2, typename T3>
reference create(const T1& t1, const T2& t2, const T3& t3)
{
ETL_ASSERT(!has_value(), ETL_ERROR(etl::typed_storage_error));
valid = true;
return *::new (data.template get_address<char>()) value_type(t1, t2, t3);
pointer p = ::new (&storage.value) value_type(t1, t2, t3);
valid = true;
return *p;
}
//***************************************************************************
/// Constructs the instance of T with types T1, T2, T3, T4
/// asserts if has_value() is false.
///
/// \returns the instance of T which has been constructed in the internal byte array.
/// \returns the instance of T which has been constructed in the internal
/// byte array.
//***************************************************************************
template<typename T1, typename T2, typename T3, typename T4>
template <typename T1, typename T2, typename T3, typename T4>
reference create(const T1& t1, const T2& t2, const T3& t3, const T4& t4)
{
ETL_ASSERT(!has_value(), ETL_ERROR(etl::typed_storage_error));
valid = true;
return *::new (data.template get_address<char>()) value_type(t1, t2, t3, t4);
pointer p = ::new (&storage.value) value_type(t1, t2, t3, t4);
valid = true;
return *p;
}
#endif
//***************************************************************************
/// Calls the destructor of the wrapped object and asserts if has_value() is false.
/// Calls the destructor of the stored object, if created.
//***************************************************************************
void destroy()
void destroy() ETL_NOEXCEPT
{
ETL_ASSERT(has_value(), ETL_ERROR(etl::typed_storage_error));
data.template get_reference<T>().~T();
valid = false;
if (has_value())
{
storage.value.~T();
valid = false;
}
}
//***************************************************************************
/// \returns a pointer of type T and asserts if has_value() is false.
//***************************************************************************
pointer operator->()
pointer operator->() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
{
ETL_ASSERT(has_value(), ETL_ERROR(etl::typed_storage_error));
return data.template get_address<value_type>();
return &storage.value;
}
//***************************************************************************
/// \returns a const pointer of type T and asserts if has_value() is false.
//***************************************************************************
const_pointer operator->() const
const_pointer operator->() const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
{
return operator->();
ETL_ASSERT(has_value(), ETL_ERROR(etl::typed_storage_error));
return &storage.value;
}
//***************************************************************************
/// \returns reference of type T and asserts if has_value() is false.
//***************************************************************************
reference operator*()
reference operator*() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
{
return *operator->();
}
//***************************************************************************
/// \returns const reference of type T and asserts if has_value() is false.
/// \returns const_reference of type T and asserts if has_value() is false.
//***************************************************************************
const_reference operator*() const
const_reference operator*() const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
{
return *operator->();
}
private:
typename aligned_storage_as<sizeof(value_type), value_type>::type data;
typed_storage(etl::typed_storage<T>&) ETL_DELETE;
typed_storage& operator=(etl::typed_storage<T>&) ETL_DELETE;
struct dummy_t
{
};
//*******************************
union union_type
{
ETL_CONSTEXPR union_type() ETL_NOEXCEPT
: dummy()
{
}
~union_type() ETL_NOEXCEPT {}
dummy_t dummy;
value_type value;
} storage;
bool valid;
};
}
//***************************************************************************
/// Wrapper class wraps a supplied memory area and lets the user create an
/// instance of T in this memory at runtime. This class also erases the
/// destructor call of T, i.e. if typed_storage goes out of scope, the
/// destructor if the wrapped type will not be called. This can be done
/// explicitly by calling destroy().
/// \tparam T Type of element stored in this instance of typed_storage.
//***************************************************************************
template <typename T>
class typed_storage_ext
{
public:
typedef T value_type;
typedef T& reference;
typedef const T& const_reference;
typedef T* pointer;
typedef const T* const_pointer;
template <typename U>
friend ETL_CONSTEXPR14 void swap(typed_storage_ext<U>& lhs, typed_storage_ext<U>& rhs) ETL_NOEXCEPT;
//***************************************************************************
/// Constructor.
//***************************************************************************
typed_storage_ext(void* pbuffer_) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
: pbuffer(reinterpret_cast<T*>(pbuffer_))
, valid(false)
{
ETL_ASSERT(etl::is_aligned(pbuffer_, etl::alignment_of<T>::value), ETL_ERROR(etl::alignment_error));
}
#if ETL_USING_CPP11
//***************************************************************************
/// Constructs the instance of T forwarding the given \p args to its
/// constructor.
//***************************************************************************
template <typename... TArgs>
typed_storage_ext(void* pbuffer_, TArgs&&... args) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
: pbuffer(reinterpret_cast<T*>(pbuffer_))
, valid(false)
{
ETL_ASSERT(etl::is_aligned(pbuffer_, etl::alignment_of<T>::value), ETL_ERROR(etl::alignment_error));
create(etl::forward<TArgs>(args)...);
}
//***************************************************************************
/// Move constructor.
/// Transfers ownership of the buffer from \p other to this.
//***************************************************************************
typed_storage_ext(typed_storage_ext<T>&& other) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
: pbuffer(other.pbuffer)
, valid(other.valid)
{
other.pbuffer = ETL_NULLPTR;
other.valid = false;
}
#else
//***************************************************************************
/// Constructs the instance of T with type T1
//***************************************************************************
template <typename T1>
typed_storage_ext(void* pbuffer_, const T1& t1)
: pbuffer(reinterpret_cast<T*>(pbuffer_))
, valid(false)
{
ETL_ASSERT(etl::is_aligned(pbuffer_, etl::alignment_of<T>::value), ETL_ERROR(etl::alignment_error));
create(t1);
}
//***************************************************************************
/// Constructs the instance of T with types T1, T2
//***************************************************************************
template <typename T1, typename T2>
typed_storage_ext(void* pbuffer_, const T1& t1, const T2& t2)
: pbuffer(reinterpret_cast<T*>(pbuffer_))
, valid(false)
{
ETL_ASSERT(etl::is_aligned(pbuffer_, etl::alignment_of<T>::value), ETL_ERROR(etl::alignment_error));
create(t1, t2);
}
//***************************************************************************
/// Constructs the instance of T with types T1, T2, T3
//***************************************************************************
template <typename T1, typename T2, typename T3>
typed_storage_ext(void* pbuffer_, const T1& t1, const T2& t2, const T3& t3)
: pbuffer(reinterpret_cast<T*>(pbuffer_))
, valid(false)
{
ETL_ASSERT(etl::is_aligned(pbuffer_, etl::alignment_of<T>::value), ETL_ERROR(etl::alignment_error));
create(t1, t2, t3);
}
//***************************************************************************
/// Constructs the instance of T with types T1, T2, T3, T4
//***************************************************************************
template <typename T1, typename T2, typename T3, typename T4>
typed_storage_ext(void* pbuffer_, const T1& t1, const T2& t2, const T3& t3, const T4& t4)
: pbuffer(reinterpret_cast<T*>(pbuffer_))
, valid(false)
{
ETL_ASSERT(etl::is_aligned(pbuffer_, etl::alignment_of<T>::value), ETL_ERROR(etl::alignment_error));
create(t1, t2, t3, t4);
}
#endif
//***************************************************************************
/// Default destructor which will NOT call the destructor of the object
/// which was created by calling create().
//***************************************************************************
~typed_storage_ext() ETL_NOEXCEPT
{
// Intentionally empty.
}
//***************************************************************************
/// \returns <b>true</b> if object has been constructed using create().
/// \returns <b>false</b> otherwise.
//***************************************************************************
bool has_value() const ETL_NOEXCEPT
{
return valid;
}
#if ETL_USING_CPP11
//***************************************************************************
/// Constructs the instance of T forwarding the given \p args to its
/// constructor. \returns the instance of T which has been constructed in
/// the external buffer.
//***************************************************************************
template <typename... TArgs>
reference create(TArgs&&... args) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
{
ETL_ASSERT(!has_value(), ETL_ERROR(etl::typed_storage_error));
pointer p = ::new (pbuffer) value_type(etl::forward<TArgs>(args)...);
valid = true;
return *p;
}
#else
//***************************************************************************
/// Constructs the instance of T with type T1
/// \returns the instance of T which has been constructed in the external
/// buffer.
//***************************************************************************
template <typename T1>
reference create(const T1& t1)
{
ETL_ASSERT(!has_value(), ETL_ERROR(etl::typed_storage_error));
pointer p = ::new (pbuffer) value_type(t1);
valid = true;
return *p;
}
//***************************************************************************
/// Constructs the instance of T with types T1, T2
/// \returns the instance of T which has been constructed in the external
/// buffer.
//***************************************************************************
template <typename T1, typename T2>
reference create(const T1& t1, const T2& t2)
{
ETL_ASSERT(!has_value(), ETL_ERROR(etl::typed_storage_error));
pointer p = ::new (pbuffer) value_type(t1, t2);
valid = true;
return *p;
}
//***************************************************************************
/// Constructs the instance of T with types T1, T2, T3
/// \returns the instance of T which has been constructed in the external
/// buffer.
//***************************************************************************
template <typename T1, typename T2, typename T3>
reference create(const T1& t1, const T2& t2, const T3& t3)
{
ETL_ASSERT(!has_value(), ETL_ERROR(etl::typed_storage_error));
pointer p = ::new (pbuffer) value_type(t1, t2, t3);
valid = true;
return *p;
}
//***************************************************************************
/// Constructs the instance of T with types T1, T2, T3, T4
/// \returns the instance of T which has been constructed in the external
/// buffer.
//***************************************************************************
template <typename T1, typename T2, typename T3, typename T4>
reference create(const T1& t1, const T2& t2, const T3& t3, const T4& t4)
{
ETL_ASSERT(!has_value(), ETL_ERROR(etl::typed_storage_error));
pointer p = ::new (pbuffer) value_type(t1, t2, t3, t4);
valid = true;
return *p;
}
#endif
//***************************************************************************
/// Calls the destructor of the stored object, if created.
//***************************************************************************
void destroy() ETL_NOEXCEPT
{
if (has_value())
{
pbuffer->~T();
valid = false;
}
}
//***************************************************************************
/// \returns a pointer of type T and asserts if has_value() is false.
//***************************************************************************
pointer operator->() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
{
ETL_ASSERT(has_value(), ETL_ERROR(etl::typed_storage_error));
return pbuffer;
}
//***************************************************************************
/// \returns a const pointer of type T and asserts if has_value() is false.
//***************************************************************************
const_pointer operator->() const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
{
ETL_ASSERT(has_value(), ETL_ERROR(etl::typed_storage_error));
return pbuffer;
}
//***************************************************************************
/// \returns reference of type T and asserts if has_value() is false.
//***************************************************************************
reference operator*() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
{
return *operator->();
}
//***************************************************************************
/// \returns const_reference of type T and asserts if has_value() is false.
//***************************************************************************
const_reference operator*() const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
{
return *operator->();
}
private:
typed_storage_ext(etl::typed_storage_ext<T>&) ETL_DELETE;
typed_storage_ext& operator=(etl::typed_storage_ext<T>&) ETL_DELETE;
pointer pbuffer;
bool valid;
};
//***************************************************************************
/// Swap two etl::typed_storage_ext
//***************************************************************************
template <typename T>
ETL_CONSTEXPR14 void swap(etl::typed_storage_ext<T>& lhs, etl::typed_storage_ext<T>& rhs) ETL_NOEXCEPT
{
using ETL_OR_STD::swap;
swap(lhs.pbuffer, rhs.pbuffer);
swap(lhs.valid, rhs.valid);
}
} // namespace etl
#endif

File diff suppressed because it is too large Load Diff

View File

@ -32,18 +32,18 @@ SOFTWARE.
#define ETL_ARRAY_VIEW_INCLUDED
#include "platform.h"
#include "memory.h"
#include "algorithm.h"
#include "array.h"
#include "iterator.h"
#include "error_handler.h"
#include "exception.h"
#include "nullptr.h"
#include "hash.h"
#include "algorithm.h"
#include "iterator.h"
#include "memory.h"
#include "nullptr.h"
#include "type_traits.h"
#if ETL_USING_STL && ETL_USING_CPP11
#include <array>
#include <array>
#endif
///\defgroup array array
@ -93,6 +93,19 @@ namespace etl
}
};
//***************************************************************************
/// The exception thrown when the view is empty.
//***************************************************************************
class array_view_empty : public array_view_exception
{
public:
array_view_empty(string_type file_name_, numeric_type line_number_)
: array_view_exception(ETL_ERROR_TEXT("array_view:empty", ETL_ARRAY_VIEW_FILE_ID"C"), file_name_, line_number_)
{
}
};
//***************************************************************************
/// Array view.
//***************************************************************************
@ -101,31 +114,31 @@ namespace etl
{
public:
typedef T value_type;
typedef size_t size_type;
typedef const T& const_reference;
typedef const T* const_pointer;
typedef const T* const_iterator;
typedef T value_type;
typedef size_t size_type;
typedef const T& const_reference;
typedef const T* const_pointer;
typedef const T* const_iterator;
typedef ETL_OR_STD::reverse_iterator<const_iterator> const_reverse_iterator;
#if defined(ETL_ARRAY_VIEW_IS_MUTABLE)
typedef T* pointer;
typedef T& reference;
typedef T* iterator;
typedef T* pointer;
typedef T& reference;
typedef T* iterator;
typedef ETL_OR_STD::reverse_iterator<iterator> reverse_iterator;
#else
typedef const_pointer pointer;
typedef const_reference reference;
typedef const_pointer iterator;
typedef const_pointer pointer;
typedef const_reference reference;
typedef const_pointer iterator;
typedef const_reverse_iterator reverse_iterator;
#endif
//*************************************************************************
/// Default constructor.
//*************************************************************************
ETL_CONSTEXPR array_view()
: mbegin(ETL_NULLPTR),
mend(ETL_NULLPTR)
ETL_CONSTEXPR array_view() ETL_NOEXCEPT
: mbegin(ETL_NULLPTR)
, mend(ETL_NULLPTR)
{
}
@ -133,8 +146,9 @@ namespace etl
//*************************************************************************
/// Construct from etl::array.
//*************************************************************************
template <typename U, size_t N, typename = typename etl::enable_if<etl::is_same<etl::remove_cv_t<T>, etl::remove_cv_t<U>>::value, void>::type>
ETL_CONSTEXPR array_view(etl::array<U, N>& a) ETL_NOEXCEPT
template < typename U, size_t Size,
typename = typename etl::enable_if< etl::is_same<etl::remove_cv_t<T>, etl::remove_cv_t<U>>::value, void>::type>
ETL_CONSTEXPR array_view(etl::array<U, Size>& a) ETL_NOEXCEPT
: mbegin(a.data())
, mend(a.data() + a.size())
{
@ -143,8 +157,9 @@ namespace etl
//*************************************************************************
/// Construct from etl::array.
//*************************************************************************
template <typename U, size_t N, typename = typename etl::enable_if<etl::is_same<etl::remove_cv_t<T>, etl::remove_cv_t<U>>::value, void>::type>
ETL_CONSTEXPR array_view(const etl::array<U, N>& a) ETL_NOEXCEPT
template < typename U, size_t Size,
typename = typename etl::enable_if< etl::is_same<etl::remove_cv_t<T>, etl::remove_cv_t<U>>::value, void>::type>
ETL_CONSTEXPR array_view(const etl::array<U, Size>& a) ETL_NOEXCEPT
: mbegin(a.data())
, mend(a.data() + a.size())
{
@ -153,8 +168,10 @@ namespace etl
//*************************************************************************
/// Construct from etl::array.
//*************************************************************************
template <typename U, size_t N>
ETL_CONSTEXPR array_view(etl::array<U, N>& a, typename etl::enable_if<etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<U>::type>::value, void>::type* = 0) ETL_NOEXCEPT
template <typename U, size_t Size>
ETL_CONSTEXPR array_view(
etl::array<U, Size>& a,
typename etl::enable_if< etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<U>::type>::value, void>::type* = 0) ETL_NOEXCEPT
: mbegin(a.data())
, mend(a.data() + a.size())
{
@ -163,8 +180,10 @@ namespace etl
//*************************************************************************
/// Construct from etl::array.
//*************************************************************************
template <typename U, size_t N>
ETL_CONSTEXPR array_view(const etl::array<U, N>& a, typename etl::enable_if<etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<U>::type>::value, void>::type* = 0) ETL_NOEXCEPT
template <typename U, size_t Size>
ETL_CONSTEXPR array_view(
const etl::array<U, Size>& a,
typename etl::enable_if< etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<U>::type>::value, void>::type* = 0) ETL_NOEXCEPT
: mbegin(a.data())
, mend(a.data() + a.size())
{
@ -175,8 +194,9 @@ namespace etl
//*************************************************************************
/// Construct from std::array.
//*************************************************************************
template <typename U, size_t N, typename = typename etl::enable_if<etl::is_same<etl::remove_cv_t<T>, etl::remove_cv_t<U>>::value, void>::type>
ETL_CONSTEXPR array_view(std::array<U, N>& a) ETL_NOEXCEPT
template < typename U, size_t Size,
typename = typename etl::enable_if< etl::is_same<etl::remove_cv_t<T>, etl::remove_cv_t<U>>::value, void>::type>
ETL_CONSTEXPR array_view(std::array<U, Size>& a) ETL_NOEXCEPT
: mbegin(a.data())
, mend(a.data() + a.size())
{
@ -185,8 +205,9 @@ namespace etl
//*************************************************************************
/// Construct from std::array.
//*************************************************************************
template <typename U, size_t N, typename = typename etl::enable_if<etl::is_same<etl::remove_cv_t<T>, etl::remove_cv_t<U>>::value, void>::type>
ETL_CONSTEXPR array_view(const std::array<U, N>& a) ETL_NOEXCEPT
template < typename U, size_t Size,
typename = typename etl::enable_if< etl::is_same<etl::remove_cv_t<T>, etl::remove_cv_t<U>>::value, void>::type>
ETL_CONSTEXPR array_view(const std::array<U, Size>& a) ETL_NOEXCEPT
: mbegin(a.data())
, mend(a.data() + a.size())
{
@ -198,10 +219,12 @@ namespace etl
/// Construct from a container or other type that supports
/// data() and size() member functions.
//*************************************************************************
template <typename TContainer, typename = typename etl::enable_if<!etl::is_pointer<etl::remove_reference_t<TContainer>>::value &&
!etl::is_array<etl::remove_reference_t<TContainer>>::value &&
etl::is_same<etl::remove_cv_t<T>, etl::remove_cv_t<typename etl::remove_reference_t<TContainer>::value_type>>::value, void>::type>
ETL_CONSTEXPR array_view(TContainer&& a) ETL_NOEXCEPT
template < typename TContainer,
typename = typename etl::enable_if<
!etl::is_pointer<etl::remove_reference_t<TContainer>>::value && !etl::is_array<etl::remove_reference_t<TContainer>>::value
&& etl::is_same<etl::remove_cv_t<T>, etl::remove_cv_t<typename etl::remove_reference_t< TContainer>::value_type>>::value,
void>::type>
ETL_CONSTEXPR array_view(TContainer&& a) ETL_NOEXCEPT
: mbegin(a.data())
, mend(a.data() + a.size())
{
@ -212,9 +235,12 @@ namespace etl
/// data() and size() member functions.
//*************************************************************************
template <typename TContainer>
ETL_CONSTEXPR array_view(TContainer& a, typename etl::enable_if<!etl::is_pointer<typename etl::remove_reference<TContainer>::type>::value &&
!etl::is_array<TContainer>::value &&
etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<typename etl::remove_reference<TContainer>::type::value_type>::type>::value, void>::type* = 0) ETL_NOEXCEPT
ETL_CONSTEXPR array_view(TContainer& a,
typename etl::enable_if<
!etl::is_pointer< typename etl::remove_reference<TContainer>::type>::value && !etl::is_array<TContainer>::value
&& etl::is_same< typename etl::remove_cv<T>::type,
typename etl::remove_cv<typename etl::remove_reference< TContainer>::type::value_type>::type>::value,
void>::type* = 0) ETL_NOEXCEPT
: mbegin(a.data())
, mend(a.data() + a.size())
{
@ -225,9 +251,12 @@ namespace etl
/// data() and size() member functions.
//*************************************************************************
template <typename TContainer>
ETL_CONSTEXPR array_view(const TContainer& a, typename etl::enable_if<!etl::is_pointer<typename etl::remove_reference<TContainer>::type>::value &&
!etl::is_array<TContainer>::value &&
etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<typename etl::remove_reference<TContainer>::type::value_type>::type>::value, void>::type* = 0) ETL_NOEXCEPT
ETL_CONSTEXPR array_view(const TContainer& a,
typename etl::enable_if<
!etl::is_pointer< typename etl::remove_reference<TContainer>::type>::value && !etl::is_array<TContainer>::value
&& etl::is_same< typename etl::remove_cv<T>::type,
typename etl::remove_cv<typename etl::remove_reference< TContainer>::type::value_type>::type>::value,
void>::type* = 0) ETL_NOEXCEPT
: mbegin(a.data())
, mend(a.data() + a.size())
{
@ -238,78 +267,89 @@ namespace etl
/// Construct from iterators
//*************************************************************************
template <typename TIterator>
ETL_CONSTEXPR array_view(const TIterator begin_, const TIterator end_)
: mbegin(etl::to_address(begin_)),
mend(etl::to_address(begin_) + etl::distance(begin_, end_))
ETL_CONSTEXPR array_view(const TIterator begin_, const TIterator end_) ETL_NOEXCEPT
: mbegin(etl::to_address(begin_))
, mend(etl::to_address(begin_) + etl::distance(begin_, end_))
{
}
//*************************************************************************
/// Construct from iterator and size
//*************************************************************************
template <typename TIterator,
typename TSize>
ETL_CONSTEXPR array_view(const TIterator begin_, const TSize size_)
: mbegin(etl::to_address(begin_)),
mend(etl::to_address(begin_) + size_)
template <typename TIterator, typename TSize>
ETL_CONSTEXPR array_view(const TIterator begin_, const TSize size_) ETL_NOEXCEPT
: mbegin(etl::to_address(begin_))
, mend(etl::to_address(begin_) + size_)
{
}
//*************************************************************************
/// Construct from C array
//*************************************************************************
template<size_t Array_Size>
ETL_CONSTEXPR array_view(T(&begin_)[Array_Size])
: mbegin(begin_),
mend(begin_ + Array_Size)
template <size_t Array_Size>
ETL_CONSTEXPR array_view(T (&begin_)[Array_Size]) ETL_NOEXCEPT
: mbegin(begin_)
, mend(begin_ + Array_Size)
{
}
//*************************************************************************
/// Copy constructor
//*************************************************************************
ETL_CONSTEXPR array_view(const array_view& other)
: mbegin(other.mbegin),
mend(other.mend)
ETL_CONSTEXPR array_view(const array_view& other) ETL_NOEXCEPT
: mbegin(other.mbegin)
, mend(other.mend)
{
}
//*************************************************************************
/// Returns a reference to the first element.
/// If asserts or exceptions are enabled, throws an etl::array_view_empty if
/// the view is empty.
//*************************************************************************
reference front()
{
ETL_ASSERT_CHECK_EXTRA(!empty(), ETL_ERROR(array_view_empty));
return *mbegin;
}
//*************************************************************************
/// Returns a const reference to the first element.
/// If asserts or exceptions are enabled, throws an etl::array_view_empty if
/// the view is empty.
//*************************************************************************
const_reference front() const
{
ETL_ASSERT_CHECK_EXTRA(!empty(), ETL_ERROR(array_view_empty));
return *mbegin;
}
//*************************************************************************
/// Returns a reference to the last element.
/// If asserts or exceptions are enabled, throws an etl::array_view_empty if
/// the view is empty.
//*************************************************************************
reference back()
{
ETL_ASSERT_CHECK_EXTRA(!empty(), ETL_ERROR(array_view_empty));
return *(mend - 1);
}
//*************************************************************************
/// Returns a const reference to the last element.
/// If asserts or exceptions are enabled, throws an etl::array_view_empty if
/// the view is empty.
//*************************************************************************
const_reference back() const
{
ETL_ASSERT_CHECK_EXTRA(!empty(), ETL_ERROR(array_view_empty));
return *(mend - 1);
}
//*************************************************************************
/// Returns a pointer to the first element of the internal storage.
//*************************************************************************
pointer data()
pointer data() ETL_NOEXCEPT
{
return mbegin;
}
@ -317,7 +357,7 @@ namespace etl
//*************************************************************************
/// Returns a const pointer to the first element of the internal storage.
//*************************************************************************
const_pointer data() const
const_pointer data() const ETL_NOEXCEPT
{
return mbegin;
}
@ -325,7 +365,7 @@ namespace etl
//*************************************************************************
/// Returns an iterator to the beginning of the array.
//*************************************************************************
iterator begin()
iterator begin() ETL_NOEXCEPT
{
return mbegin;
}
@ -333,7 +373,7 @@ namespace etl
//*************************************************************************
/// Returns a const iterator to the beginning of the array.
//*************************************************************************
const_iterator begin() const
const_iterator begin() const ETL_NOEXCEPT
{
return mbegin;
}
@ -341,7 +381,7 @@ namespace etl
//*************************************************************************
/// Returns a const iterator to the beginning of the array.
//*************************************************************************
const_iterator cbegin() const
const_iterator cbegin() const ETL_NOEXCEPT
{
return mbegin;
}
@ -349,7 +389,7 @@ namespace etl
//*************************************************************************
/// Returns an iterator to the end of the array.
//*************************************************************************
iterator end()
iterator end() ETL_NOEXCEPT
{
return mend;
}
@ -357,7 +397,7 @@ namespace etl
//*************************************************************************
/// Returns a const iterator to the end of the array.
//*************************************************************************
const_iterator end() const
const_iterator end() const ETL_NOEXCEPT
{
return mend;
}
@ -365,7 +405,7 @@ namespace etl
//*************************************************************************
// Returns a const iterator to the end of the array.
//*************************************************************************
const_iterator cend() const
const_iterator cend() const ETL_NOEXCEPT
{
return mend;
}
@ -373,7 +413,7 @@ namespace etl
//*************************************************************************
// Returns an reverse iterator to the reverse beginning of the array.
//*************************************************************************
reverse_iterator rbegin()
reverse_iterator rbegin() ETL_NOEXCEPT
{
return reverse_iterator(mend);
}
@ -381,7 +421,7 @@ namespace etl
//*************************************************************************
/// Returns a const reverse iterator to the reverse beginning of the array.
//*************************************************************************
const_reverse_iterator rbegin() const
const_reverse_iterator rbegin() const ETL_NOEXCEPT
{
return const_reverse_iterator(mend);
}
@ -389,7 +429,7 @@ namespace etl
//*************************************************************************
/// Returns a const reverse iterator to the reverse beginning of the array.
//*************************************************************************
const_reverse_iterator crbegin() const
const_reverse_iterator crbegin() const ETL_NOEXCEPT
{
return const_reverse_iterator(mend);
}
@ -397,7 +437,7 @@ namespace etl
//*************************************************************************
/// Returns a reverse iterator to the end of the array.
//*************************************************************************
reverse_iterator rend()
reverse_iterator rend() ETL_NOEXCEPT
{
return reverse_iterator(mbegin);
}
@ -405,7 +445,7 @@ namespace etl
//*************************************************************************
/// Returns a const reverse iterator to the end of the array.
//*************************************************************************
const_reverse_iterator rend() const
const_reverse_iterator rend() const ETL_NOEXCEPT
{
return const_reverse_iterator(mbegin);
}
@ -413,7 +453,7 @@ namespace etl
//*************************************************************************
/// Returns a const reverse iterator to the end of the array.
//*************************************************************************
const_reverse_iterator crend() const
const_reverse_iterator crend() const ETL_NOEXCEPT
{
return const_reverse_iterator(mbegin);
}
@ -421,7 +461,7 @@ namespace etl
//*************************************************************************
/// Returns <b>true</b> if the array size is zero.
//*************************************************************************
ETL_CONSTEXPR bool empty() const
ETL_CONSTEXPR bool empty() const ETL_NOEXCEPT
{
return (mbegin == mend);
}
@ -429,7 +469,7 @@ namespace etl
//*************************************************************************
/// Returns the size of the array.
//*************************************************************************
ETL_CONSTEXPR size_t size() const
ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT
{
return static_cast<size_t>(mend - mbegin);
}
@ -437,7 +477,7 @@ namespace etl
//*************************************************************************
/// Returns the maximum possible size of the array.
//*************************************************************************
ETL_CONSTEXPR size_t max_size() const
ETL_CONSTEXPR size_t max_size() const ETL_NOEXCEPT
{
return size();
}
@ -445,7 +485,7 @@ namespace etl
//*************************************************************************
/// Assign from a view.
//*************************************************************************
array_view& operator=(const array_view& other)
array_view& operator=(const array_view& other) ETL_NOEXCEPT
{
mbegin = other.mbegin;
mend = other.mend;
@ -465,8 +505,7 @@ namespace etl
//*************************************************************************
/// Assign from iterator and size.
//*************************************************************************
template <typename TIterator,
typename TSize>
template <typename TIterator, typename TSize>
void assign(const TIterator begin_, const TSize size_)
{
mbegin = etl::to_address(begin_);
@ -476,18 +515,26 @@ namespace etl
#if defined(ETL_ARRAY_VIEW_IS_MUTABLE)
//*************************************************************************
/// Returns a reference to the indexed value.
/// If asserts or exceptions are enabled, throws an etl::array_view_bounds
/// if the index is out of bounds.
//*************************************************************************
reference operator[](const size_t i)
reference operator[](const size_t i) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_INDEX_OPERATOR)
{
ETL_ASSERT_CHECK_INDEX_OPERATOR(i < size(), ETL_ERROR(array_view_bounds));
return mbegin[i];
}
#endif
//*************************************************************************
/// Returns a const reference to the indexed value.
/// If asserts or exceptions are enabled, throws an etl::array_view_bounds
/// if the index is out of bounds.
//*************************************************************************
const_reference operator[](const size_t i) const
const_reference operator[](const size_t i) const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_INDEX_OPERATOR)
{
ETL_ASSERT_CHECK_INDEX_OPERATOR(i < size(), ETL_ERROR(array_view_bounds));
return mbegin[i];
}
@ -516,7 +563,7 @@ namespace etl
//*************************************************************************
/// Swaps with another array_view.
//*************************************************************************
void swap(array_view& other)
void swap(array_view& other) ETL_NOEXCEPT
{
using ETL_OR_STD::swap; // Allow ADL
@ -527,23 +574,23 @@ namespace etl
//*************************************************************************
/// Shrinks the view by moving its start forward.
//*************************************************************************
void remove_prefix(const size_type n)
void remove_prefix(const size_type n) ETL_NOEXCEPT
{
if (n < size())
mbegin += n;
else
mbegin = mend;
if (n < size())
mbegin += n;
else
mbegin = mend;
}
//*************************************************************************
/// Shrinks the view by moving its end backward.
//*************************************************************************
void remove_suffix(const size_type n)
void remove_suffix(const size_type n) ETL_NOEXCEPT
{
if (n < size())
mend -= n;
else
mend = mbegin;
if (n < size())
mend -= n;
else
mend = mbegin;
}
//*************************************************************************
@ -557,16 +604,15 @@ namespace etl
//*************************************************************************
/// Equality for array views.
//*************************************************************************
friend bool operator == (const array_view<T>& lhs, const array_view<T>& rhs)
friend bool operator==(const array_view<T>& lhs, const array_view<T>& rhs)
{
return (lhs.size() == rhs.size()) &&
etl::equal(lhs.begin(), lhs.end(), rhs.begin());
return (lhs.size() == rhs.size()) && etl::equal(lhs.begin(), lhs.end(), rhs.begin());
}
//*************************************************************************
/// Inequality for array views.
//*************************************************************************
friend bool operator != (const array_view<T>& lhs, const array_view<T>& rhs)
friend bool operator!=(const array_view<T>& lhs, const array_view<T>& rhs)
{
return !(lhs == rhs);
}
@ -574,7 +620,7 @@ namespace etl
//*************************************************************************
/// Less-than for array views.
//*************************************************************************
friend bool operator < (const array_view<T>& lhs, const array_view<T>& rhs)
friend bool operator<(const array_view<T>& lhs, const array_view<T>& rhs)
{
return etl::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
}
@ -582,7 +628,7 @@ namespace etl
//*************************************************************************
/// Greater-than for array views.
//*************************************************************************
friend bool operator > (const array_view<T>& lhs, const array_view<T>& rhs)
friend bool operator>(const array_view<T>& lhs, const array_view<T>& rhs)
{
return rhs < lhs;
}
@ -590,7 +636,7 @@ namespace etl
//*************************************************************************
/// Less-than-equal for array views.
//*************************************************************************
friend bool operator <= (const array_view<T>& lhs, const array_view<T>& rhs)
friend bool operator<=(const array_view<T>& lhs, const array_view<T>& rhs)
{
return !(lhs > rhs);
}
@ -598,7 +644,7 @@ namespace etl
//*************************************************************************
/// Greater-than-equal for array views.
//*************************************************************************
friend bool operator >= (const array_view<T>& lhs, const array_view<T>& rhs)
friend bool operator>=(const array_view<T>& lhs, const array_view<T>& rhs)
{
return !(lhs < rhs);
}
@ -614,18 +660,14 @@ namespace etl
//*************************************************************************
#if ETL_USING_CPP17
template <typename TArray>
array_view(TArray& a)
-> array_view<typename TArray::value_type>;
array_view(TArray& a) -> array_view<typename TArray::value_type>;
template <typename TIterator>
array_view(const TIterator begin_, const TIterator end_)
-> array_view<etl::remove_pointer_t<TIterator>>;
array_view(const TIterator begin_, const TIterator end_) -> array_view<etl::remove_pointer_t<TIterator>>;
template <typename TIterator,
typename TSize>
array_view(const TIterator begin_, const TSize size_)
-> array_view<etl::remove_pointer_t<TIterator>>;
#endif
template <typename TIterator, typename TSize>
array_view(const TIterator begin_, const TSize size_) -> array_view<etl::remove_pointer_t<TIterator>>;
#endif
//*************************************************************************
/// Hash function.
@ -641,13 +683,13 @@ namespace etl
}
};
#endif
}
} // namespace etl
//*************************************************************************
/// Swaps the values.
//*************************************************************************
template <typename T>
void swap(etl::array_view<T>& lhs, etl::array_view<T>& rhs)
void swap(etl::array_view<T>& lhs, etl::array_view<T>& rhs) ETL_NOEXCEPT
{
lhs.swap(rhs);
}

View File

@ -32,12 +32,12 @@ SOFTWARE.
#define ETL_ARRAY_WRAPPER_INCLUDED
#include "platform.h"
#include "iterator.h"
#include "algorithm.h"
#include "error_handler.h"
#include "exception.h"
#include "hash.h"
#include "iterator.h"
#include "parameter_type.h"
#include "algorithm.h"
///\defgroup array array
/// A wrapper for arrays
@ -75,19 +75,19 @@ namespace etl
//***************************************************************************
/// Array wrapper.
//***************************************************************************
template <typename T, size_t SIZE_, T(&ARRAY_)[SIZE_]>
template <typename T, size_t SIZE_, T (&ARRAY_)[SIZE_]>
class array_wrapper
{
public:
typedef T value_type;
typedef size_t size_type;
typedef T& reference;
typedef const T& const_reference;
typedef T* pointer;
typedef const T* const_pointer;
typedef T* iterator;
typedef const T* const_iterator;
typedef T value_type;
typedef size_t size_type;
typedef T& reference;
typedef const T& const_reference;
typedef T* pointer;
typedef const T* const_pointer;
typedef T* iterator;
typedef const T* const_iterator;
typedef ETL_OR_STD::reverse_iterator<iterator> reverse_iterator;
typedef ETL_OR_STD::reverse_iterator<const_iterator> const_reverse_iterator;
@ -141,7 +141,7 @@ namespace etl
//*************************************************************************
/// Returns a pointer to the first element of the internal storage.
//*************************************************************************
pointer data()
pointer data() ETL_NOEXCEPT
{
return &ARRAY_[BEGIN];
}
@ -149,7 +149,7 @@ namespace etl
//*************************************************************************
/// Returns a const pointer to the first element of the internal storage.
//*************************************************************************
ETL_CONSTEXPR const_pointer data() const
ETL_CONSTEXPR const_pointer data() const ETL_NOEXCEPT
{
return &ARRAY_[BEGIN];
}
@ -157,7 +157,7 @@ namespace etl
//*************************************************************************
/// Returns an iterator to the beginning of the array.
//*************************************************************************
iterator begin()
iterator begin() ETL_NOEXCEPT
{
return &ARRAY_[BEGIN];
}
@ -165,7 +165,7 @@ namespace etl
//*************************************************************************
/// Returns a const iterator to the beginning of the array.
//*************************************************************************
ETL_CONSTEXPR const_iterator begin() const
ETL_CONSTEXPR const_iterator begin() const ETL_NOEXCEPT
{
return &ARRAY_[BEGIN];
}
@ -173,7 +173,7 @@ namespace etl
//*************************************************************************
/// Returns a const iterator to the beginning of the array.
//*************************************************************************
ETL_CONSTEXPR const_iterator cbegin() const
ETL_CONSTEXPR const_iterator cbegin() const ETL_NOEXCEPT
{
return &ARRAY_[BEGIN];
}
@ -181,7 +181,7 @@ namespace etl
//*************************************************************************
/// Returns an iterator to the end of the array.
//*************************************************************************
iterator end()
iterator end() ETL_NOEXCEPT
{
return &ARRAY_[END];
}
@ -189,7 +189,7 @@ namespace etl
//*************************************************************************
/// Returns a const iterator to the end of the array.
//*************************************************************************
ETL_CONSTEXPR const_iterator end() const
ETL_CONSTEXPR const_iterator end() const ETL_NOEXCEPT
{
return &ARRAY_[END];
}
@ -197,7 +197,7 @@ namespace etl
//*************************************************************************
// Returns a const iterator to the end of the array.
//*************************************************************************
ETL_CONSTEXPR const_iterator cend() const
ETL_CONSTEXPR const_iterator cend() const ETL_NOEXCEPT
{
return &ARRAY_[END];
}
@ -205,7 +205,7 @@ namespace etl
//*************************************************************************
// Returns an reverse iterator to the reverse beginning of the array.
//*************************************************************************
reverse_iterator rbegin()
reverse_iterator rbegin() ETL_NOEXCEPT
{
return reverse_iterator(&ARRAY_[END]);
}
@ -213,7 +213,7 @@ namespace etl
//*************************************************************************
/// Returns a const reverse iterator to the reverse beginning of the array.
//*************************************************************************
ETL_CONSTEXPR const_reverse_iterator rbegin() const
ETL_CONSTEXPR const_reverse_iterator rbegin() const ETL_NOEXCEPT
{
return const_reverse_iterator(&ARRAY_[END]);
}
@ -221,7 +221,7 @@ namespace etl
//*************************************************************************
/// Returns a const reverse iterator to the reverse beginning of the array.
//*************************************************************************
ETL_CONSTEXPR const_reverse_iterator crbegin() const
ETL_CONSTEXPR const_reverse_iterator crbegin() const ETL_NOEXCEPT
{
return const_reverse_iterator(&ARRAY_[END]);
}
@ -229,7 +229,7 @@ namespace etl
//*************************************************************************
/// Returns a reverse iterator to the end of the array.
//*************************************************************************
reverse_iterator rend()
reverse_iterator rend() ETL_NOEXCEPT
{
return reverse_iterator(&ARRAY_[BEGIN]);
}
@ -237,7 +237,7 @@ namespace etl
//*************************************************************************
/// Returns a const reverse iterator to the end of the array.
//*************************************************************************
ETL_CONSTEXPR const_reverse_iterator rend() const
ETL_CONSTEXPR const_reverse_iterator rend() const ETL_NOEXCEPT
{
return const_reverse_iterator(&ARRAY_[BEGIN]);
}
@ -245,7 +245,7 @@ namespace etl
//*************************************************************************
/// Returns a const reverse iterator to the end of the array.
//*************************************************************************
ETL_CONSTEXPR const_reverse_iterator crend() const
ETL_CONSTEXPR const_reverse_iterator crend() const ETL_NOEXCEPT
{
return const_reverse_iterator(&ARRAY_[BEGIN]);
}
@ -253,7 +253,7 @@ namespace etl
//*************************************************************************
/// Returns the size of the array.
//*************************************************************************
ETL_CONSTEXPR size_t size() const
ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT
{
return SIZE;
}
@ -261,25 +261,36 @@ namespace etl
//*************************************************************************
/// Returns the maximum possible size of the array.
//*************************************************************************
ETL_CONSTEXPR size_t max_size() const
ETL_CONSTEXPR size_t max_size() const ETL_NOEXCEPT
{
return MAX_SIZE;
}
//*************************************************************************
/// Returns a reference to the indexed value.
/// If asserts or exceptions are enabled, throws an
/// etl::array_wrapper_bounds if the index is out of bounds.
//*************************************************************************
reference operator[](size_t i)
reference operator[](size_t i) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_INDEX_OPERATOR)
{
ETL_ASSERT_CHECK_INDEX_OPERATOR(i < SIZE, ETL_ERROR(etl::array_wrapper_bounds));
return ARRAY_[i];
}
//*************************************************************************
/// Returns a const reference to the indexed value.
/// If asserts or exceptions are enabled, throws an
/// etl::array_wrapper_bounds if the index is out of bounds.
//*************************************************************************
ETL_CONSTEXPR const_reference operator[](size_t i) const
ETL_CONSTEXPR const_reference operator[](size_t i) const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_INDEX_OPERATOR)
{
// Throwing from c++11 constexpr requires special syntax
#if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_INDEX_OPERATOR
return i < SIZE ? ARRAY_[i] : throw(ETL_ERROR(etl::array_wrapper_bounds));
#else
ETL_ASSERT_CHECK_INDEX_OPERATOR(i < SIZE, ETL_ERROR(etl::array_wrapper_bounds));
return ARRAY_[i];
#endif
}
//*************************************************************************
@ -311,9 +322,8 @@ namespace etl
//*************************************************************************
/// Swaps the contents of arrays.
//*************************************************************************
template <typename U, U(&ARRAYOTHER)[SIZE_]>
typename etl::enable_if<etl::is_same<T, U>::value, void>::type
swap(etl::array_wrapper<U, SIZE_, ARRAYOTHER>& other)
template <typename U, U (&ARRAYOTHER)[SIZE_]>
typename etl::enable_if<etl::is_same<T, U>::value, void>::type swap(etl::array_wrapper<U, SIZE_, ARRAYOTHER>& other)
{
using ETL_OR_STD::swap; // Allow ADL
@ -327,9 +337,8 @@ namespace etl
//*************************************************************************
/// Equality for array wrappers.
//*************************************************************************
template <typename TL, typename TR, size_t SIZEL, size_t SIZER, TL(&ARRAYL)[SIZEL], TR(&ARRAYR)[SIZER]>
bool operator == (const etl::array_wrapper<TL, SIZEL, ARRAYL>& lhs,
const etl::array_wrapper<TR, SIZER, ARRAYR>& rhs)
template <typename TL, typename TR, size_t SIZEL, size_t SIZER, TL (&ARRAYL)[SIZEL], TR (&ARRAYR)[SIZER]>
bool operator==(const etl::array_wrapper<TL, SIZEL, ARRAYL>& lhs, const etl::array_wrapper<TR, SIZER, ARRAYR>& rhs)
{
return (SIZEL == SIZER) && etl::equal(lhs.begin(), lhs.end(), rhs.begin());
}
@ -337,9 +346,8 @@ namespace etl
//*************************************************************************
/// Inequality for array wrapper.
//*************************************************************************
template <typename TL, typename TR, size_t SIZEL, size_t SIZER, TL(&ARRAYL)[SIZEL], TR(&ARRAYR)[SIZER]>
bool operator != (const etl::array_wrapper<TL, SIZEL, ARRAYL>& lhs,
const etl::array_wrapper<TR, SIZER, ARRAYR>& rhs)
template <typename TL, typename TR, size_t SIZEL, size_t SIZER, TL (&ARRAYL)[SIZEL], TR (&ARRAYR)[SIZER]>
bool operator!=(const etl::array_wrapper<TL, SIZEL, ARRAYL>& lhs, const etl::array_wrapper<TR, SIZER, ARRAYR>& rhs)
{
return !(lhs == rhs);
}
@ -347,9 +355,8 @@ namespace etl
//*************************************************************************
/// Less-than for array wrapper.
//*************************************************************************
template <typename TL, typename TR, size_t SIZEL, size_t SIZER, TL(&ARRAYL)[SIZEL], TR(&ARRAYR)[SIZER]>
bool operator < (const etl::array_wrapper<TL, SIZEL, ARRAYL>& lhs,
const etl::array_wrapper<TR, SIZER, ARRAYR>& rhs)
template <typename TL, typename TR, size_t SIZEL, size_t SIZER, TL (&ARRAYL)[SIZEL], TR (&ARRAYR)[SIZER]>
bool operator<(const etl::array_wrapper<TL, SIZEL, ARRAYL>& lhs, const etl::array_wrapper<TR, SIZER, ARRAYR>& rhs)
{
return etl::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
}
@ -357,9 +364,8 @@ namespace etl
//*************************************************************************
/// Greater-than for array wrapper.
//*************************************************************************
template <typename TL, typename TR, size_t SIZEL, size_t SIZER, TL(&ARRAYL)[SIZEL], TR(&ARRAYR)[SIZER]>
bool operator > (const etl::array_wrapper<TL, SIZEL, ARRAYL>& lhs,
const etl::array_wrapper<TR, SIZER, ARRAYR>& rhs)
template <typename TL, typename TR, size_t SIZEL, size_t SIZER, TL (&ARRAYL)[SIZEL], TR (&ARRAYR)[SIZER]>
bool operator>(const etl::array_wrapper<TL, SIZEL, ARRAYL>& lhs, const etl::array_wrapper<TR, SIZER, ARRAYR>& rhs)
{
return rhs < lhs;
}
@ -367,9 +373,8 @@ namespace etl
//*************************************************************************
/// Less-than-equal for array wrapper.
//*************************************************************************
template <typename TL, typename TR, size_t SIZEL, size_t SIZER, TL(&ARRAYL)[SIZEL], TR(&ARRAYR)[SIZER]>
bool operator <= (const etl::array_wrapper<TL, SIZEL, ARRAYL>& lhs,
const etl::array_wrapper<TR, SIZER, ARRAYR>& rhs)
template <typename TL, typename TR, size_t SIZEL, size_t SIZER, TL (&ARRAYL)[SIZEL], TR (&ARRAYR)[SIZER]>
bool operator<=(const etl::array_wrapper<TL, SIZEL, ARRAYL>& lhs, const etl::array_wrapper<TR, SIZER, ARRAYR>& rhs)
{
return !(lhs > rhs);
}
@ -377,9 +382,8 @@ namespace etl
//*************************************************************************
/// Greater-than-equal for array wrapper.
//*************************************************************************
template <typename TL, typename TR, size_t SIZEL, size_t SIZER, TL(&ARRAYL)[SIZEL], TR(&ARRAYR)[SIZER]>
bool operator >= (const etl::array_wrapper<TL, SIZEL, ARRAYL>& lhs,
const etl::array_wrapper<TR, SIZER, ARRAYR>& rhs)
template <typename TL, typename TR, size_t SIZEL, size_t SIZER, TL (&ARRAYL)[SIZEL], TR (&ARRAYR)[SIZER]>
bool operator>=(const etl::array_wrapper<TL, SIZEL, ARRAYL>& lhs, const etl::array_wrapper<TR, SIZER, ARRAYR>& rhs)
{
return !(lhs < rhs);
}
@ -388,7 +392,7 @@ namespace etl
/// Hash function.
//*************************************************************************
#if ETL_USING_8BIT_TYPES
template <typename T, size_t SIZE, T(&ARRAY)[SIZE]>
template <typename T, size_t SIZE, T (&ARRAY)[SIZE]>
struct hash<etl::array_wrapper<T, SIZE, ARRAY> >
{
size_t operator()(const etl::array_wrapper<T, SIZE, ARRAY>& aw) const
@ -400,19 +404,17 @@ namespace etl
}
};
#endif
}
} // namespace etl
//*************************************************************************
/// Swap.
//*************************************************************************
template <typename T, 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)
template <typename T, 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)
{
lhs.swap(rhs);
}
#define ETL_ARRAY_WRAPPER(arraytype, arrayobject) etl::array_wrapper<arraytype, ETL_ARRAY_SIZE(arrayobject), arrayobject>
#define ETL_ARRAY_WRAPPER(arraytype, arrayobject) etl::array_wrapper<arraytype, ETL_ARRAY_SIZE(arrayobject), arrayobject>
#endif

View File

@ -32,7 +32,7 @@ SOFTWARE.
#include "platform.h"
#if ETL_HAS_ATOMIC
#if (ETL_USING_CPP11 && (ETL_USING_STL || defined(ETL_IN_UNIT_TEST)))
#if (ETL_USING_CPP11 && (ETL_USING_STL || defined(ETL_IN_UNIT_TEST)))
#include "atomic/atomic_std.h"
#elif defined(ETL_COMPILER_ARM5)
#include "atomic/atomic_arm.h"

File diff suppressed because it is too large Load Diff

View File

@ -30,8 +30,8 @@ SOFTWARE.
#define ETL_ATOMIC_STD_INCLUDED
#include "../platform.h"
#include "../nullptr.h"
#include "../char_traits.h"
#include "../nullptr.h"
#include <atomic>
#include <stdint.h>
@ -55,39 +55,39 @@ namespace etl
static ETL_CONSTANT etl::memory_order memory_order_acq_rel = std::memory_order_acq_rel;
static ETL_CONSTANT etl::memory_order memory_order_seq_cst = std::memory_order_seq_cst;
using atomic_bool = std::atomic<bool>;
using atomic_char = std::atomic<char>;
using atomic_schar = std::atomic<signed char>;
using atomic_uchar = std::atomic<unsigned char>;
using atomic_short = std::atomic<short>;
using atomic_ushort = std::atomic<unsigned short>;
using atomic_int = std::atomic<int>;
using atomic_uint = std::atomic<unsigned int>;
using atomic_long = std::atomic<long>;
using atomic_ulong = std::atomic<unsigned long>;
using atomic_llong = std::atomic<long long>;
using atomic_ullong = std::atomic<unsigned long long>;
using atomic_wchar_t = std::atomic<wchar_t>;
using atomic_bool = std::atomic<bool>;
using atomic_char = std::atomic<char>;
using atomic_schar = std::atomic<signed char>;
using atomic_uchar = std::atomic<unsigned char>;
using atomic_short = std::atomic<short>;
using atomic_ushort = std::atomic<unsigned short>;
using atomic_int = std::atomic<int>;
using atomic_uint = std::atomic<unsigned int>;
using atomic_long = std::atomic<long>;
using atomic_ulong = std::atomic<unsigned long>;
using atomic_llong = std::atomic<long long>;
using atomic_ullong = std::atomic<unsigned long long>;
using atomic_wchar_t = std::atomic<wchar_t>;
#if ETL_HAS_NATIVE_CHAR8_T
using atomic_char8_t = std::atomic<char8_t>;
#endif
#if ETL_HAS_NATIVE_CHAR16_T
using atomic_char16_t = std::atomic<char16_t>;
using atomic_char16_t = std::atomic<char16_t>;
#endif
#if ETL_HAS_NATIVE_CHAR32_T
using atomic_char32_t = std::atomic<char32_t>;
using atomic_char32_t = std::atomic<char32_t>;
#endif
#if ETL_USING_8BIT_TYPES
using atomic_uint8_t = std::atomic<uint8_t>;
using atomic_int8_t = std::atomic<int8_t>;
using atomic_uint8_t = std::atomic<uint8_t>;
using atomic_int8_t = std::atomic<int8_t>;
#endif
using atomic_uint16_t = std::atomic<uint16_t>;
using atomic_int16_t = std::atomic<int16_t>;
using atomic_uint32_t = std::atomic<uint32_t>;
using atomic_int32_t = std::atomic<int32_t>;
using atomic_uint16_t = std::atomic<uint16_t>;
using atomic_int16_t = std::atomic<int16_t>;
using atomic_uint32_t = std::atomic<uint32_t>;
using atomic_int32_t = std::atomic<int32_t>;
#if ETL_USING_64BIT_TYPES
using atomic_uint64_t = std::atomic<uint64_t>;
using atomic_int64_t = std::atomic<int64_t>;
using atomic_uint64_t = std::atomic<uint64_t>;
using atomic_int64_t = std::atomic<int64_t>;
#endif
using atomic_int_least8_t = std::atomic<int_least8_t>;
using atomic_uint_least8_t = std::atomic<uint_least8_t>;
@ -99,22 +99,22 @@ namespace etl
using atomic_int_least64_t = std::atomic<int_least64_t>;
using atomic_uint_least64_t = std::atomic<uint_least64_t>;
#endif
using atomic_int_fast8_t = std::atomic<int_fast8_t>;
using atomic_uint_fast8_t = std::atomic<uint_fast8_t>;
using atomic_int_fast16_t = std::atomic<int_fast16_t>;
using atomic_uint_fast16_t = std::atomic<uint_fast16_t>;
using atomic_int_fast32_t = std::atomic<int_fast32_t>;
using atomic_uint_fast32_t = std::atomic<uint_fast32_t>;
using atomic_int_fast8_t = std::atomic<int_fast8_t>;
using atomic_uint_fast8_t = std::atomic<uint_fast8_t>;
using atomic_int_fast16_t = std::atomic<int_fast16_t>;
using atomic_uint_fast16_t = std::atomic<uint_fast16_t>;
using atomic_int_fast32_t = std::atomic<int_fast32_t>;
using atomic_uint_fast32_t = std::atomic<uint_fast32_t>;
#if ETL_USING_64BIT_TYPES
using atomic_int_fast64_t = std::atomic<int_fast64_t>;
using atomic_uint_fast64_t = std::atomic<uint_fast64_t>;
using atomic_int_fast64_t = std::atomic<int_fast64_t>;
using atomic_uint_fast64_t = std::atomic<uint_fast64_t>;
#endif
using atomic_intptr_t = std::atomic<intptr_t>;
using atomic_uintptr_t = std::atomic<uintptr_t>;
using atomic_size_t = std::atomic<size_t>;
using atomic_ptrdiff_t = std::atomic<ptrdiff_t>;
using atomic_intmax_t = std::atomic<intmax_t>;
using atomic_uintmax_t = std::atomic<uintmax_t>;
}
using atomic_intptr_t = std::atomic<intptr_t>;
using atomic_uintptr_t = std::atomic<uintptr_t>;
using atomic_size_t = std::atomic<size_t>;
using atomic_ptrdiff_t = std::atomic<ptrdiff_t>;
using atomic_intmax_t = std::atomic<intmax_t>;
using atomic_uintmax_t = std::atomic<uintmax_t>;
} // namespace etl
#endif

View File

@ -27,27 +27,29 @@ SOFTWARE.
#define ETL_BASE64_INCLUDED
#include "platform.h"
#include "static_assert.h"
#include "exception.h"
#include "error_handler.h"
#include "type_traits.h"
#include "enum_type.h"
#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
*
* Encoding Encoding characters Separate encoding of lines Decoding non-encoding characters
* 62nd 63rd Pad Separators Length Checksum
* RFC 1421 : Base64 for Privacy - Enhanced Mail(deprecated) + / = mandatory CR + LF 64, or lower for the last line No No
* RFC 2045 : Base64 transfer encoding for MIME + / = mandatory CR + LF At most 76 No Discarded
* RFC 2152 : Base64 for UTF - 7 + / No No No
* RFC 3501 : Base64 encoding for IMAP mailbox names + , No No No
* RFC 4648 : base64(standard)[a] + / = optional No No
* RFC 4648 : base64url(URL - and filename - safe standard) - _ = optional No No
**************************************************************************************************************************************************************************/
* See https://en.wikipedia.org/wiki/Base64
*
* Encoding Encoding characters
*Separate encoding of lines Decoding non-encoding characters 62nd 63rd Pad
*Separators Length Checksum RFC 1421 : Base64 for
*Privacy - Enhanced Mail(deprecated) + / = mandatory CR + LF 64,
*or lower for the last line No No RFC 2045 : Base64 transfer encoding for MIME
*+ / = mandatory CR + LF At most 76 No Discarded RFC 2152 : Base64
*for UTF - 7 + / No No No RFC
*3501 : Base64 encoding for IMAP mailbox names + , No
*No No RFC 4648 : base64(standard)[a] + / = optional No No RFC 4648 :
*base64url(URL - and filename - safe standard) - _ = optional No No
**************************************************************************************************************************************************************************/
namespace etl
{
@ -114,8 +116,8 @@ namespace etl
{
enum enum_type
{
//RFC_1421, // Not implemented
//RFC_2045, // Not implemented
// RFC_1421, // Not implemented
// RFC_2045, // Not implemented
RFC_2152,
RFC_3501,
RFC_4648,
@ -125,8 +127,8 @@ namespace etl
};
ETL_DECLARE_ENUM_TYPE(Encoding, int)
//ETL_ENUM_TYPE(RFC_1421, "RFC_1421") // Not implemented
//ETL_ENUM_TYPE(RFC_2045, "RFC_2045") // Not implemented
// ETL_ENUM_TYPE(RFC_1421, "RFC_1421") // Not implemented
// ETL_ENUM_TYPE(RFC_2045, "RFC_2045") // Not implemented
ETL_ENUM_TYPE(RFC_2152, "RFC_2152")
ETL_ENUM_TYPE(RFC_3501, "RFC_3501")
ETL_ENUM_TYPE(RFC_4648, "RFC_4648")
@ -166,16 +168,14 @@ namespace etl
enum
{
Invalid_Data = etl::integral_limits<int>::max,
Invalid_Data = etl::integral_limits<int>::max,
Min_Encode_Buffer_Size = 4,
Min_Decode_Buffer_Size = 3
};
protected:
ETL_CONSTEXPR14
base64(const char* encoder_table_,
bool use_padding_)
ETL_CONSTEXPR14 base64(const char* encoder_table_, bool use_padding_)
: encoder_table(encoder_table_)
, use_padding(use_padding_)
{
@ -184,9 +184,7 @@ namespace etl
//*************************************************************************
// Character set for RFC-1421, RFC-2045, RFC-2152 and RFC-4648
//*************************************************************************
static
ETL_CONSTEXPR14
const char* character_set_1()
static ETL_CONSTEXPR14 const char* character_set_1()
{
return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
}
@ -194,9 +192,7 @@ namespace etl
//*************************************************************************
// Character set for RFC-4648-URL
//*************************************************************************
static
ETL_CONSTEXPR14
const char* character_set_2()
static ETL_CONSTEXPR14 const char* character_set_2()
{
return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
}
@ -204,9 +200,7 @@ namespace etl
//*************************************************************************
// Character set for RFC-3501-URL
//*************************************************************************
static
ETL_CONSTEXPR14
const char* character_set_3()
static ETL_CONSTEXPR14 const char* character_set_3()
{
return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,";
}
@ -214,5 +208,5 @@ namespace etl
const char* encoder_table;
const bool use_padding;
};
}
} // namespace etl
#endif

View File

@ -1,5 +1,5 @@
//*************************************************************************
///Decode from Base64 from and to pointer/length
/// Decode from Base64 from and to pointer/length
//*************************************************************************///\file
/******************************************************************************
@ -29,16 +29,16 @@ SOFTWARE.
#define ETL_BASE64_DECODER_INCLUDED
#include "platform.h"
#include "static_assert.h"
#include "error_handler.h"
#include "type_traits.h"
#include "binary.h"
#include "algorithm.h"
#include "binary.h"
#include "delegate.h"
#include "enum_type.h"
#include "error_handler.h"
#include "integral_limits.h"
#include "iterator.h"
#include "enum_type.h"
#include "delegate.h"
#include "span.h"
#include "static_assert.h"
#include "type_traits.h"
#include "base64.h"
@ -48,11 +48,12 @@ SOFTWARE.
#include <iterator>
#endif
#define ETL_IS_8_BIT_INTEGRAL(Type) (etl::is_integral<typename etl::remove_cv<Type>::type>::value && \
(etl::integral_limits<typename etl::remove_cv<Type>::type>::bits == 8U))
#define ETL_IS_8_BIT_INTEGRAL(Type) \
(etl::is_integral<typename etl::remove_cv<Type>::type>::value && (etl::integral_limits<typename etl::remove_cv<Type>::type>::bits == 8U))
#define ETL_IS_ITERATOR_TYPE_8_BIT_INTEGRAL(Type) (etl::is_integral<typename etl::iterator_traits<typename etl::remove_cv<Type>::type>::value_type>::value && \
(etl::integral_limits<typename etl::iterator_traits<typename etl::remove_cv<Type>::type>::value_type>::bits == 8U))
#define ETL_IS_ITERATOR_TYPE_8_BIT_INTEGRAL(Type) \
(etl::is_integral< typename etl::iterator_traits< typename etl::remove_cv<Type>::type>::value_type>::value \
&& (etl::integral_limits< typename etl::iterator_traits< typename etl::remove_cv<Type>::type>::value_type>::bits == 8U))
namespace etl
{
@ -70,8 +71,7 @@ namespace etl
/// Decode to Base64
//*************************************************************************
template <typename T>
ETL_CONSTEXPR14
bool decode(T value)
ETL_CONSTEXPR14 bool decode(T value)
{
ETL_STATIC_ASSERT(ETL_IS_8_BIT_INTEGRAL(T), "Input type must be an 8 bit integral");
@ -101,8 +101,7 @@ namespace etl
/// Decode from Base64
//*************************************************************************
template <typename TInputIterator>
ETL_CONSTEXPR14
bool decode(TInputIterator input_begin, TInputIterator input_end)
ETL_CONSTEXPR14 bool decode(TInputIterator input_begin, TInputIterator input_end)
{
ETL_STATIC_ASSERT(ETL_IS_ITERATOR_TYPE_8_BIT_INTEGRAL(TInputIterator), "Input type must be an 8 bit integral");
@ -121,8 +120,7 @@ namespace etl
/// Decode from Base64
//*************************************************************************
template <typename TInputIterator>
ETL_CONSTEXPR14
bool decode(TInputIterator input_begin, size_t input_length)
ETL_CONSTEXPR14 bool decode(TInputIterator input_begin, size_t input_length)
{
ETL_STATIC_ASSERT(ETL_IS_ITERATOR_TYPE_8_BIT_INTEGRAL(TInputIterator), "Input type must be an 8 bit integral");
@ -141,8 +139,7 @@ namespace etl
/// Decode from Base64
//*************************************************************************
template <typename TInputIterator>
ETL_CONSTEXPR14
bool decode_final(TInputIterator input_begin, TInputIterator input_end)
ETL_CONSTEXPR14 bool decode_final(TInputIterator input_begin, TInputIterator input_end)
{
return decode(input_begin, input_end) && flush();
}
@ -151,8 +148,7 @@ namespace etl
/// Decode from Base64
//*************************************************************************
template <typename TInputIterator>
ETL_CONSTEXPR14
bool decode_final(TInputIterator input_begin, size_t input_length)
ETL_CONSTEXPR14 bool decode_final(TInputIterator input_begin, size_t input_length)
{
return decode(input_begin, input_length) && flush();
}
@ -160,8 +156,7 @@ namespace etl
//*************************************************************************
/// Flush any remaining data to the output.
//*************************************************************************
ETL_CONSTEXPR14
bool flush()
ETL_CONSTEXPR14 bool flush()
{
// Encode any remaining input data.
bool success = decode_block();
@ -193,32 +188,28 @@ namespace etl
//*************************************************************************
/// Reset the encoder.
//*************************************************************************
ETL_CONSTEXPR14
void restart()
ETL_CONSTEXPR14 void restart()
{
reset_input_buffer();
reset_output_buffer();
overflow_detected = false;
overflow_detected = false;
invalid_data_detected = false;
padding_received = false;
padding_received = false;
}
//*************************************************************************
/// Returns the beginning of the output buffer.
//*************************************************************************
ETL_NODISCARD
ETL_CONSTEXPR14
const unsigned char* begin() const
ETL_NODISCARD ETL_CONSTEXPR14 const unsigned char* begin() const
{
return p_output_buffer;
}
//*************************************************************************
/// This only returns a useful value if a callback has not been set or called.
/// This only returns a useful value if a callback has not been set or
/// called.
//*************************************************************************
ETL_NODISCARD
ETL_CONSTEXPR14
const unsigned char* end() const
ETL_NODISCARD ETL_CONSTEXPR14 const unsigned char* end() const
{
return p_output_buffer + output_buffer_length;
}
@ -226,30 +217,26 @@ namespace etl
//*************************************************************************
/// Returns the beginning of the output buffer.
//*************************************************************************
ETL_NODISCARD
ETL_CONSTEXPR14
const unsigned char* cbegin() const
ETL_NODISCARD ETL_CONSTEXPR14 const unsigned char* cbegin() const
{
return p_output_buffer;
}
//*************************************************************************
/// This only returns a useful value if a callback has not been set or called.
/// This only returns a useful value if a callback has not been set or
/// called.
//*************************************************************************
ETL_NODISCARD
ETL_CONSTEXPR14
const unsigned char* cend() const
ETL_NODISCARD ETL_CONSTEXPR14 const unsigned char* cend() const
{
return p_output_buffer + output_buffer_length;
}
//*************************************************************************
/// Returns the size of the output buffer.
/// This only returns a useful value if a callback has not been set or called.
/// This only returns a useful value if a callback has not been set or
/// called.
//*************************************************************************
ETL_NODISCARD
ETL_CONSTEXPR14
size_t size() const
ETL_NODISCARD ETL_CONSTEXPR14 size_t size() const
{
return output_buffer_length;
}
@ -257,20 +244,17 @@ namespace etl
//*************************************************************************
/// Returns the maximum size of the output buffer.
//*************************************************************************
ETL_NODISCARD
ETL_CONSTEXPR14
size_t buffer_size() const
ETL_NODISCARD ETL_CONSTEXPR14 size_t buffer_size() const
{
return output_buffer_max_size;
}
//*************************************************************************
/// Get a span of the output data.
/// This only returns a useful span if a callback has not been set or called.
/// This only returns a useful span if a callback has not been set or
/// called.
//*************************************************************************
ETL_NODISCARD
ETL_CONSTEXPR14
span_type span() const
ETL_NODISCARD ETL_CONSTEXPR14 span_type span() const
{
return span_type(begin(), end());
}
@ -278,9 +262,7 @@ namespace etl
//*************************************************************************
/// Returns true if the output buffer has overflowed
//*************************************************************************
ETL_NODISCARD
ETL_CONSTEXPR14
bool overflow() const
ETL_NODISCARD ETL_CONSTEXPR14 bool overflow() const
{
return overflow_detected;
}
@ -288,9 +270,7 @@ namespace etl
//*************************************************************************
/// Returns true if an invalid character was detected.
//*************************************************************************
ETL_NODISCARD
ETL_CONSTEXPR14
bool invalid_data() const
ETL_NODISCARD ETL_CONSTEXPR14 bool invalid_data() const
{
return invalid_data_detected;
}
@ -298,9 +278,7 @@ namespace etl
//*************************************************************************
/// Returns true if an error was detected.
//*************************************************************************
ETL_NODISCARD
ETL_CONSTEXPR14
bool error() const
ETL_NODISCARD ETL_CONSTEXPR14 bool error() const
{
return overflow() || invalid_data();
}
@ -310,12 +288,8 @@ namespace etl
//*************************************************************************
/// Constructor
//*************************************************************************
ETL_CONSTEXPR14
ibase64_decoder(const char* encoder_table_,
bool use_padding_,
unsigned char* p_output_buffer_,
size_t ouput_buffer_max_size_,
callback_type callback_)
ETL_CONSTEXPR14 ibase64_decoder(const char* encoder_table_, bool use_padding_, unsigned char* p_output_buffer_, size_t ouput_buffer_max_size_,
callback_type callback_)
: base64(encoder_table_, use_padding_)
, input_buffer()
, input_buffer_length(0)
@ -333,9 +307,7 @@ namespace etl
/// Calculates the minimum buffer size required to decode from Base64
//*************************************************************************
ETL_NODISCARD
static
ETL_CONSTEXPR14
size_t decoded_size_from_valid_input_length(size_t input_length)
static ETL_CONSTEXPR14 size_t decoded_size_from_valid_input_length(size_t input_length)
{
return input_length - (input_length / 4U);
}
@ -343,14 +315,13 @@ namespace etl
private:
//*************************************************************************
// Translates a sextet into an index
// Translates a sextet into an index
//*************************************************************************
template <typename T>
ETL_CONSTEXPR14
uint32_t get_index_from_sextet(T sextet)
ETL_CONSTEXPR14 uint32_t get_index_from_sextet(T sextet)
{
const char* encoder_table_end = encoder_table + 64;
const char* p_sextet = etl::find(encoder_table, encoder_table_end, static_cast<char>(sextet));
const char* p_sextet = etl::find(encoder_table, encoder_table_end, static_cast<char>(sextet));
if (p_sextet != encoder_table_end)
{
@ -369,8 +340,7 @@ namespace etl
template <typename T>
ETL_NODISCARD
static
ETL_CONSTEXPR14
T padding()
ETL_CONSTEXPR14 T padding()
{
return static_cast<T>('=');
}
@ -378,51 +348,50 @@ namespace etl
//*************************************************************************
/// Decode one block of data.
//*************************************************************************
ETL_CONSTEXPR14
bool decode_block()
ETL_CONSTEXPR14 bool decode_block()
{
switch (input_buffer_length)
{
// Only triggered on call to flush().
case 2:
{
uint32_t sextets = (get_index_from_sextet(input_buffer[0]) << 6);
sextets = sextets | (get_index_from_sextet(input_buffer[1]));
push_to_output_buffer((sextets >> 4) & 0xFF);
break;
}
{
uint32_t sextets = (get_index_from_sextet(input_buffer[0]) << 6);
sextets = sextets | (get_index_from_sextet(input_buffer[1]));
push_to_output_buffer((sextets >> 4) & 0xFF);
break;
}
// Only triggered on call to flush().
case 3:
{
uint32_t sextets = (get_index_from_sextet(input_buffer[0]) << 12);
sextets = sextets | (get_index_from_sextet(input_buffer[1]) << 6);
sextets = sextets | (get_index_from_sextet(input_buffer[2]));
push_to_output_buffer((sextets >> 10) & 0xFF);
push_to_output_buffer((sextets >> 2) & 0xFF);
break;
}
{
uint32_t sextets = (get_index_from_sextet(input_buffer[0]) << 12);
sextets = sextets | (get_index_from_sextet(input_buffer[1]) << 6);
sextets = sextets | (get_index_from_sextet(input_buffer[2]));
push_to_output_buffer((sextets >> 10) & 0xFF);
push_to_output_buffer((sextets >> 2) & 0xFF);
break;
}
// Only triggered on call to decode().
case 4:
{
// Read in four sextets
uint32_t sextets = (get_index_from_sextet(input_buffer[0]) << 18);
sextets = sextets | (get_index_from_sextet(input_buffer[1]) << 12);
sextets = sextets | (get_index_from_sextet(input_buffer[2]) << 6);
sextets = sextets | (get_index_from_sextet(input_buffer[3]));
{
// Read in four sextets
uint32_t sextets = (get_index_from_sextet(input_buffer[0]) << 18);
sextets = sextets | (get_index_from_sextet(input_buffer[1]) << 12);
sextets = sextets | (get_index_from_sextet(input_buffer[2]) << 6);
sextets = sextets | (get_index_from_sextet(input_buffer[3]));
// Write out three octets
push_to_output_buffer((sextets >> 16) & 0xFF);
push_to_output_buffer((sextets >> 8) & 0xFF);
push_to_output_buffer((sextets >> 0) & 0xFF);
break;
}
// Write out three octets
push_to_output_buffer((sextets >> 16) & 0xFF);
push_to_output_buffer((sextets >> 8) & 0xFF);
push_to_output_buffer((sextets >> 0) & 0xFF);
break;
}
default:
{
break;
}
{
break;
}
}
ETL_ASSERT(!invalid_data_detected, ETL_ERROR(etl::base64_invalid_data));
@ -434,8 +403,7 @@ namespace etl
//*************************************************************************
// Push to the output buffer.
//*************************************************************************
ETL_CONSTEXPR14
void push_to_output_buffer(unsigned char c)
ETL_CONSTEXPR14 void push_to_output_buffer(unsigned char c)
{
if (output_buffer_length < output_buffer_max_size)
{
@ -448,28 +416,25 @@ namespace etl
}
//*************************************************************************
//
//
//*************************************************************************
ETL_CONSTEXPR14
bool output_buffer_is_full() const
ETL_CONSTEXPR14 bool output_buffer_is_full() const
{
return output_buffer_length == output_buffer_max_size;
}
//*************************************************************************
//
//
//*************************************************************************
ETL_CONSTEXPR14
bool output_buffer_is_empty() const
ETL_CONSTEXPR14 bool output_buffer_is_empty() const
{
return output_buffer_length == 0;
}
//*************************************************************************
//
//
//*************************************************************************
ETL_CONSTEXPR14
void reset_output_buffer()
ETL_CONSTEXPR14 void reset_output_buffer()
{
output_buffer_length = 0;
}
@ -478,8 +443,7 @@ namespace etl
// Push to the input buffer.
//*************************************************************************
template <typename T>
ETL_CONSTEXPR14
void push_to_input_buffer(T value)
ETL_CONSTEXPR14 void push_to_input_buffer(T value)
{
if (value == padding<T>())
{
@ -494,25 +458,23 @@ namespace etl
}
else
{
input_buffer[input_buffer_length++] = static_cast<uint8_t>(value);
input_buffer[input_buffer_length++] = static_cast<char>(value);
}
}
}
//*************************************************************************
//
//
//*************************************************************************
ETL_CONSTEXPR14
bool input_buffer_is_full() const
ETL_CONSTEXPR14 bool input_buffer_is_full() const
{
return input_buffer_length == 4U;
}
//*************************************************************************
//
//
//*************************************************************************
ETL_CONSTEXPR14
void reset_input_buffer()
ETL_CONSTEXPR14 void reset_input_buffer()
{
input_buffer_length = 0;
}
@ -544,13 +506,8 @@ namespace etl
//*************************************************************************
/// Base64 RFC-2152 constructor.
//*************************************************************************
ETL_CONSTEXPR14
base64_rfc2152_decoder()
: ibase64_decoder(etl::base64::character_set_1(),
etl::base64::Padding::No_Padding,
output_buffer,
Buffer_Size,
callback_type())
ETL_CONSTEXPR14 base64_rfc2152_decoder()
: ibase64_decoder(etl::base64::character_set_1(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_type())
, output_buffer()
{
}
@ -558,13 +515,8 @@ namespace etl
//*************************************************************************
/// Base64 RFC-2152 constructor.
//*************************************************************************
ETL_CONSTEXPR14
base64_rfc2152_decoder(callback_type callback_)
: ibase64_decoder(etl::base64::character_set_1(),
etl::base64::Padding::No_Padding,
output_buffer,
Buffer_Size,
callback_)
ETL_CONSTEXPR14 base64_rfc2152_decoder(callback_type callback_)
: ibase64_decoder(etl::base64::character_set_1(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_)
, output_buffer()
{
}
@ -574,8 +526,7 @@ namespace etl
//*************************************************************************
ETL_NODISCARD
static
ETL_CONSTEXPR14
size_t safe_output_buffer_size(size_t input_length)
ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
{
return ibase64_decoder::decoded_size_from_valid_input_length(input_length);
}
@ -599,13 +550,8 @@ namespace etl
//*************************************************************************
/// Base64 RFC-3501 constructor.
//*************************************************************************
ETL_CONSTEXPR14
base64_rfc3501_decoder()
: ibase64_decoder(etl::base64::character_set_3(),
etl::base64::Padding::No_Padding,
output_buffer,
Buffer_Size,
callback_type())
ETL_CONSTEXPR14 base64_rfc3501_decoder()
: ibase64_decoder(etl::base64::character_set_3(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_type())
, output_buffer()
{
}
@ -613,13 +559,8 @@ namespace etl
//*************************************************************************
/// Base64 RFC-3501 constructor.
//*************************************************************************
ETL_CONSTEXPR14
base64_rfc3501_decoder(callback_type callback_)
: ibase64_decoder(etl::base64::character_set_3(),
etl::base64::Padding::No_Padding,
output_buffer,
Buffer_Size,
callback_)
ETL_CONSTEXPR14 base64_rfc3501_decoder(callback_type callback_)
: ibase64_decoder(etl::base64::character_set_3(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_)
, output_buffer()
{
}
@ -629,8 +570,7 @@ namespace etl
//*************************************************************************
ETL_NODISCARD
static
ETL_CONSTEXPR14
size_t safe_output_buffer_size(size_t input_length)
ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
{
return ibase64_decoder::decoded_size_from_valid_input_length(input_length);
}
@ -654,13 +594,8 @@ namespace etl
//*************************************************************************
/// Base64 RFC-4648 constructor.
//*************************************************************************
ETL_CONSTEXPR14
base64_rfc4648_decoder()
: ibase64_decoder(etl::base64::character_set_1(),
etl::base64::Padding::No_Padding,
output_buffer,
Buffer_Size,
callback_type())
ETL_CONSTEXPR14 base64_rfc4648_decoder()
: ibase64_decoder(etl::base64::character_set_1(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_type())
, output_buffer()
{
}
@ -668,13 +603,8 @@ namespace etl
//*************************************************************************
/// Base64 RFC-4648 constructor.
//*************************************************************************
ETL_CONSTEXPR14
base64_rfc4648_decoder(callback_type callback_)
: ibase64_decoder(etl::base64::character_set_1(),
etl::base64::Padding::No_Padding,
output_buffer,
Buffer_Size,
callback_)
ETL_CONSTEXPR14 base64_rfc4648_decoder(callback_type callback_)
: ibase64_decoder(etl::base64::character_set_1(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_)
, output_buffer()
{
}
@ -683,9 +613,8 @@ namespace etl
/// Calculate the required output encode buffer size.
//*************************************************************************
ETL_NODISCARD
static
ETL_CONSTEXPR14
size_t safe_output_buffer_size(size_t input_length)
static
ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
{
return ibase64_decoder::decoded_size_from_valid_input_length(input_length);
}
@ -709,13 +638,8 @@ namespace etl
//*************************************************************************
/// Base64 RFC-4648-Padding constructor.
//*************************************************************************
ETL_CONSTEXPR14
base64_rfc4648_padding_decoder()
: ibase64_decoder(etl::base64::character_set_1(),
etl::base64::Padding::Use_Padding,
output_buffer,
Buffer_Size,
callback_type())
ETL_CONSTEXPR14 base64_rfc4648_padding_decoder()
: ibase64_decoder(etl::base64::character_set_1(), etl::base64::Padding::Use_Padding, output_buffer, Buffer_Size, callback_type())
, output_buffer()
{
}
@ -723,13 +647,8 @@ namespace etl
//*************************************************************************
/// Base64 RFC-4648-Padding constructor.
//*************************************************************************
ETL_CONSTEXPR14
base64_rfc4648_padding_decoder(callback_type callback_)
: ibase64_decoder(etl::base64::character_set_1(),
etl::base64::Padding::Use_Padding,
output_buffer,
Buffer_Size,
callback_)
ETL_CONSTEXPR14 base64_rfc4648_padding_decoder(callback_type callback_)
: ibase64_decoder(etl::base64::character_set_1(), etl::base64::Padding::Use_Padding, output_buffer, Buffer_Size, callback_)
, output_buffer()
{
}
@ -739,8 +658,7 @@ namespace etl
//*************************************************************************
ETL_NODISCARD
static
ETL_CONSTEXPR14
size_t safe_output_buffer_size(size_t input_length)
ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
{
return ibase64_decoder::decoded_size_from_valid_input_length(input_length);
}
@ -764,13 +682,8 @@ namespace etl
//*************************************************************************
/// Base64 RFC-4648-Padding constructor.
//*************************************************************************
ETL_CONSTEXPR14
base64_rfc4648_url_decoder()
: ibase64_decoder(etl::base64::character_set_2(),
etl::base64::Padding::No_Padding,
output_buffer,
Buffer_Size,
callback_type())
ETL_CONSTEXPR14 base64_rfc4648_url_decoder()
: ibase64_decoder(etl::base64::character_set_2(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_type())
, output_buffer()
{
}
@ -778,13 +691,8 @@ namespace etl
//*************************************************************************
/// Base64 RFC-4648-Padding constructor.
//*************************************************************************
ETL_CONSTEXPR14
base64_rfc4648_url_decoder(callback_type callback_)
: ibase64_decoder(etl::base64::character_set_2(),
etl::base64::Padding::No_Padding,
output_buffer,
Buffer_Size,
callback_)
ETL_CONSTEXPR14 base64_rfc4648_url_decoder(callback_type callback_)
: ibase64_decoder(etl::base64::character_set_2(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_)
, output_buffer()
{
}
@ -794,8 +702,7 @@ namespace etl
//*************************************************************************
ETL_NODISCARD
static
ETL_CONSTEXPR14
size_t safe_output_buffer_size(size_t input_length)
ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
{
return ibase64_decoder::decoded_size_from_valid_input_length(input_length);
}
@ -819,13 +726,8 @@ namespace etl
//*************************************************************************
/// Base64 RFC-4648-Padding constructor.
//*************************************************************************
ETL_CONSTEXPR14
base64_rfc4648_url_padding_decoder()
: ibase64_decoder(etl::base64::character_set_2(),
etl::base64::Padding::Use_Padding,
output_buffer,
Buffer_Size,
callback_type())
ETL_CONSTEXPR14 base64_rfc4648_url_padding_decoder()
: ibase64_decoder(etl::base64::character_set_2(), etl::base64::Padding::Use_Padding, output_buffer, Buffer_Size, callback_type())
, output_buffer()
{
}
@ -833,13 +735,8 @@ namespace etl
//*************************************************************************
/// Base64 RFC-4648-Padding constructor.
//*************************************************************************
ETL_CONSTEXPR14
base64_rfc4648_url_padding_decoder(callback_type callback_)
: ibase64_decoder(etl::base64::character_set_2(),
etl::base64::Padding::Use_Padding,
output_buffer,
Buffer_Size,
callback_)
ETL_CONSTEXPR14 base64_rfc4648_url_padding_decoder(callback_type callback_)
: ibase64_decoder(etl::base64::character_set_2(), etl::base64::Padding::Use_Padding, output_buffer, Buffer_Size, callback_)
, output_buffer()
{
}
@ -849,8 +746,7 @@ namespace etl
//*************************************************************************
ETL_NODISCARD
static
ETL_CONSTEXPR14
size_t safe_output_buffer_size(size_t input_length)
ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
{
return ibase64_decoder::decoded_size_from_valid_input_length(input_length);
}
@ -860,7 +756,7 @@ namespace etl
/// The internal output buffer.
unsigned char output_buffer[Buffer_Size];
};
}
} // namespace etl
#undef ETL_IS_TYPE_8_BIT_INTEGRAL
#undef ETL_IS_ITERATOR_TYPE_8_BIT_INTEGRAL

View File

@ -1,5 +1,5 @@
//*************************************************************************
///Decode from Base64 from and to pointer/length
/// Decode from Base64 from and to pointer/length
//*************************************************************************///\file
/******************************************************************************
@ -29,16 +29,16 @@ SOFTWARE.
#define ETL_BASE64_ENCODER_INCLUDED
#include "platform.h"
#include "static_assert.h"
#include "error_handler.h"
#include "type_traits.h"
#include "binary.h"
#include "algorithm.h"
#include "binary.h"
#include "delegate.h"
#include "enum_type.h"
#include "error_handler.h"
#include "integral_limits.h"
#include "iterator.h"
#include "enum_type.h"
#include "delegate.h"
#include "span.h"
#include "static_assert.h"
#include "type_traits.h"
#include "base64.h"
@ -48,11 +48,12 @@ SOFTWARE.
#include <iterator>
#endif
#define ETL_IS_8_BIT_INTEGRAL(Type) (etl::is_integral<typename etl::remove_cv<Type>::type>::value && \
(etl::integral_limits<typename etl::remove_cv<Type>::type>::bits == 8U))
#define ETL_IS_8_BIT_INTEGRAL(Type) \
(etl::is_integral<typename etl::remove_cv<Type>::type>::value && (etl::integral_limits<typename etl::remove_cv<Type>::type>::bits == 8U))
#define ETL_IS_ITERATOR_TYPE_8_BIT_INTEGRAL(Type) (etl::is_integral<typename etl::iterator_traits<typename etl::remove_cv<Type>::type>::value_type>::value && \
(etl::integral_limits<typename etl::iterator_traits<typename etl::remove_cv<Type>::type>::value_type>::bits == 8U))
#define ETL_IS_ITERATOR_TYPE_8_BIT_INTEGRAL(Type) \
(etl::is_integral< typename etl::iterator_traits< typename etl::remove_cv<Type>::type>::value_type>::value \
&& (etl::integral_limits< typename etl::iterator_traits< typename etl::remove_cv<Type>::type>::value_type>::bits == 8U))
namespace etl
{
@ -70,8 +71,7 @@ namespace etl
/// Encode to Base64
//*************************************************************************
template <typename T>
ETL_CONSTEXPR14
bool encode(T value)
ETL_CONSTEXPR14 bool encode(T value)
{
ETL_STATIC_ASSERT(ETL_IS_8_BIT_INTEGRAL(T), "Input type must be an 8 bit integral");
@ -99,8 +99,7 @@ namespace etl
/// Encode to Base64
//*************************************************************************
template <typename TInputIterator>
ETL_CONSTEXPR14
bool encode(TInputIterator input_begin, size_t input_length)
ETL_CONSTEXPR14 bool encode(TInputIterator input_begin, size_t input_length)
{
ETL_STATIC_ASSERT(ETL_IS_ITERATOR_TYPE_8_BIT_INTEGRAL(TInputIterator), "Input type must be an 8 bit integral");
@ -119,8 +118,7 @@ namespace etl
/// Encode to Base64
//*************************************************************************
template <typename TInputIterator>
ETL_CONSTEXPR14
bool encode(TInputIterator input_begin, TInputIterator input_end)
ETL_CONSTEXPR14 bool encode(TInputIterator input_begin, TInputIterator input_end)
{
ETL_STATIC_ASSERT(ETL_IS_ITERATOR_TYPE_8_BIT_INTEGRAL(TInputIterator), "Input type must be an 8 bit integral");
@ -139,8 +137,7 @@ namespace etl
/// Encode to Base64
//*************************************************************************
template <typename TInputIterator>
ETL_CONSTEXPR14
bool encode_final(TInputIterator input_begin, size_t input_length)
ETL_CONSTEXPR14 bool encode_final(TInputIterator input_begin, size_t input_length)
{
return encode(input_begin, input_length) && flush();
}
@ -149,8 +146,7 @@ namespace etl
/// Encode to Base64
//*************************************************************************
template <typename TInputIterator>
ETL_CONSTEXPR14
bool encode_final(TInputIterator input_begin, TInputIterator input_end)
ETL_CONSTEXPR14 bool encode_final(TInputIterator input_begin, TInputIterator input_end)
{
return encode(input_begin, input_end) && flush();
}
@ -158,8 +154,7 @@ namespace etl
//*************************************************************************
/// Flush any remaining data to the output.
//*************************************************************************
ETL_CONSTEXPR14
bool flush()
ETL_CONSTEXPR14 bool flush()
{
// Encode any remaining input data.
bool success = encode_block();
@ -189,8 +184,7 @@ namespace etl
//*************************************************************************
/// Reset the encoder.
//*************************************************************************
ETL_CONSTEXPR14
void restart()
ETL_CONSTEXPR14 void restart()
{
reset_input_buffer();
reset_output_buffer();
@ -199,19 +193,16 @@ namespace etl
//*************************************************************************
/// Returns the beginning of the output buffer.
//*************************************************************************
ETL_NODISCARD
ETL_CONSTEXPR14
const char* begin() const
ETL_NODISCARD ETL_CONSTEXPR14 const char* begin() const
{
return p_output_buffer;
}
//*************************************************************************
/// This only returns a useful value if a callback has not been set or called.
/// This only returns a useful value if a callback has not been set or
/// called.
//*************************************************************************
ETL_NODISCARD
ETL_CONSTEXPR14
const char* end() const
ETL_NODISCARD ETL_CONSTEXPR14 const char* end() const
{
return p_output_buffer + output_buffer_length;
}
@ -219,30 +210,26 @@ namespace etl
//*************************************************************************
/// Returns the beginning of the output buffer.
//*************************************************************************
ETL_NODISCARD
ETL_CONSTEXPR14
const char* cbegin() const
ETL_NODISCARD ETL_CONSTEXPR14 const char* cbegin() const
{
return p_output_buffer;
}
//*************************************************************************
/// This only returns a useful value if a callback has not been set or called.
/// This only returns a useful value if a callback has not been set or
/// called.
//*************************************************************************
ETL_NODISCARD
ETL_CONSTEXPR14
const char* cend() const
ETL_NODISCARD ETL_CONSTEXPR14 const char* cend() const
{
return p_output_buffer + output_buffer_length;
}
//*************************************************************************
/// Returns the size of the output buffer.
/// This only returns a useful value if a callback has not been set or called.
/// This only returns a useful value if a callback has not been set or
/// called.
//*************************************************************************
ETL_NODISCARD
ETL_CONSTEXPR14
size_t size() const
ETL_NODISCARD ETL_CONSTEXPR14 size_t size() const
{
return output_buffer_length;
}
@ -250,20 +237,17 @@ namespace etl
//*************************************************************************
/// Returns the maximum size of the output buffer.
//*************************************************************************
ETL_NODISCARD
ETL_CONSTEXPR14
size_t max_size() const
ETL_NODISCARD ETL_CONSTEXPR14 size_t max_size() const
{
return output_buffer_max_size;
}
//*************************************************************************
/// Get a span of the output data.
/// This only returns a useful span if a callback has not been set or called.
/// This only returns a useful span if a callback has not been set or
/// called.
//*************************************************************************
ETL_NODISCARD
ETL_CONSTEXPR14
span_type span() const
ETL_NODISCARD ETL_CONSTEXPR14 span_type span() const
{
return span_type(begin(), end());
}
@ -271,9 +255,7 @@ namespace etl
//*************************************************************************
/// Returns true if the output buffer has overflowed
//*************************************************************************
ETL_NODISCARD
ETL_CONSTEXPR14
bool overflow() const
ETL_NODISCARD ETL_CONSTEXPR14 bool overflow() const
{
return overflowed;
}
@ -281,9 +263,7 @@ namespace etl
//*************************************************************************
/// Returns true if an error was detected.
//*************************************************************************
ETL_NODISCARD
ETL_CONSTEXPR14
bool error() const
ETL_NODISCARD ETL_CONSTEXPR14 bool error() const
{
return overflow();
}
@ -293,12 +273,8 @@ namespace etl
//*************************************************************************
/// Constructor
//*************************************************************************
ETL_CONSTEXPR14
ibase64_encoder(const char* encoder_table_,
bool use_padding_,
char* p_output_buffer_,
size_t ouput_buffer_max_size_,
callback_type callback_)
ETL_CONSTEXPR14 ibase64_encoder(const char* encoder_table_, bool use_padding_, char* p_output_buffer_, size_t ouput_buffer_max_size_,
callback_type callback_)
: base64(encoder_table_, use_padding_)
, input_buffer()
, input_buffer_length(0)
@ -313,64 +289,65 @@ namespace etl
//*************************************************************************
/// Encode one block of data.
//*************************************************************************
ETL_CONSTEXPR14
bool encode_block()
ETL_CONSTEXPR14 bool encode_block()
{
switch (input_buffer_length)
{
// Only triggered on call to flush().
case 1:
{
uint32_t octets = input_buffer[0];
octets = octets << 4; // Adjust one octet (8 bits) for two sextets worth of data (12 bits)
// Write out two sextets + optional padding.
push_to_output_buffer(encoder_table[(octets >> 6) & 0x3F]);
push_to_output_buffer(encoder_table[(octets >> 0) & 0x3F]);
if (use_padding)
{
push_to_output_buffer('=');
push_to_output_buffer('=');
}
break;
}
uint32_t octets = input_buffer[0];
octets = octets << 4; // Adjust one octet (8 bits) for two sextets
// worth of data (12 bits)
// Write out two sextets + optional padding.
push_to_output_buffer(encoder_table[(octets >> 6) & 0x3F]);
push_to_output_buffer(encoder_table[(octets >> 0) & 0x3F]);
if (use_padding)
{
push_to_output_buffer('=');
push_to_output_buffer('=');
}
break;
}
// Only triggered on call to flush().
case 2:
{
uint32_t octets = (input_buffer[0] << 8) | input_buffer[1];
octets <<= 2; // Adjust two octets (16 bits) for three sextets worth of data (18 bits)
// Write out three sextets + optional padding.
push_to_output_buffer(encoder_table[(octets >> 12) & 0x3F]);
push_to_output_buffer(encoder_table[(octets >> 6) & 0x3F]);
push_to_output_buffer(encoder_table[(octets >> 0) & 0x3F]);
if (use_padding)
{
push_to_output_buffer('=');
uint32_t octets = (static_cast<uint32_t>(input_buffer[0]) << 8) | input_buffer[1];
octets <<= 2; // Adjust two octets (16 bits) for three sextets worth
// of data (18 bits)
// Write out three sextets + optional padding.
push_to_output_buffer(encoder_table[(octets >> 12) & 0x3F]);
push_to_output_buffer(encoder_table[(octets >> 6) & 0x3F]);
push_to_output_buffer(encoder_table[(octets >> 0) & 0x3F]);
if (use_padding)
{
push_to_output_buffer('=');
}
break;
}
break;
}
// Only triggered on call to encode().
case 3:
{
uint32_t octets = (input_buffer[0] << 16) | (input_buffer[1] << 8) | input_buffer[2];
{
uint32_t octets = (static_cast<uint32_t>(input_buffer[0]) << 16) | (static_cast<uint32_t>(input_buffer[1]) << 8) | input_buffer[2];
// Write out four sextets
push_to_output_buffer(encoder_table[(octets >> 18) & 0x3F]);
push_to_output_buffer(encoder_table[(octets >> 12) & 0x3F]);
push_to_output_buffer(encoder_table[(octets >> 6) & 0x3F]);
push_to_output_buffer(encoder_table[(octets >> 0) & 0x3F]);
break;
}
// Write out four sextets
push_to_output_buffer(encoder_table[(octets >> 18) & 0x3F]);
push_to_output_buffer(encoder_table[(octets >> 12) & 0x3F]);
push_to_output_buffer(encoder_table[(octets >> 6) & 0x3F]);
push_to_output_buffer(encoder_table[(octets >> 0) & 0x3F]);
break;
}
default:
{
break;
}
{
break;
}
}
ETL_ASSERT(!overflowed, ETL_ERROR(etl::base64_overflow));
@ -383,8 +360,7 @@ namespace etl
//*************************************************************************
ETL_NODISCARD
static
ETL_CONSTEXPR14
size_t encoded_size(size_t input_length, bool use_padding)
ETL_CONSTEXPR14 size_t encoded_size(size_t input_length, bool use_padding)
{
size_t required_output_length = 0;
@ -420,8 +396,7 @@ namespace etl
//*************************************************************************
// Push to the output buffer.
//*************************************************************************
ETL_CONSTEXPR14
void push_to_output_buffer(char c)
ETL_CONSTEXPR14 void push_to_output_buffer(char c)
{
if (output_buffer_length < output_buffer_max_size)
{
@ -434,28 +409,25 @@ namespace etl
}
//*************************************************************************
//
//
//*************************************************************************
ETL_CONSTEXPR14
bool output_buffer_is_full() const
ETL_CONSTEXPR14 bool output_buffer_is_full() const
{
return output_buffer_length == output_buffer_max_size;
}
//*************************************************************************
//
//
//*************************************************************************
ETL_CONSTEXPR14
bool output_buffer_is_empty() const
ETL_CONSTEXPR14 bool output_buffer_is_empty() const
{
return output_buffer_length == 0;
}
//*************************************************************************
//
//
//*************************************************************************
ETL_CONSTEXPR14
void reset_output_buffer()
ETL_CONSTEXPR14 void reset_output_buffer()
{
output_buffer_length = 0;
}
@ -464,26 +436,23 @@ namespace etl
// Push to the input buffer.
//*************************************************************************
template <typename T>
ETL_CONSTEXPR14
void push_to_input_buffer(T value)
ETL_CONSTEXPR14 void push_to_input_buffer(T value)
{
input_buffer[input_buffer_length++] = static_cast<uint8_t>(value);
}
//*************************************************************************
//
//
//*************************************************************************
ETL_CONSTEXPR14
bool input_buffer_is_full() const
ETL_CONSTEXPR14 bool input_buffer_is_full() const
{
return input_buffer_length == 3U;
}
//*************************************************************************
//
//
//*************************************************************************
ETL_CONSTEXPR14
void reset_input_buffer()
ETL_CONSTEXPR14 void reset_input_buffer()
{
input_buffer_length = 0;
}
@ -496,7 +465,7 @@ namespace etl
const size_t output_buffer_max_size;
callback_type callback;
bool overflowed;
};
@ -508,19 +477,15 @@ namespace etl
{
public:
ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Encode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Encode_Buffer_Size");
ETL_STATIC_ASSERT(((Buffer_Size % etl::base64::Min_Encode_Buffer_Size) == 0), "Buffer size must be a multiple of etl::base64::Min_Encode_Buffer_Size");
ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Encode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Encode_Buffer_Size");
ETL_STATIC_ASSERT(((Buffer_Size % etl::base64::Min_Encode_Buffer_Size) == 0),
"Buffer size must be a multiple of etl::base64::Min_Encode_Buffer_Size");
//*************************************************************************
/// Base64 RFC-2152 constructor.
//*************************************************************************
ETL_CONSTEXPR14
base64_rfc2152_encoder()
: ibase64_encoder(etl::base64::character_set_1(),
etl::base64::Padding::No_Padding,
output_buffer,
Buffer_Size,
callback_type())
ETL_CONSTEXPR14 base64_rfc2152_encoder()
: ibase64_encoder(etl::base64::character_set_1(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_type())
, output_buffer()
{
}
@ -528,13 +493,8 @@ namespace etl
//*************************************************************************
/// Base64 RFC-2152 constructor.
//*************************************************************************
ETL_CONSTEXPR14
base64_rfc2152_encoder(callback_type callback_)
: ibase64_encoder(etl::base64::character_set_1(),
etl::base64::Padding::No_Padding,
output_buffer,
Buffer_Size,
callback_)
ETL_CONSTEXPR14 base64_rfc2152_encoder(callback_type callback_)
: ibase64_encoder(etl::base64::character_set_1(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_)
, output_buffer()
{
}
@ -544,8 +504,7 @@ namespace etl
//*************************************************************************
ETL_NODISCARD
static
ETL_CONSTEXPR14
size_t safe_output_buffer_size(size_t input_length)
ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
{
return ibase64_encoder::encoded_size(input_length, etl::base64::Padding::No_Padding);
}
@ -564,19 +523,15 @@ namespace etl
{
public:
ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Encode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Encode_Buffer_Size");
ETL_STATIC_ASSERT(((Buffer_Size% etl::base64::Min_Encode_Buffer_Size) == 0), "Buffer size must be a multiple of etl::base64::Min_Encode_Buffer_Size");
ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Encode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Encode_Buffer_Size");
ETL_STATIC_ASSERT(((Buffer_Size % etl::base64::Min_Encode_Buffer_Size) == 0),
"Buffer size must be a multiple of etl::base64::Min_Encode_Buffer_Size");
//*************************************************************************
/// Base64 RFC-3501 constructor.
//*************************************************************************
ETL_CONSTEXPR14
base64_rfc3501_encoder()
: ibase64_encoder(etl::base64::character_set_3(),
etl::base64::Padding::No_Padding,
output_buffer,
Buffer_Size,
callback_type())
ETL_CONSTEXPR14 base64_rfc3501_encoder()
: ibase64_encoder(etl::base64::character_set_3(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_type())
, output_buffer()
{
}
@ -584,13 +539,8 @@ namespace etl
//*************************************************************************
/// Base64 RFC-3501 constructor.
//*************************************************************************
ETL_CONSTEXPR14
base64_rfc3501_encoder(callback_type callback_)
: ibase64_encoder(etl::base64::character_set_3(),
etl::base64::Padding::No_Padding,
output_buffer,
Buffer_Size,
callback_)
ETL_CONSTEXPR14 base64_rfc3501_encoder(callback_type callback_)
: ibase64_encoder(etl::base64::character_set_3(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_)
, output_buffer()
{
}
@ -600,8 +550,7 @@ namespace etl
//*************************************************************************
ETL_NODISCARD
static
ETL_CONSTEXPR14
size_t safe_output_buffer_size(size_t input_length)
ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
{
return ibase64_encoder::encoded_size(input_length, etl::base64::Padding::No_Padding);
}
@ -620,19 +569,15 @@ namespace etl
{
public:
ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Encode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Encode_Buffer_Size");
ETL_STATIC_ASSERT(((Buffer_Size % etl::base64::Min_Encode_Buffer_Size) == 0), "Buffer size must be a multiple of etl::base64::Min_Encode_Buffer_Size");
ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Encode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Encode_Buffer_Size");
ETL_STATIC_ASSERT(((Buffer_Size % etl::base64::Min_Encode_Buffer_Size) == 0),
"Buffer size must be a multiple of etl::base64::Min_Encode_Buffer_Size");
//*************************************************************************
/// Base64 RFC-4648 constructor.
//*************************************************************************
ETL_CONSTEXPR14
base64_rfc4648_encoder()
: ibase64_encoder(etl::base64::character_set_1(),
etl::base64::Padding::No_Padding,
output_buffer,
Buffer_Size,
callback_type())
ETL_CONSTEXPR14 base64_rfc4648_encoder()
: ibase64_encoder(etl::base64::character_set_1(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_type())
, output_buffer()
{
}
@ -640,13 +585,8 @@ namespace etl
//*************************************************************************
/// Base64 RFC-4648 constructor.
//*************************************************************************
ETL_CONSTEXPR14
base64_rfc4648_encoder(callback_type callback_)
: ibase64_encoder(etl::base64::character_set_1(),
etl::base64::Padding::No_Padding,
output_buffer,
Buffer_Size,
callback_)
ETL_CONSTEXPR14 base64_rfc4648_encoder(callback_type callback_)
: ibase64_encoder(etl::base64::character_set_1(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_)
, output_buffer()
{
}
@ -656,8 +596,7 @@ namespace etl
//*************************************************************************
ETL_NODISCARD
static
ETL_CONSTEXPR14
size_t safe_output_buffer_size(size_t input_length)
ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
{
return ibase64_encoder::encoded_size(input_length, etl::base64::Padding::No_Padding);
}
@ -676,19 +615,15 @@ namespace etl
{
public:
ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Encode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Encode_Buffer_Size");
ETL_STATIC_ASSERT(((Buffer_Size% etl::base64::Min_Encode_Buffer_Size) == 0), "Buffer size must be a multiple of etl::base64::Min_Encode_Buffer_Size");
ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Encode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Encode_Buffer_Size");
ETL_STATIC_ASSERT(((Buffer_Size % etl::base64::Min_Encode_Buffer_Size) == 0),
"Buffer size must be a multiple of etl::base64::Min_Encode_Buffer_Size");
//*************************************************************************
/// Base64 RFC-4648-Padding constructor.
//*************************************************************************
ETL_CONSTEXPR14
base64_rfc4648_padding_encoder()
: ibase64_encoder(etl::base64::character_set_1(),
etl::base64::Padding::Use_Padding,
output_buffer,
Buffer_Size,
callback_type())
ETL_CONSTEXPR14 base64_rfc4648_padding_encoder()
: ibase64_encoder(etl::base64::character_set_1(), etl::base64::Padding::Use_Padding, output_buffer, Buffer_Size, callback_type())
, output_buffer()
{
}
@ -696,13 +631,8 @@ namespace etl
//*************************************************************************
/// Base64 RFC-4648-Padding constructor.
//*************************************************************************
ETL_CONSTEXPR14
base64_rfc4648_padding_encoder(callback_type callback_)
: ibase64_encoder(etl::base64::character_set_1(),
etl::base64::Padding::Use_Padding,
output_buffer,
Buffer_Size,
callback_)
ETL_CONSTEXPR14 base64_rfc4648_padding_encoder(callback_type callback_)
: ibase64_encoder(etl::base64::character_set_1(), etl::base64::Padding::Use_Padding, output_buffer, Buffer_Size, callback_)
, output_buffer()
{
}
@ -712,8 +642,7 @@ namespace etl
//*************************************************************************
ETL_NODISCARD
static
ETL_CONSTEXPR14
size_t safe_output_buffer_size(size_t input_length)
ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
{
return ibase64_encoder::encoded_size(input_length, etl::base64::Padding::Use_Padding);
}
@ -732,19 +661,15 @@ namespace etl
{
public:
ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Encode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Encode_Buffer_Size");
ETL_STATIC_ASSERT(((Buffer_Size % etl::base64::Min_Encode_Buffer_Size) == 0), "Buffer size must be a multiple of etl::base64::Min_Encode_Buffer_Size");
ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Encode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Encode_Buffer_Size");
ETL_STATIC_ASSERT(((Buffer_Size % etl::base64::Min_Encode_Buffer_Size) == 0),
"Buffer size must be a multiple of etl::base64::Min_Encode_Buffer_Size");
//*************************************************************************
/// Base64 RFC-4648-URL constructor.
//*************************************************************************
ETL_CONSTEXPR14
base64_rfc4648_url_encoder()
: ibase64_encoder(etl::base64::character_set_2(),
etl::base64::Padding::No_Padding,
output_buffer,
Buffer_Size,
callback_type())
ETL_CONSTEXPR14 base64_rfc4648_url_encoder()
: ibase64_encoder(etl::base64::character_set_2(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_type())
, output_buffer()
{
}
@ -752,13 +677,8 @@ namespace etl
//*************************************************************************
/// Base64 RFC-4648-URL constructor.
//*************************************************************************
ETL_CONSTEXPR14
base64_rfc4648_url_encoder(callback_type callback_)
: ibase64_encoder(etl::base64::character_set_2(),
etl::base64::Padding::No_Padding,
output_buffer,
Buffer_Size,
callback_)
ETL_CONSTEXPR14 base64_rfc4648_url_encoder(callback_type callback_)
: ibase64_encoder(etl::base64::character_set_2(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_)
, output_buffer()
{
}
@ -768,8 +688,7 @@ namespace etl
//*************************************************************************
ETL_NODISCARD
static
ETL_CONSTEXPR14
size_t safe_output_buffer_size(size_t input_length)
ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
{
return ibase64_encoder::encoded_size(input_length, etl::base64::Padding::No_Padding);
}
@ -788,19 +707,15 @@ namespace etl
{
public:
ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Encode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Encode_Buffer_Size");
ETL_STATIC_ASSERT(((Buffer_Size% etl::base64::Min_Encode_Buffer_Size) == 0), "Buffer size must be a multiple of etl::base64::Min_Encode_Buffer_Size");
ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Encode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Encode_Buffer_Size");
ETL_STATIC_ASSERT(((Buffer_Size % etl::base64::Min_Encode_Buffer_Size) == 0),
"Buffer size must be a multiple of etl::base64::Min_Encode_Buffer_Size");
//*************************************************************************
/// Base64 RFC-4648-URL constructor.
//*************************************************************************
ETL_CONSTEXPR14
base64_rfc4648_url_padding_encoder()
: ibase64_encoder(etl::base64::character_set_2(),
etl::base64::Padding::Use_Padding,
output_buffer,
Buffer_Size,
callback_type())
ETL_CONSTEXPR14 base64_rfc4648_url_padding_encoder()
: ibase64_encoder(etl::base64::character_set_2(), etl::base64::Padding::Use_Padding, output_buffer, Buffer_Size, callback_type())
, output_buffer()
{
}
@ -808,13 +723,8 @@ namespace etl
//*************************************************************************
/// Base64 RFC-4648-URL constructor.
//*************************************************************************
ETL_CONSTEXPR14
base64_rfc4648_url_padding_encoder(callback_type callback_)
: ibase64_encoder(etl::base64::character_set_2(),
etl::base64::Padding::Use_Padding,
output_buffer,
Buffer_Size,
callback_)
ETL_CONSTEXPR14 base64_rfc4648_url_padding_encoder(callback_type callback_)
: ibase64_encoder(etl::base64::character_set_2(), etl::base64::Padding::Use_Padding, output_buffer, Buffer_Size, callback_)
, output_buffer()
{
}
@ -824,8 +734,7 @@ namespace etl
//*************************************************************************
ETL_NODISCARD
static
ETL_CONSTEXPR14
size_t safe_output_buffer_size(size_t input_length)
ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
{
return ibase64_encoder::encoded_size(input_length, etl::base64::Padding::Use_Padding);
}
@ -835,7 +744,7 @@ namespace etl
/// The internal output buffer.
char output_buffer[Buffer_Size];
};
}
} // namespace etl
#undef ETL_IS_TYPE_8_BIT_INTEGRAL
#undef ETL_IS_ITERATOR_TYPE_8_BIT_INTEGRAL

View File

@ -34,8 +34,9 @@ SOFTWARE.
///\ingroup string
#include "platform.h"
#include "type_traits.h"
#include "static_assert.h"
#include "type_traits.h"
#include "utility.h"
namespace etl
{
@ -130,7 +131,7 @@ namespace etl
struct right_spec
{
};
}
} // namespace private_basic_format_spec
//***************************************************************************
// Stream formatting manipulators.
@ -206,7 +207,7 @@ namespace etl
//***************************************************************************
/// Default constructor.
//***************************************************************************
ETL_CONSTEXPR basic_format_spec()
ETL_CONSTEXPR basic_format_spec() ETL_NOEXCEPT
: base_(10U)
, width_(0U)
, precision_(0U)
@ -221,14 +222,8 @@ namespace etl
//***************************************************************************
/// Constructor.
//***************************************************************************
ETL_CONSTEXPR basic_format_spec(uint_least8_t base__,
uint_least8_t width__,
uint_least8_t precision__,
bool upper_case__,
bool left_justified__,
bool boolalpha__,
bool show_base__,
typename TString::value_type fill__)
ETL_CONSTEXPR basic_format_spec(uint_least8_t base__, uint_least8_t width__, uint_least8_t precision__, bool upper_case__, bool left_justified__,
bool boolalpha__, bool show_base__, typename TString::value_type fill__) ETL_NOEXCEPT
: base_(base__)
, width_(width__)
, precision_(precision__)
@ -243,7 +238,7 @@ namespace etl
//***************************************************************************
/// Clears the format spec back to default.
//***************************************************************************
ETL_CONSTEXPR14 void clear()
ETL_CONSTEXPR14 void clear() ETL_NOEXCEPT
{
base_ = 10U;
width_ = 0U;
@ -259,56 +254,93 @@ namespace etl
/// Sets the base.
/// \return A reference to the basic_format_spec.
//***************************************************************************
ETL_CONSTEXPR14 basic_format_spec& base(uint32_t b)
ETL_CONSTEXPR14 basic_format_spec& base(uint32_t b) ETL_LVALUE_REF_QUALIFIER ETL_NOEXCEPT
{
base_ = static_cast<uint_least8_t>(b);
return *this;
}
#if ETL_USING_CPP11
/// @overload
ETL_CONSTEXPR14 basic_format_spec&& base(uint32_t b) ETL_RVALUE_REF_QUALIFIER ETL_NOEXCEPT
{
base_ = static_cast<uint_least8_t>(b);
return etl::move(*this);
}
#endif
//***************************************************************************
/// Sets the base to binary.
/// \return A reference to the basic_format_spec.
//***************************************************************************
ETL_CONSTEXPR14 basic_format_spec& binary()
ETL_CONSTEXPR14 basic_format_spec& binary() ETL_LVALUE_REF_QUALIFIER ETL_NOEXCEPT
{
base(2);
return *this;
return base(2);
}
#if ETL_USING_CPP11
/// @overload
ETL_CONSTEXPR14 basic_format_spec&& binary() ETL_RVALUE_REF_QUALIFIER ETL_NOEXCEPT
{
return etl::move(base(2));
}
#endif
//***************************************************************************
/// Sets the base to octal.
/// \return A reference to the basic_format_spec.
//***************************************************************************
ETL_CONSTEXPR14 basic_format_spec& octal()
ETL_CONSTEXPR14 basic_format_spec& octal() ETL_LVALUE_REF_QUALIFIER ETL_NOEXCEPT
{
base(8);
return *this;
return base(8);
}
#if ETL_USING_CPP11
/// @overload
ETL_CONSTEXPR14 basic_format_spec&& octal() ETL_RVALUE_REF_QUALIFIER ETL_NOEXCEPT
{
return etl::move(base(8));
}
#endif
//***************************************************************************
/// Sets the base to decimal.
/// \return A reference to the basic_format_spec.
//***************************************************************************
ETL_CONSTEXPR14 basic_format_spec& decimal()
ETL_CONSTEXPR14 basic_format_spec& decimal() ETL_LVALUE_REF_QUALIFIER ETL_NOEXCEPT
{
base(10);
return *this;
return base(10);
}
#if ETL_USING_CPP11
/// @overload
ETL_CONSTEXPR14 basic_format_spec&& decimal() ETL_RVALUE_REF_QUALIFIER ETL_NOEXCEPT
{
return etl::move(base(10));
}
#endif
//***************************************************************************
/// Sets the base to hex.
/// \return A reference to the basic_format_spec.
//***************************************************************************
ETL_CONSTEXPR14 basic_format_spec& hex()
ETL_CONSTEXPR14 basic_format_spec& hex() ETL_LVALUE_REF_QUALIFIER ETL_NOEXCEPT
{
base(16);
return *this;
return base(16);
}
#if ETL_USING_CPP11
/// @overload
ETL_CONSTEXPR14 basic_format_spec&& hex() ETL_RVALUE_REF_QUALIFIER ETL_NOEXCEPT
{
return etl::move(base(16));
}
#endif
//***************************************************************************
/// Gets the base.
//***************************************************************************
ETL_CONSTEXPR uint32_t get_base() const
ETL_CONSTEXPR uint32_t get_base() const ETL_NOEXCEPT
{
return base_;
}
@ -317,16 +349,25 @@ namespace etl
/// Sets the show base flag.
/// \return A reference to the basic_format_spec.
//***************************************************************************
ETL_CONSTEXPR14 basic_format_spec& show_base(bool b)
ETL_CONSTEXPR14 basic_format_spec& show_base(bool b) ETL_LVALUE_REF_QUALIFIER ETL_NOEXCEPT
{
show_base_ = b;
return *this;
}
#if ETL_USING_CPP11
/// @overload
ETL_CONSTEXPR14 basic_format_spec&& show_base(bool b) ETL_RVALUE_REF_QUALIFIER ETL_NOEXCEPT
{
show_base_ = b;
return etl::move(*this);
}
#endif
//***************************************************************************
/// Gets the show base flag.
//***************************************************************************
ETL_CONSTEXPR bool is_show_base() const
ETL_CONSTEXPR bool is_show_base() const ETL_NOEXCEPT
{
return show_base_;
}
@ -335,16 +376,25 @@ namespace etl
/// Sets the width.
/// \return A reference to the basic_format_spec.
//***************************************************************************
ETL_CONSTEXPR14 basic_format_spec& width(uint32_t w)
ETL_CONSTEXPR14 basic_format_spec& width(uint32_t w) ETL_LVALUE_REF_QUALIFIER ETL_NOEXCEPT
{
width_ = static_cast<uint_least8_t>(w);
return *this;
}
#if ETL_USING_CPP11
/// @overload
ETL_CONSTEXPR14 basic_format_spec&& width(uint32_t w) ETL_RVALUE_REF_QUALIFIER ETL_NOEXCEPT
{
width_ = static_cast<uint_least8_t>(w);
return etl::move(*this);
}
#endif
//***************************************************************************
/// Gets the width.
//***************************************************************************
ETL_CONSTEXPR uint32_t get_width() const
ETL_CONSTEXPR uint32_t get_width() const ETL_NOEXCEPT
{
return width_;
}
@ -353,16 +403,25 @@ namespace etl
/// Sets the precision.
/// \return A reference to the basic_format_spec.
//***************************************************************************
ETL_CONSTEXPR14 basic_format_spec& precision(uint32_t p)
ETL_CONSTEXPR14 basic_format_spec& precision(uint32_t p) ETL_LVALUE_REF_QUALIFIER ETL_NOEXCEPT
{
precision_ = static_cast<uint_least8_t>(p);
return *this;
}
#if ETL_USING_CPP11
/// @overload
ETL_CONSTEXPR14 basic_format_spec&& precision(uint32_t p) ETL_RVALUE_REF_QUALIFIER ETL_NOEXCEPT
{
precision_ = static_cast<uint_least8_t>(p);
return etl::move(*this);
}
#endif
//***************************************************************************
/// Gets the precision.
//***************************************************************************
ETL_CONSTEXPR uint32_t get_precision() const
ETL_CONSTEXPR uint32_t get_precision() const ETL_NOEXCEPT
{
return precision_;
}
@ -371,16 +430,25 @@ namespace etl
/// Sets the upper case flag.
/// \return A reference to the basic_format_spec.
//***************************************************************************
ETL_CONSTEXPR14 basic_format_spec& upper_case(bool u)
ETL_CONSTEXPR14 basic_format_spec& upper_case(bool u) ETL_LVALUE_REF_QUALIFIER ETL_NOEXCEPT
{
upper_case_ = u;
return *this;
}
#if ETL_USING_CPP11
/// @overload
ETL_CONSTEXPR14 basic_format_spec&& upper_case(bool u) ETL_RVALUE_REF_QUALIFIER ETL_NOEXCEPT
{
upper_case_ = u;
return etl::move(*this);
}
#endif
//***************************************************************************
/// Gets the upper case flag.
//***************************************************************************
ETL_CONSTEXPR bool is_upper_case() const
ETL_CONSTEXPR bool is_upper_case() const ETL_NOEXCEPT
{
return upper_case_;
}
@ -389,16 +457,25 @@ namespace etl
/// Sets the fill character.
/// \return A reference to the basic_format_spec.
//***************************************************************************
ETL_CONSTEXPR14 basic_format_spec& fill(typename TString::value_type c)
ETL_CONSTEXPR14 basic_format_spec& fill(typename TString::value_type c) ETL_LVALUE_REF_QUALIFIER ETL_NOEXCEPT
{
fill_ = c;
return *this;
}
#if ETL_USING_CPP11
/// @overload
ETL_CONSTEXPR14 basic_format_spec&& fill(typename TString::value_type c) ETL_RVALUE_REF_QUALIFIER ETL_NOEXCEPT
{
fill_ = c;
return etl::move(*this);
}
#endif
//***************************************************************************
/// Gets the fill character.
//***************************************************************************
ETL_CONSTEXPR typename TString::value_type get_fill() const
ETL_CONSTEXPR typename TString::value_type get_fill() const ETL_NOEXCEPT
{
return fill_;
}
@ -407,16 +484,25 @@ namespace etl
/// Sets the left justify flag.
/// \return A reference to the basic_format_spec.
//***************************************************************************
ETL_CONSTEXPR14 basic_format_spec& left()
ETL_CONSTEXPR14 basic_format_spec& left() ETL_LVALUE_REF_QUALIFIER ETL_NOEXCEPT
{
left_justified_ = true;
return *this;
}
#if ETL_USING_CPP11
/// @overload
ETL_CONSTEXPR14 basic_format_spec&& left() ETL_RVALUE_REF_QUALIFIER ETL_NOEXCEPT
{
left_justified_ = true;
return etl::move(*this);
}
#endif
//***************************************************************************
/// Gets the left justify flag.
//***************************************************************************
ETL_CONSTEXPR bool is_left() const
ETL_CONSTEXPR bool is_left() const ETL_NOEXCEPT
{
return left_justified_;
}
@ -425,16 +511,25 @@ namespace etl
/// Sets the right justify flag.
/// \return A reference to the basic_format_spec.
//***************************************************************************
ETL_CONSTEXPR14 basic_format_spec& right()
ETL_CONSTEXPR14 basic_format_spec& right() ETL_LVALUE_REF_QUALIFIER ETL_NOEXCEPT
{
left_justified_ = false;
return *this;
}
#if ETL_USING_CPP11
/// @overload
ETL_CONSTEXPR14 basic_format_spec&& right() ETL_RVALUE_REF_QUALIFIER ETL_NOEXCEPT
{
left_justified_ = false;
return etl::move(*this);
}
#endif
//***************************************************************************
/// Gets the right justify flag.
//***************************************************************************
ETL_CONSTEXPR bool is_right() const
ETL_CONSTEXPR bool is_right() const ETL_NOEXCEPT
{
return !left_justified_;
}
@ -443,16 +538,25 @@ namespace etl
/// Sets the bool alpha flag.
/// \return A reference to the basic_format_spec.
//***************************************************************************
ETL_CONSTEXPR14 basic_format_spec& boolalpha(bool b)
ETL_CONSTEXPR14 basic_format_spec& boolalpha(bool b) ETL_LVALUE_REF_QUALIFIER ETL_NOEXCEPT
{
boolalpha_ = b;
return *this;
}
#if ETL_USING_CPP11
/// @overload
ETL_CONSTEXPR14 basic_format_spec&& boolalpha(bool b) ETL_RVALUE_REF_QUALIFIER ETL_NOEXCEPT
{
boolalpha_ = b;
return etl::move(*this);
}
#endif
//***************************************************************************
/// Gets the boolalpha flag.
//***************************************************************************
ETL_CONSTEXPR bool is_boolalpha() const
ETL_CONSTEXPR bool is_boolalpha() const ETL_NOEXCEPT
{
return boolalpha_;
}
@ -460,37 +564,32 @@ namespace etl
//***************************************************************************
/// Equality operator.
//***************************************************************************
ETL_CONSTEXPR friend bool operator ==(const basic_format_spec& lhs, const basic_format_spec& rhs)
ETL_CONSTEXPR friend bool operator==(const basic_format_spec& lhs, const basic_format_spec& rhs)
{
return (lhs.base_ == rhs.base_) &&
(lhs.width_ == rhs.width_) &&
(lhs.precision_ == rhs.precision_) &&
(lhs.upper_case_ == rhs.upper_case_) &&
(lhs.left_justified_ == rhs.left_justified_) &&
(lhs.boolalpha_ == rhs.boolalpha_) &&
(lhs.show_base_ == rhs.show_base_) &&
(lhs.fill_ == rhs.fill_);
return (lhs.base_ == rhs.base_) && (lhs.width_ == rhs.width_) && (lhs.precision_ == rhs.precision_) && (lhs.upper_case_ == rhs.upper_case_)
&& (lhs.left_justified_ == rhs.left_justified_) && (lhs.boolalpha_ == rhs.boolalpha_) && (lhs.show_base_ == rhs.show_base_)
&& (lhs.fill_ == rhs.fill_);
}
//***************************************************************************
/// Inequality operator.
//***************************************************************************
ETL_CONSTEXPR friend bool operator !=(const basic_format_spec& lhs, const basic_format_spec& rhs)
ETL_CONSTEXPR friend bool operator!=(const basic_format_spec& lhs, const basic_format_spec& rhs)
{
return !(lhs == rhs);
}
private:
uint_least8_t base_;
uint_least8_t width_;
uint_least8_t precision_;
bool upper_case_;
bool left_justified_;
bool boolalpha_;
bool show_base_;
uint_least8_t base_;
uint_least8_t width_;
uint_least8_t precision_;
bool upper_case_;
bool left_justified_;
bool boolalpha_;
bool show_base_;
typename TString::value_type fill_;
};
}
} // namespace etl
#endif

File diff suppressed because it is too large Load Diff

View File

@ -35,6 +35,10 @@ SOFTWARE.
#include "platform.h"
#include "to_string.h"
#include "to_u16string.h"
#include "to_u32string.h"
#include "to_u8string.h"
#include "to_wstring.h"
namespace etl
{
@ -121,16 +125,17 @@ namespace etl
//*********************************
/// TFormat
//*********************************
friend basic_string_stream& operator <<(basic_string_stream& ss, const TFormat& fmt)
friend basic_string_stream& operator<<(basic_string_stream& ss, const TFormat& fmt)
{
ss.format = fmt;
return ss;
}
//*********************************
/// etl::base_spec from etl::setbase, etl::bin, etl::oct, etl::dec & etl::hex stream manipulators
/// etl::base_spec from etl::setbase, etl::bin, etl::oct, etl::dec &
/// etl::hex stream manipulators
//*********************************
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::base_spec fmt)
friend basic_string_stream& operator<<(basic_string_stream& ss, etl::private_basic_format_spec::base_spec fmt)
{
ss.format.base(fmt.base);
return ss;
@ -139,7 +144,7 @@ namespace etl
//*********************************
/// etl::width_spec from etl::setw stream manipulator
//*********************************
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::width_spec fmt)
friend basic_string_stream& operator<<(basic_string_stream& ss, etl::private_basic_format_spec::width_spec fmt)
{
ss.format.width(fmt.width);
return ss;
@ -149,7 +154,7 @@ namespace etl
/// etl::fill_spec from etl::setfill stream manipulator
//*********************************
template <typename TChar>
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::fill_spec<TChar> fmt)
friend basic_string_stream& operator<<(basic_string_stream& ss, etl::private_basic_format_spec::fill_spec<TChar> fmt)
{
ss.format.fill(fmt.fill);
return ss;
@ -158,34 +163,37 @@ namespace etl
//*********************************
/// etl::precision_spec from etl::setprecision stream manipulator
//*********************************
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::precision_spec fmt)
friend basic_string_stream& operator<<(basic_string_stream& ss, etl::private_basic_format_spec::precision_spec fmt)
{
ss.format.precision(fmt.precision);
return ss;
}
//*********************************
/// etl::boolalpha_spec from etl::boolalpha & etl::noboolalpha stream manipulators
/// etl::boolalpha_spec from etl::boolalpha & etl::noboolalpha stream
/// manipulators
//*********************************
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::boolalpha_spec fmt)
friend basic_string_stream& operator<<(basic_string_stream& ss, etl::private_basic_format_spec::boolalpha_spec fmt)
{
ss.format.boolalpha(fmt.boolalpha);
return ss;
}
//*********************************
/// etl::uppercase_spec from etl::uppercase & etl::nouppercase stream manipulators
/// etl::uppercase_spec from etl::uppercase & etl::nouppercase stream
/// manipulators
//*********************************
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::uppercase_spec fmt)
friend basic_string_stream& operator<<(basic_string_stream& ss, etl::private_basic_format_spec::uppercase_spec fmt)
{
ss.format.upper_case(fmt.upper_case);
return ss;
}
//*********************************
/// etl::showbase_spec from etl::showbase & etl::noshowbase stream manipulators
/// etl::showbase_spec from etl::showbase & etl::noshowbase stream
/// manipulators
//*********************************
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::showbase_spec fmt)
friend basic_string_stream& operator<<(basic_string_stream& ss, etl::private_basic_format_spec::showbase_spec fmt)
{
ss.format.show_base(fmt.show_base);
return ss;
@ -194,7 +202,7 @@ namespace etl
//*********************************
/// etl::left_spec from etl::left stream manipulator
//*********************************
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::left_spec /*fmt*/)
friend basic_string_stream& operator<<(basic_string_stream& ss, etl::private_basic_format_spec::left_spec /*fmt*/)
{
ss.format.left();
return ss;
@ -203,7 +211,7 @@ namespace etl
//*********************************
/// etl::right_spec from etl::left stream manipulator
//*********************************
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::right_spec /*fmt*/)
friend basic_string_stream& operator<<(basic_string_stream& ss, etl::private_basic_format_spec::right_spec /*fmt*/)
{
ss.format.right();
return ss;
@ -212,7 +220,7 @@ namespace etl
//*********************************
/// From a string view
//*********************************
friend basic_string_stream& operator <<(basic_string_stream& ss, TStringView view)
friend basic_string_stream& operator<<(basic_string_stream& ss, TStringView view)
{
etl::to_string(view, ss.text, ss.format, true);
return ss;
@ -221,7 +229,7 @@ namespace etl
//*********************************
/// From a character pointer to a string
//*********************************
friend basic_string_stream& operator <<(basic_string_stream& ss, pointer p)
friend basic_string_stream& operator<<(basic_string_stream& ss, pointer p)
{
TStringView view(p);
ss << view;
@ -231,7 +239,7 @@ namespace etl
//*********************************
/// From a const character pointer to a string
//*********************************
friend basic_string_stream& operator <<(basic_string_stream& ss, const_pointer p)
friend basic_string_stream& operator<<(basic_string_stream& ss, const_pointer p)
{
TStringView view(p);
ss << view;
@ -241,7 +249,7 @@ namespace etl
//*********************************
/// From a string interface
//*********************************
friend basic_string_stream& operator <<(basic_string_stream& ss, const TIString& t)
friend basic_string_stream& operator<<(basic_string_stream& ss, const TIString& t)
{
etl::to_string(t, ss.text, ss.format, true);
return ss;
@ -251,7 +259,7 @@ namespace etl
/// From a string
//*********************************
template <template <size_t> class TString, size_t SIZE>
friend basic_string_stream& operator <<(basic_string_stream& ss, const TString<SIZE>& t)
friend basic_string_stream& operator<<(basic_string_stream& ss, const TString<SIZE>& t)
{
const TIString& itext = t;
etl::to_string(itext, ss.str(), ss.get_format(), true);
@ -262,7 +270,7 @@ namespace etl
/// From anything else
//*********************************
template <typename T>
friend basic_string_stream& operator <<(basic_string_stream& ss, const T& value)
friend basic_string_stream& operator<<(basic_string_stream& ss, const T& value)
{
etl::to_string(value, ss.text, ss.format, true);
return ss;
@ -274,8 +282,8 @@ namespace etl
TFormat format;
basic_string_stream(const basic_string_stream&) ETL_DELETE;
basic_string_stream& operator =(const basic_string_stream&) ETL_DELETE;
basic_string_stream& operator=(const basic_string_stream&) ETL_DELETE;
};
}
} // namespace etl
#endif

File diff suppressed because it is too large Load Diff

View File

@ -40,15 +40,15 @@ SOFTWARE.
#include "platform.h"
#include "alignment.h"
#include "parameter_type.h"
#include "atomic.h"
#include "error_handler.h"
#include "file_error_numbers.h"
#include "integral_limits.h"
#include "memory.h"
#include "memory_model.h"
#include "integral_limits.h"
#include "utility.h"
#include "error_handler.h"
#include "parameter_type.h"
#include "span.h"
#include "file_error_numbers.h"
#include "utility.h"
#include <stddef.h>
#include <stdint.h>
@ -60,12 +60,12 @@ namespace etl
//***************************************************************************
/// Base exception for a bip buffer.
//***************************************************************************
class bip_buffer_exception: public exception
class bip_buffer_exception : public exception
{
public:
bip_buffer_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
: exception(reason_, file_name_, line_number_)
: exception(reason_, file_name_, line_number_)
{
}
};
@ -73,7 +73,7 @@ namespace etl
//***************************************************************************
/// Exception for an invalid reserve.
//***************************************************************************
class bip_buffer_reserve_invalid: public bip_buffer_exception
class bip_buffer_reserve_invalid : public bip_buffer_exception
{
public:
@ -117,7 +117,7 @@ namespace etl
size_type size() const
{
size_type write_index = write.load(etl::memory_order_acquire);
size_type read_index = read.load(etl::memory_order_acquire);
size_type read_index = read.load(etl::memory_order_acquire);
// no wraparound
if (write_index >= read_index)
@ -140,7 +140,7 @@ namespace etl
size_type available() const
{
size_type write_index = write.load(etl::memory_order_acquire);
size_type read_index = read.load(etl::memory_order_acquire);
size_type read_index = read.load(etl::memory_order_acquire);
// no wraparound
if (write_index >= read_index)
@ -185,10 +185,10 @@ namespace etl
/// Constructs the buffer.
//*************************************************************************
bip_buffer_spsc_atomic_base(size_type reserved_)
: read(0)
, write(0)
, last(0)
, Reserved(reserved_)
: read(0)
, write(0)
, last(0)
, Reserved(reserved_)
{
}
@ -204,7 +204,7 @@ namespace etl
size_type get_write_reserve(size_type* psize, size_type fallback_size = numeric_limits<size_type>::max())
{
size_type write_index = write.load(etl::memory_order_relaxed);
size_type read_index = read.load(etl::memory_order_acquire);
size_type read_index = read.load(etl::memory_order_acquire);
// No wraparound
if (write_index >= read_index)
@ -262,7 +262,7 @@ namespace etl
if (wsize > 0)
{
size_type write_index = write.load(etl::memory_order_relaxed);
size_type read_index = read.load(etl::memory_order_acquire);
size_type read_index = read.load(etl::memory_order_acquire);
// Wrapped around already
if (write_index < read_index)
@ -281,8 +281,11 @@ namespace etl
else
{
ETL_ASSERT_OR_RETURN((windex == 0) && ((wsize + 1) <= read_index), ETL_ERROR(bip_buffer_reserve_invalid));
// Correct wrapping point
last.store(write_index, etl::memory_order_release);
}
// Always update write index
write.store(windex + wsize, etl::memory_order_release);
}
@ -291,7 +294,7 @@ namespace etl
//*************************************************************************
size_type get_read_reserve(size_type* psize)
{
size_type read_index = read.load(etl::memory_order_relaxed);
size_type read_index = read.load(etl::memory_order_relaxed);
size_type write_index = write.load(etl::memory_order_acquire);
if (read_index > write_index)
@ -341,21 +344,19 @@ namespace etl
etl::atomic<size_type> read;
etl::atomic<size_type> write;
etl::atomic<size_type> last;
const size_type Reserved;
const size_type Reserved;
#if defined(ETL_POLYMORPHIC_SPSC_BIP_BUFFER_ATOMIC) || defined(ETL_POLYMORPHIC_CONTAINERS)
#if defined(ETL_POLYMORPHIC_SPSC_BIP_BUFFER_ATOMIC) || defined(ETL_POLYMORPHIC_CONTAINERS)
public:
virtual ~bip_buffer_spsc_atomic_base()
{
}
#else
virtual ~bip_buffer_spsc_atomic_base() {}
#else
protected:
~bip_buffer_spsc_atomic_base()
{
}
#endif
~bip_buffer_spsc_atomic_base() {}
#endif
};
//***************************************************************************
@ -367,21 +368,21 @@ namespace etl
private:
typedef typename etl::bip_buffer_spsc_atomic_base<Memory_Model> base_t;
using base_t::reset;
using base_t::get_read_reserve;
using base_t::apply_read_reserve;
using base_t::get_write_reserve;
using base_t::apply_write_reserve;
using base_t::get_read_reserve;
using base_t::get_write_reserve;
using base_t::reset;
public:
typedef T value_type; ///< The type stored in the buffer.
typedef T& reference; ///< A reference to the type used in the buffer.
typedef const T& const_reference; ///< A const reference to the type used in the buffer.
#if ETL_USING_CPP11
typedef T&& rvalue_reference;///< An rvalue_reference to the type used in the buffer.
#endif
typedef typename base_t::size_type size_type; ///< The type used for determining the size of the buffer.
typedef T value_type; ///< The type stored in the buffer.
typedef T& reference; ///< A reference to the type used in the buffer.
typedef const T& const_reference; ///< A const reference to the type used in the buffer.
#if ETL_USING_CPP11
typedef T&& rvalue_reference; ///< An rvalue_reference to the type used in the buffer.
#endif
typedef typename base_t::size_type size_type; ///< The type used for determining the size of the buffer.
using base_t::max_size;
@ -391,8 +392,8 @@ namespace etl
span<T> read_reserve(size_type max_reserve_size = numeric_limits<size_type>::max())
{
size_type reserve_size = max_reserve_size;
size_type rindex = get_read_reserve(&reserve_size);
size_type rindex = get_read_reserve(&reserve_size);
return span<T>(p_buffer + rindex, reserve_size);
}
@ -401,7 +402,7 @@ namespace etl
// the reserve can be trimmed at the end before committing.
// Throws bip_buffer_reserve_invalid
//*************************************************************************
void read_commit(const span<T> &reserve)
void read_commit(const span<T>& reserve)
{
size_type rindex = etl::distance(p_buffer, reserve.data());
apply_read_reserve(rindex, reserve.size());
@ -413,8 +414,8 @@ namespace etl
span<T> write_reserve(size_type max_reserve_size)
{
size_type reserve_size = max_reserve_size;
size_type windex = get_write_reserve(&reserve_size);
size_type windex = get_write_reserve(&reserve_size);
return span<T>(p_buffer + windex, reserve_size);
}
@ -424,10 +425,10 @@ namespace etl
//*************************************************************************
span<T> write_reserve_optimal(size_type min_reserve_size = 1U)
{
size_type reserve_size = numeric_limits<size_type>::max();
size_type windex = get_write_reserve(&reserve_size, min_reserve_size);
size_type reserve_size = numeric_limits<size_type>::max();
size_type windex = get_write_reserve(&reserve_size, min_reserve_size);
return span<T>(p_buffer + windex, reserve_size);
return span<T>(p_buffer + windex, reserve_size);
}
//*************************************************************************
@ -435,7 +436,7 @@ namespace etl
// the reserve can be trimmed at the end before committing.
// Throws bip_buffer_reserve_invalid
//*************************************************************************
void write_commit(const span<T> &reserve)
void write_commit(const span<T>& reserve)
{
size_type windex = etl::distance(p_buffer, reserve.data());
apply_write_reserve(windex, reserve.size());
@ -472,12 +473,12 @@ namespace etl
// Disable copy construction and assignment.
ibip_buffer_spsc_atomic(const ibip_buffer_spsc_atomic&) ETL_DELETE;
ibip_buffer_spsc_atomic& operator =(const ibip_buffer_spsc_atomic&) ETL_DELETE;
ibip_buffer_spsc_atomic& operator=(const ibip_buffer_spsc_atomic&) ETL_DELETE;
#if ETL_USING_CPP11
ibip_buffer_spsc_atomic(ibip_buffer_spsc_atomic&&) = delete;
ibip_buffer_spsc_atomic& operator =(ibip_buffer_spsc_atomic&&) = delete;
#endif
#if ETL_USING_CPP11
ibip_buffer_spsc_atomic(ibip_buffer_spsc_atomic&&) = delete;
ibip_buffer_spsc_atomic& operator=(ibip_buffer_spsc_atomic&&) = delete;
#endif
T* const p_buffer;
};
@ -487,7 +488,8 @@ namespace etl
/// This buffer supports concurrent access by one producer and one consumer.
/// \tparam T The type this buffer should support.
/// \tparam Size The maximum capacity of the buffer.
/// \tparam Memory_Model The memory model for the buffer. Determines the type of the internal counter variables.
/// \tparam Memory_Model The memory model for the buffer. Determines the type
/// of the internal counter variables.
//***************************************************************************
template <typename T, const size_t Size, const size_t Memory_Model = etl::memory_model::MEMORY_MODEL_LARGE>
class bip_buffer_spsc_atomic : public ibip_buffer_spsc_atomic<T, Memory_Model>
@ -526,15 +528,15 @@ namespace etl
base_t::clear();
}
private:
private:
/// The uninitialised buffer of T used in the bip_buffer_spsc.
etl::uninitialized_buffer_of<T, Reserved_Size> buffer;
};
template <typename T, const size_t Size, const size_t Memory_Model>
template <typename T, const size_t Size, const size_t Memory_Model>
ETL_CONSTANT typename bip_buffer_spsc_atomic<T, Size, Memory_Model>::size_type bip_buffer_spsc_atomic<T, Size, Memory_Model>::Reserved_Size;
}
} // namespace etl
#endif /* ETL_HAS_ATOMIC && ETL_USING_CPP11 */

View File

@ -32,10 +32,9 @@ SOFTWARE.
#define ETL_BIT_INCLUDED
#include "platform.h"
#include "type_traits.h"
#include "binary.h"
#include "integral_limits.h"
#include "endianness.h"
#include "integral_limits.h"
#include "type_traits.h"
#include <string.h>
@ -51,11 +50,9 @@ namespace etl
//***************************************************************************
template <typename TDestination, typename TSource>
ETL_NODISCARD
typename etl::enable_if<!(etl::is_integral<TDestination>::value&& etl::is_integral<TSource>::value) &&
(sizeof(TDestination) == sizeof(TSource)) &&
etl::is_trivially_copyable<TSource>::value &&
etl::is_trivially_copyable<TDestination>::value, TDestination>::type
bit_cast(const TSource& source) ETL_NOEXCEPT
typename etl::enable_if< !(etl::is_integral<TDestination>::value && etl::is_integral<TSource>::value) && (sizeof(TDestination) == sizeof(TSource))
&& etl::is_trivially_copyable<TSource>::value && etl::is_trivially_copyable<TDestination>::value,
TDestination>::type bit_cast(const TSource& source) ETL_NOEXCEPT
{
TDestination destination;
@ -68,11 +65,9 @@ namespace etl
/// bit_cast - Integral to integral
//***************************************************************************
template <typename TDestination, typename TSource>
ETL_NODISCARD
ETL_CONSTEXPR14
typename etl::enable_if<(etl::is_integral<TDestination>::value && etl::is_integral<TSource>::value) &&
(sizeof(TDestination) == sizeof(TSource)), TDestination>::type
bit_cast(const TSource& source) ETL_NOEXCEPT
ETL_NODISCARD ETL_CONSTEXPR14
typename etl::enable_if< (etl::is_integral<TDestination>::value && etl::is_integral<TSource>::value) && (sizeof(TDestination) == sizeof(TSource)),
TDestination>::type bit_cast(const TSource& source) ETL_NOEXCEPT
{
return static_cast<TDestination>(source);
}
@ -81,9 +76,7 @@ namespace etl
/// byteswap
//***************************************************************************
template <typename T>
ETL_CONSTEXPR14
typename etl::enable_if<etl::is_integral<T>::value, T>::type
byteswap(T value) ETL_NOEXCEPT
ETL_CONSTEXPR14 typename etl::enable_if<etl::is_integral<T>::value, T>::type byteswap(T value) ETL_NOEXCEPT
{
return etl::reverse_bytes(value);
}
@ -92,8 +85,7 @@ namespace etl
/// has_single_bit
//***************************************************************************
template <typename T>
ETL_NODISCARD ETL_CONSTEXPR14
typename etl::enable_if<etl::is_unsigned<T>::value, bool>::type has_single_bit(T value) ETL_NOEXCEPT
ETL_NODISCARD ETL_CONSTEXPR14 typename etl::enable_if<etl::is_unsigned<T>::value, bool>::type has_single_bit(T value) ETL_NOEXCEPT
{
return (value & (value - 1)) == 0;
}
@ -101,9 +93,7 @@ namespace etl
/// countl_zero
//***************************************************************************
template <typename T>
ETL_NODISCARD ETL_CONSTEXPR14
typename etl::enable_if<etl::is_unsigned<T>::value, int>::type
countl_zero(T value) ETL_NOEXCEPT
ETL_NODISCARD ETL_CONSTEXPR14 typename etl::enable_if<etl::is_unsigned<T>::value, int>::type countl_zero(T value) ETL_NOEXCEPT
{
return etl::count_leading_zeros(value);
}
@ -112,9 +102,7 @@ namespace etl
/// countl_one
//***************************************************************************
template <typename T>
ETL_NODISCARD ETL_CONSTEXPR14
typename etl::enable_if<etl::is_unsigned<T>::value, int>::type
countl_one(T value) ETL_NOEXCEPT
ETL_NODISCARD ETL_CONSTEXPR14 typename etl::enable_if<etl::is_unsigned<T>::value, int>::type countl_one(T value) ETL_NOEXCEPT
{
return etl::count_leading_ones(value);
}
@ -123,9 +111,7 @@ namespace etl
/// countr_zero
//***************************************************************************
template <typename T>
ETL_NODISCARD ETL_CONSTEXPR14
typename etl::enable_if<etl::is_unsigned<T>::value, int>::type
countr_zero(T value) ETL_NOEXCEPT
ETL_NODISCARD ETL_CONSTEXPR14 typename etl::enable_if<etl::is_unsigned<T>::value, int>::type countr_zero(T value) ETL_NOEXCEPT
{
return etl::count_trailing_zeros(value);
}
@ -134,26 +120,21 @@ namespace etl
/// countr_one
//***************************************************************************
template <typename T>
ETL_NODISCARD ETL_CONSTEXPR14
typename etl::enable_if<etl::is_unsigned<T>::value, int>::type
countr_one(T value) ETL_NOEXCEPT
ETL_NODISCARD ETL_CONSTEXPR14 typename etl::enable_if<etl::is_unsigned<T>::value, int>::type countr_one(T value) ETL_NOEXCEPT
{
return etl::count_trailing_ones(value);;
return etl::count_trailing_ones(value);
}
//***************************************************************************
/// bit_width
//***************************************************************************
template <typename T>
ETL_CONSTEXPR14
typename etl::enable_if<etl::is_unsigned<T>::value, T>::type
bit_width(T value) ETL_NOEXCEPT
ETL_CONSTEXPR14 typename etl::enable_if<etl::is_unsigned<T>::value, T>::type bit_width(T value) ETL_NOEXCEPT
{
#if ETL_USING_CPP20 && ETL_USING_STL
return std::bit_width(value);
return static_cast<T>(std::bit_width(value));
#else
return etl::integral_limits<T>::bits - etl::countl_zero(value);
return static_cast<T>(etl::integral_limits<T>::bits - etl::countl_zero(value));
#endif
}
@ -161,9 +142,7 @@ namespace etl
/// bit_ceil
//***************************************************************************
template <typename T>
ETL_NODISCARD ETL_CONSTEXPR14
typename etl::enable_if<etl::is_unsigned<T>::value, T>::type
bit_ceil(T value)
ETL_NODISCARD ETL_CONSTEXPR14 typename etl::enable_if<etl::is_unsigned<T>::value, T>::type bit_ceil(T value)
{
#if ETL_USING_CPP20 && ETL_USING_STL
return std::bit_ceil(value);
@ -183,9 +162,7 @@ namespace etl
/// bit_floor
//***************************************************************************
template <typename T>
ETL_NODISCARD ETL_CONSTEXPR14
typename etl::enable_if<etl::is_unsigned<T>::value, T>::type
bit_floor(T value) ETL_NOEXCEPT
ETL_NODISCARD ETL_CONSTEXPR14 typename etl::enable_if<etl::is_unsigned<T>::value, T>::type bit_floor(T value) ETL_NOEXCEPT
{
#if ETL_USING_CPP20 && ETL_USING_STL
return std::bit_floor(value);
@ -205,17 +182,15 @@ namespace etl
/// rotl
//***************************************************************************
template <typename T>
ETL_NODISCARD ETL_CONSTEXPR14
typename etl::enable_if<etl::is_unsigned<T>::value, T>::type
rotl(T value, int n) ETL_NOEXCEPT
ETL_NODISCARD ETL_CONSTEXPR14 typename etl::enable_if<etl::is_unsigned<T>::value, T>::type rotl(T value, int n) ETL_NOEXCEPT
{
if (n < 0)
{
return etl::rotate_right(value, -n);
return etl::rotate_right(value, static_cast<size_t>(-n));
}
else
{
return etl::rotate_left(value, n);
return etl::rotate_left(value, static_cast<size_t>(n));
}
}
@ -223,30 +198,26 @@ namespace etl
/// rotr
//***************************************************************************
template <typename T>
ETL_NODISCARD ETL_CONSTEXPR14
typename etl::enable_if<etl::is_unsigned<T>::value, T>::type
rotr(T value, int n) ETL_NOEXCEPT
ETL_NODISCARD ETL_CONSTEXPR14 typename etl::enable_if<etl::is_unsigned<T>::value, T>::type rotr(T value, int n) ETL_NOEXCEPT
{
if (n < 0)
{
return etl::rotate_left(value, -n);
return etl::rotate_left(value, static_cast<size_t>(-n));
}
else
{
return etl::rotate_right(value, n);
return etl::rotate_right(value, static_cast<size_t>(n));
}
}
//***************************************************************************
/// popcount
//***************************************************************************
template <typename T>
ETL_NODISCARD ETL_CONSTEXPR14
typename etl::enable_if<etl::is_unsigned<T>::value, int>::type
popcount(T value) ETL_NOEXCEPT
ETL_NODISCARD ETL_CONSTEXPR14 typename etl::enable_if<etl::is_unsigned<T>::value, int>::type popcount(T value) ETL_NOEXCEPT
{
return etl::count_bits(value);
}
}
} // namespace etl
#endif

View File

@ -27,22 +27,22 @@ SOFTWARE.
#define ETL_BIT_STREAM_INCLUDED
#include "platform.h"
#include "type_traits.h"
#include "nullptr.h"
#include "endianness.h"
#include "integral_limits.h"
#include "binary.h"
#include "algorithm.h"
#include "binary.h"
#include "delegate.h"
#include "endianness.h"
#include "error_handler.h"
#include "exception.h"
#include "integral_limits.h"
#include "iterator.h"
#include "memory.h"
#include "delegate.h"
#include "span.h"
#include "nullptr.h"
#include "optional.h"
#include "exception.h"
#include "error_handler.h"
#include "span.h"
#include "type_traits.h"
#include <stdint.h>
#include <limits.h>
#include <stdint.h>
#include "private/minmax_push.h"
@ -73,7 +73,7 @@ namespace etl
//***************************************************************************
bit_stream(void* begin_, void* end_)
: pdata(reinterpret_cast<unsigned char*>(begin_))
, length_chars(etl::distance(reinterpret_cast<unsigned char*>(begin_), reinterpret_cast<unsigned char*>(end_)))
, length_chars(static_cast<size_t>(etl::distance(reinterpret_cast<unsigned char*>(begin_), reinterpret_cast<unsigned char*>(end_))))
{
restart();
}
@ -93,7 +93,7 @@ namespace etl
//***************************************************************************
void set_stream(void* begin_, size_t length_)
{
pdata = reinterpret_cast<unsigned char*>(begin_);
pdata = reinterpret_cast<unsigned char*>(begin_);
length_chars = length_;
restart();
}
@ -103,7 +103,7 @@ namespace etl
//***************************************************************************
void set_stream(void* begin_, void* end_)
{
set_stream(begin_, etl::distance(reinterpret_cast<unsigned char*>(begin_), reinterpret_cast<unsigned char*>(end_)));
set_stream(begin_, static_cast<size_t>(etl::distance(reinterpret_cast<unsigned char*>(begin_), reinterpret_cast<unsigned char*>(end_))));
}
//***************************************************************************
@ -112,8 +112,8 @@ namespace etl
void restart()
{
bits_available_in_char = CHAR_BIT;
char_index = 0U;
bits_available = CHAR_BIT * length_chars;
char_index = 0U;
bits_available = CHAR_BIT * length_chars;
}
//***************************************************************************
@ -148,8 +148,7 @@ namespace etl
/// For integral types
//***************************************************************************
template <typename T>
typename etl::enable_if<etl::is_integral<T>::value, bool>::type
put(T value, uint_least8_t nbits = CHAR_BIT * sizeof(T))
typename etl::enable_if<etl::is_integral<T>::value, bool>::type put(T value, uint_least8_t nbits = CHAR_BIT * sizeof(T))
{
return put_integral(static_cast<uint32_t>(value), nbits);
}
@ -176,8 +175,7 @@ namespace etl
/// For floating point types
//***************************************************************************
template <typename T>
typename etl::enable_if<etl::is_floating_point<T>::value, bool>::type
put(T value)
typename etl::enable_if<etl::is_floating_point<T>::value, bool>::type put(T value)
{
bool success = true;
@ -207,7 +205,7 @@ namespace etl
// Do we have enough bits?
if (bits_available > 0U)
{
value = get_bit();
value = get_bit();
success = true;
}
}
@ -219,11 +217,10 @@ namespace etl
/// For integral types
//***************************************************************************
template <typename T>
typename etl::enable_if<etl::is_integral<T>::value, bool>::type
get(T& value, uint_least8_t nbits = CHAR_BIT * sizeof(T))
typename etl::enable_if<etl::is_integral<T>::value, bool>::type get(T& value, uint_least8_t nbits = CHAR_BIT * sizeof(T))
{
bool success = false;
uint_least8_t bits = nbits;
bool success = false;
uint_least8_t bits = nbits;
if (pdata != ETL_NULLPTR)
{
@ -238,7 +235,7 @@ namespace etl
unsigned char mask_width = static_cast<unsigned char>(etl::min(nbits, bits_available_in_char));
typedef typename etl::make_unsigned<T>::type chunk_t;
chunk_t chunk = get_chunk(mask_width);
chunk_t chunk = get_chunk(mask_width);
nbits -= mask_width;
value |= static_cast<T>(chunk << nbits);
@ -252,7 +249,7 @@ namespace etl
if (etl::is_signed<T>::value && (bits != (CHAR_BIT * sizeof(T))))
{
typedef typename etl::make_signed<T>::type ST;
value = etl::sign_extend<ST, ST>(value, bits);
value = static_cast<T>(etl::sign_extend<ST, ST>(static_cast<ST>(value), bits));
}
return success;
@ -262,8 +259,7 @@ namespace etl
/// For floating point types
//***************************************************************************
template <typename T>
typename etl::enable_if<etl::is_floating_point<T>::value, bool>::type
get(T& value)
typename etl::enable_if<etl::is_floating_point<T>::value, bool>::type get(T& value)
{
bool success = false;
@ -279,7 +275,7 @@ namespace etl
for (size_t i = 0UL; i < sizeof(T); ++i)
{
get(data.raw[i], CHAR_BIT);
get(data.raw[i], CHAR_BIT);
}
from_bytes(reinterpret_cast<const unsigned char*>(data.raw), value);
@ -351,7 +347,7 @@ namespace etl
unsigned char mask_width = static_cast<unsigned char>(etl::min(nbits, bits_available_in_char));
nbits -= mask_width;
uint32_t mask = ((1U << mask_width) - 1U) << nbits;
//uint32_t mask = ((uint32_t(1U) << mask_width) - 1U) << nbits;
// uint32_t mask = ((uint32_t(1U) << mask_width) - 1U) << nbits;
// Move chunk to lowest char bits.
// Chunks are never larger than one char.
@ -422,7 +418,7 @@ namespace etl
//***************************************************************************
unsigned char get_chunk(unsigned char nbits)
{
unsigned char value = pdata[char_index];
unsigned char value = static_cast<unsigned char>(pdata[char_index]);
value >>= (bits_available_in_char - nbits);
@ -434,7 +430,7 @@ namespace etl
}
else
{
mask = (1U << nbits) - 1;
mask = static_cast<unsigned char>((1U << nbits) - 1);
}
value &= mask;
@ -449,7 +445,7 @@ namespace etl
//***************************************************************************
bool get_bit()
{
bool result = (pdata[char_index] & (1U << (bits_available_in_char - 1U))) != 0U;
bool result = (static_cast<unsigned char>(pdata[char_index]) & (1U << (bits_available_in_char - 1U))) != 0U;
step(1U);
@ -467,11 +463,11 @@ namespace etl
// Network to host.
if (etl::endianness::value() == etl::endian::little)
{
etl::reverse_copy(data, data + sizeof(T), temp.raw);
etl::reverse_copy(data, data + sizeof(T), reinterpret_cast<unsigned char*>(temp.raw));
}
else
{
etl::copy(data, data + sizeof(T), temp.raw);
etl::copy(data, data + sizeof(T), reinterpret_cast<unsigned char*>(temp.raw));
}
value = *reinterpret_cast<T*>(temp.raw);
@ -513,11 +509,13 @@ namespace etl
bits_available -= nbits;
}
unsigned char *pdata; ///< The start of the bitstream buffer.
size_t length_chars; ///< The length, in char, of the bitstream buffer.
unsigned char bits_available_in_char; ///< The number of available bits in the current char.
size_t char_index; ///< The index of the char in the bitstream buffer.
size_t bits_available; ///< The number of bits still available in the bitstream buffer.
unsigned char* pdata; ///< The start of the bitstream buffer.
size_t length_chars; ///< The length, in char, of the bitstream buffer.
unsigned char bits_available_in_char; ///< The number of available bits in
///< the current char.
size_t char_index; ///< The index of the char in the bitstream buffer.
size_t bits_available; ///< The number of bits still available in the
///< bitstream buffer.
};
//***************************************************************************
@ -527,10 +525,10 @@ namespace etl
{
public:
typedef char value_type;
typedef value_type* iterator;
typedef const value_type* const_iterator;
typedef etl::span<value_type> callback_parameter_type;
typedef char value_type;
typedef value_type* iterator;
typedef const value_type* const_iterator;
typedef etl::span<value_type> callback_parameter_type;
typedef etl::delegate<void(callback_parameter_type)> callback_type;
//***************************************************************************
@ -564,7 +562,7 @@ namespace etl
//***************************************************************************
bit_stream_writer(void* begin_, void* end_, etl::endian stream_endianness_, callback_type callback_ = callback_type())
: pdata(reinterpret_cast<char*>(begin_))
, length_chars(etl::distance(reinterpret_cast<unsigned char*>(begin_), reinterpret_cast<unsigned char*>(end_)))
, length_chars(static_cast<size_t>(etl::distance(reinterpret_cast<unsigned char*>(begin_), reinterpret_cast<unsigned char*>(end_))))
, stream_endianness(stream_endianness_)
, callback(callback_)
{
@ -589,8 +587,8 @@ namespace etl
void restart()
{
bits_available_in_char = CHAR_BIT;
char_index = 0U;
bits_available = capacity_bits();
char_index = 0U;
bits_available = capacity_bits();
}
//***************************************************************************
@ -653,8 +651,7 @@ namespace etl
/// For integral types
//***************************************************************************
template <typename T>
typename etl::enable_if<etl::is_integral<T>::value, void>::type
write_unchecked(T value, uint_least8_t nbits = CHAR_BIT * sizeof(T))
typename etl::enable_if<etl::is_integral<T>::value, void>::type write_unchecked(T value, uint_least8_t nbits = CHAR_BIT * sizeof(T))
{
typedef typename etl::unsigned_type<T>::type unsigned_t;
@ -665,8 +662,7 @@ namespace etl
/// For integral types
//***************************************************************************
template <typename T>
typename etl::enable_if<etl::is_integral<T>::value, bool>::type
write(T value, uint_least8_t nbits = CHAR_BIT * sizeof(T))
typename etl::enable_if<etl::is_integral<T>::value, bool>::type write(T value, uint_least8_t nbits = CHAR_BIT * sizeof(T))
{
bool success = (available(nbits) > 0U);
@ -975,10 +971,12 @@ namespace etl
char* const pdata; ///< The start of the bitstream buffer.
const size_t length_chars; ///< The length of the bitstream buffer.
const etl::endian stream_endianness; ///< The endianness of the stream data.
unsigned char bits_available_in_char; ///< The number of available bits in the current char.
size_t char_index; ///< The index of the current char in the bitstream buffer.
size_t bits_available; ///< The number of bits still available in the bitstream buffer.
callback_type callback; ///< An optional callback on every filled byte in buffer.
unsigned char bits_available_in_char; ///< The number of available bits in
///< the current char.
size_t char_index; ///< The index of the current char in the bitstream buffer.
size_t bits_available; ///< The number of bits still available in the
///< bitstream buffer.
callback_type callback; ///< An optional callback on every filled byte in buffer.
};
//***************************************************************************
@ -1005,8 +1003,8 @@ namespace etl
/// Overload this to support custom types.
//***************************************************************************
template <typename T>
typename etl::enable_if<etl::is_integral<T>::value, void>::type
write_unchecked(etl::bit_stream_writer& stream, const T& value, uint_least8_t nbits = CHAR_BIT * sizeof(T))
typename etl::enable_if<etl::is_integral<T>::value, void>::type write_unchecked(etl::bit_stream_writer& stream, const T& value,
uint_least8_t nbits = CHAR_BIT * sizeof(T))
{
stream.write_unchecked(value, nbits);
}
@ -1017,8 +1015,8 @@ namespace etl
/// Overload this to support custom types.
//***************************************************************************
template <typename T>
typename etl::enable_if<etl::is_integral<T>::value, bool>::type
write(etl::bit_stream_writer& stream, const T& value, uint_least8_t nbits = CHAR_BIT * sizeof(T))
typename etl::enable_if<etl::is_integral<T>::value, bool>::type write(etl::bit_stream_writer& stream, const T& value,
uint_least8_t nbits = CHAR_BIT * sizeof(T))
{
return stream.write(value, nbits);
}
@ -1030,7 +1028,7 @@ namespace etl
{
public:
typedef char value_type;
typedef char value_type;
typedef const char* const_iterator;
//***************************************************************************
@ -1086,7 +1084,7 @@ namespace etl
//***************************************************************************
bit_stream_reader(const void* begin_, const void* end_, etl::endian stream_endianness_)
: pdata(reinterpret_cast<const char*>(begin_))
, length_chars(etl::distance(reinterpret_cast<const char*>(begin_), reinterpret_cast<const char*>(end_)))
, length_chars(static_cast<size_t>(etl::distance(reinterpret_cast<const char*>(begin_), reinterpret_cast<const char*>(end_))))
, stream_endianness(stream_endianness_)
{
restart();
@ -1109,16 +1107,15 @@ namespace etl
void restart()
{
bits_available_in_char = CHAR_BIT;
char_index = 0U;
bits_available = CHAR_BIT * length_chars;
char_index = 0U;
bits_available = CHAR_BIT * length_chars;
}
//***************************************************************************
/// For bool types
//***************************************************************************
template <typename T>
typename etl::enable_if<etl::is_same<bool, T>::value, bool>::type
read_unchecked()
typename etl::enable_if<etl::is_same<bool, T>::value, bool>::type read_unchecked()
{
return get_bit();
}
@ -1127,8 +1124,7 @@ namespace etl
/// For bool types
//***************************************************************************
template <typename T>
typename etl::enable_if<etl::is_same<bool, T>::value, etl::optional<bool> >::type
read()
typename etl::enable_if<etl::is_same<bool, T>::value, etl::optional<bool> >::type read()
{
etl::optional<bool> result;
@ -1144,12 +1140,12 @@ namespace etl
/// For integral types
//***************************************************************************
template <typename T>
typename etl::enable_if<etl::is_integral<T>::value && !etl::is_same<bool, T>::value, T>::type
read_unchecked(uint_least8_t nbits = CHAR_BIT * sizeof(T))
typename etl::enable_if< etl::is_integral<T>::value && !etl::is_same<bool, T>::value, T>::type read_unchecked(uint_least8_t nbits = CHAR_BIT
* sizeof(T))
{
typedef typename etl::unsigned_type<T>::type unsigned_t;
T value = read_value<unsigned_t>(nbits, etl::is_signed<T>::value);
T value = static_cast<T>(read_value<unsigned_t>(nbits, etl::is_signed<T>::value));
return static_cast<T>(value);
}
@ -1166,7 +1162,7 @@ namespace etl
// Do we have enough bits?
if (bits_available >= nbits)
{
result = read_unchecked<T>(nbits);
result = read_unchecked<T>(nbits);
}
return result;
@ -1266,8 +1262,8 @@ namespace etl
// Make sure that we are not reading more bits than should be available.
nbits = (nbits > (CHAR_BIT * sizeof(T))) ? (CHAR_BIT * sizeof(T)) : nbits;
T value = 0;
uint_least8_t bits = nbits;
T value = 0;
uint_least8_t bits = nbits;
// Get the bits from the stream.
while (nbits != 0)
@ -1299,7 +1295,7 @@ namespace etl
//***************************************************************************
unsigned char get_chunk(unsigned char nbits)
{
unsigned char value = pdata[char_index];
unsigned char value = static_cast<unsigned char>(pdata[char_index]);
value >>= (bits_available_in_char - nbits);
unsigned char mask;
@ -1310,7 +1306,7 @@ namespace etl
}
else
{
mask = (1U << nbits) - 1;
mask = static_cast<unsigned char>((1U << nbits) - 1);
}
value &= mask;
@ -1325,7 +1321,7 @@ namespace etl
//***************************************************************************
bool get_bit()
{
bool result = (pdata[char_index] & (1U << (bits_available_in_char - 1U))) != 0U;
bool result = (static_cast<unsigned char>(pdata[char_index]) & (1U << (bits_available_in_char - 1U))) != 0U;
step(1U);
@ -1352,9 +1348,11 @@ namespace etl
const char* pdata; ///< The start of the bitstream buffer.
size_t length_chars; ///< The length, in char, of the bitstream buffer.
const etl::endian stream_endianness; ///< The endianness of the stream data.
unsigned char bits_available_in_char; ///< The number of available bits in the current char.
size_t char_index; ///< The index of the char in the bitstream buffer.
size_t bits_available; ///< The number of bits still available in the bitstream buffer.
unsigned char bits_available_in_char; ///< The number of available bits in
///< the current char.
size_t char_index; ///< The index of the char in the bitstream buffer.
size_t bits_available; ///< The number of bits still available in the
///< bitstream buffer.
};
//***************************************************************************
@ -1404,7 +1402,7 @@ namespace etl
{
return stream.read<bool>();
}
}
} // namespace etl
#include "private/minmax_pop.h"

View File

@ -32,12 +32,12 @@ SOFTWARE.
#define ETL_BLOOM_FILTER_INCLUDED
#include "platform.h"
#include "parameter_type.h"
#include "bitset.h"
#include "type_traits.h"
#include "binary.h"
#include "bitset.h"
#include "log.h"
#include "parameter_type.h"
#include "power.h"
#include "type_traits.h"
///\defgroup bloom_filter bloom_filter
/// A Bloom filter
@ -51,34 +51,33 @@ namespace etl
struct null_hash
{
template <typename T>
size_t operator ()(T)
size_t operator()(T)
{
return 0;
}
};
}
} // namespace private_bloom_filter
//***************************************************************************
/// An implementation of a bloom filter.
/// Allows up to three hashes to be defined.
/// Hashes must support the () operator and define 'argument_type'.
///\tparam Desired_Width The desired number of hash results that can be stored. Rounded up to best fit the underlying bitset.
///\tparam THash1 The first hash generator class.
///\tparam THash2 The second hash generator class. If omitted, uses the null hash.
///\tparam THash3 The third hash generator class. If omitted, uses the null hash.
/// The hash classes must define <b>argument_type</b>.
///\tparam Desired_Width The desired number of hash results that can be
/// stored. Rounded up to best fit the underlying
/// bitset. \tparam THash1 The first hash generator class. \tparam
/// THash2 The second hash generator class. If omitted, uses the null
/// hash. \tparam THash3 The third hash generator class. If omitted,
/// uses the null hash. The hash classes must define <b>argument_type</b>.
///\ingroup bloom_filter
//***************************************************************************
template <size_t Desired_Width,
typename THash1,
typename THash2 = private_bloom_filter::null_hash,
template <size_t Desired_Width, typename THash1, typename THash2 = private_bloom_filter::null_hash,
typename THash3 = private_bloom_filter::null_hash>
class bloom_filter
{
private:
typedef typename etl::parameter_type<typename THash1::argument_type>::type parameter_t;
typedef private_bloom_filter::null_hash null_hash;
typedef private_bloom_filter::null_hash null_hash;
public:
@ -90,11 +89,11 @@ namespace etl
//***************************************************************************
/// Clears the bloom filter of all entries.
//***************************************************************************
void clear()
{
flags.reset();
}
//***************************************************************************
void clear()
{
flags.reset();
}
//***************************************************************************
/// Adds a key to the filter.
@ -184,7 +183,6 @@ namespace etl
/// The Bloom filter flags.
etl::bitset<WIDTH> flags;
};
}
} // namespace etl
#endif

View File

@ -91,7 +91,7 @@ namespace etl
//***************************************************
/// Assignment operator
//***************************************************
const_iterator& operator =(const const_iterator& rhs)
const_iterator& operator=(const const_iterator& rhs)
{
p_bresenham_line = rhs.p_bresenham_line;
@ -101,7 +101,7 @@ namespace etl
//***************************************************
/// Pre-increment operator
//***************************************************
const_iterator& operator ++()
const_iterator& operator++()
{
// Has the end of the series has been reached?
if (p_bresenham_line->get_coordinate() == p_bresenham_line->back())
@ -120,7 +120,7 @@ namespace etl
//***************************************************
/// De-reference operator
//***************************************************
value_type operator *() const
value_type operator*() const
{
return p_bresenham_line->get_coordinate();
}
@ -128,7 +128,7 @@ namespace etl
//***************************************************
/// Equality operator
//***************************************************
friend bool operator ==(const const_iterator& lhs, const const_iterator& rhs)
friend bool operator==(const const_iterator& lhs, const const_iterator& rhs)
{
return lhs.p_bresenham_line == rhs.p_bresenham_line;
}
@ -136,7 +136,7 @@ namespace etl
//***************************************************
/// Inequality operator
//***************************************************
friend bool operator !=(const const_iterator& lhs, const const_iterator& rhs)
friend bool operator!=(const const_iterator& lhs, const const_iterator& rhs)
{
return !(lhs == rhs);
}
@ -240,18 +240,18 @@ namespace etl
{
if (y_is_major_axis())
{
return (dy / 2) + 1;
return static_cast<size_t>((dy / 2) + 1);
}
else
{
return (dx / 2) + 1;
return static_cast<size_t>((dx / 2) + 1);
}
}
//***************************************************
/// Equality operator
//***************************************************
friend bool operator ==(const bresenham_line& lhs, const bresenham_line& rhs)
friend bool operator==(const bresenham_line& lhs, const bresenham_line& rhs)
{
return (lhs.front() == rhs.front()) && (lhs.back() == rhs.back());
}
@ -259,7 +259,7 @@ namespace etl
//***************************************************
/// Inequality operator
//***************************************************
friend bool operator !=(const bresenham_line& lhs, const bresenham_line& rhs)
friend bool operator!=(const bresenham_line& lhs, const bresenham_line& rhs)
{
return !(lhs == rhs);
}
@ -272,7 +272,7 @@ namespace etl
void initialise(T first_x, T first_y, T last_x, T last_y)
{
first = value_type(first_x, first_y);
last = value_type(last_x, last_y);
last = value_type(last_x, last_y);
coordinate = first;
x_increment = (last_x < first_x) ? -1 : 1;
y_increment = (last_y < first_y) ? -1 : 1;
@ -355,7 +355,6 @@ namespace etl
work_t balance;
bool do_minor_increment;
};
}
} // namespace etl
#endif

View File

@ -32,12 +32,12 @@ SOFTWARE.
#define ETL_BUFFER_DESCRIPTORS_INCLUDED
#include "platform.h"
#include "array.h"
#include "delegate.h"
#include "type_traits.h"
#include "static_assert.h"
#include "cyclic_value.h"
#include "algorithm.h"
#include "array.h"
#include "cyclic_value.h"
#include "delegate.h"
#include "static_assert.h"
#include "type_traits.h"
#include <cstring>
@ -89,7 +89,7 @@ namespace etl
}
//*********************************
descriptor& operator =(const descriptor& other)
descriptor& operator=(const descriptor& other)
{
pdesc_item = other.pdesc_item;
return *this;
@ -99,12 +99,13 @@ namespace etl
pointer data() const
{
assert(pdesc_item != ETL_NULLPTR);
#include "private/diagnostic_null_dereference_push.h"
return pdesc_item->pbuffer;
#include "private/diagnostic_pop.h"
}
//*********************************
ETL_NODISCARD
ETL_CONSTEXPR size_type max_size() const
ETL_NODISCARD ETL_CONSTEXPR size_type max_size() const
{
return BUFFER_SIZE;
}
@ -147,7 +148,7 @@ namespace etl
//*********************************
void allocate()
{
pdesc_item->in_use = true;;
pdesc_item->in_use = true;
}
/// The pointer to the buffer descriptor.
@ -282,23 +283,26 @@ namespace etl
//*********************************
struct descriptor_item
{
pointer pbuffer;
pointer pbuffer;
volatile flag_type in_use;
};
callback_type callback;
etl::array<descriptor_item, N_BUFFERS> descriptor_items;
callback_type callback;
etl::array<descriptor_item, N_BUFFERS> descriptor_items;
etl::cyclic_value<uint_least8_t, 0U, N_BUFFERS - 1> next;
};
template <typename TBuffer, size_t BUFFER_SIZE_, size_t N_BUFFERS_, typename TFlag>
ETL_CONSTANT typename buffer_descriptors<TBuffer, BUFFER_SIZE_, N_BUFFERS_, TFlag>::size_type buffer_descriptors<TBuffer, BUFFER_SIZE_, N_BUFFERS_, TFlag>::N_BUFFERS;
ETL_CONSTANT typename buffer_descriptors<TBuffer, BUFFER_SIZE_, N_BUFFERS_, TFlag>::size_type
buffer_descriptors<TBuffer, BUFFER_SIZE_, N_BUFFERS_, TFlag>::N_BUFFERS;
template <typename TBuffer, size_t BUFFER_SIZE_, size_t N_BUFFERS_, typename TFlag>
ETL_CONSTANT typename buffer_descriptors<TBuffer, BUFFER_SIZE_, N_BUFFERS_, TFlag>::size_type buffer_descriptors<TBuffer, BUFFER_SIZE_, N_BUFFERS_, TFlag>::BUFFER_SIZE;
ETL_CONSTANT typename buffer_descriptors<TBuffer, BUFFER_SIZE_, N_BUFFERS_, TFlag>::size_type
buffer_descriptors<TBuffer, BUFFER_SIZE_, N_BUFFERS_, TFlag>::BUFFER_SIZE;
template <typename TBuffer, size_t BUFFER_SIZE_, size_t N_BUFFERS_, typename TFlag>
ETL_CONSTANT typename buffer_descriptors<TBuffer, BUFFER_SIZE_, N_BUFFERS_, TFlag>::size_type buffer_descriptors<TBuffer, BUFFER_SIZE_, N_BUFFERS_, TFlag>::descriptor::MAX_SIZE;
}
ETL_CONSTANT typename buffer_descriptors<TBuffer, BUFFER_SIZE_, N_BUFFERS_, TFlag>::size_type
buffer_descriptors<TBuffer, BUFFER_SIZE_, N_BUFFERS_, TFlag>::descriptor::MAX_SIZE;
} // namespace etl
#endif
#endif

Some files were not shown because too many files have changed in this diff Show More