ETLCPP / etl

Embedded Template Library
https://www.etlcpp.com
MIT License
2.04k stars 371 forks source link

Constexpr CRC for C++23 #907

Open jaskij opened 5 days ago

jaskij commented 5 days ago

This ended up a bit bigger than I originally intended, but all the tests pass.

What's added:

C++23

Since my feature requires C++23, I added basic support for it, including:

Constexpr CRC

I wanted to created some binary headers for use with a bootloader, and for those headers to be guarded with CRC. Since I'm using ETL's implementation, I updated the library to actually allow using CRCs in a constant evaluated context.

The requirement for C++23 comes from P2647R1, which permits putting constexpr on etl::crc_table::add(). The limitation being the static part of the actual table. This could probably be relaxed, but I don't exactly see how at the moment, not with support for C++98 or C++03.

semanticdiff-com[bot] commented 5 days ago

Review changes with SemanticDiff.

jaskij commented 5 days ago

Sorry for bundling it like this, the PR was written in several hours of sleep-deprivation-fueled-mania. I can split the C++23 support later on.

I can also tell already that the check for C++23 will probably need to be refined in the future.

jaskij commented 3 days ago

That last push should fix the C++11 builds (my fault for using ETL_CONSTEXPR instead of ETL_CONSTEXPR14).

Right now I have absolutely no clue though what's going on in those C++23 test on clang. The include stack would point to something in UnitTest++?

[  8%] Building CXX object test/CMakeFiles/etl_tests.dir/test_algorithm.cpp.o
In file included from /home/runner/work/etl/etl/test/test_algorithm.cpp:29:
In file included from /home/runner/work/etl/etl/test/unit_test_framework.h:32:
In file included from /home/runner/work/etl/etl/test/UnitTest++/UnitTest++.h:1:
In file included from /home/runner/work/etl/etl/test/UnitTest++/UnitTestPP.h:5:
In file included from /home/runner/work/etl/etl/test/UnitTest++/TestMacros.h:7:
In file included from /home/runner/work/etl/etl/test/UnitTest++/ExecuteTest.h:8:
In file included from /home/runner/work/etl/etl/test/UnitTest++/MemoryOutStream.h:9:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/sstream:40:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/istream:40:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/ios:44:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/ios_base.h:41:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/locale_classes.h:40:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/string:67:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/memory_resource.h:41:
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/bits/uses_allocator_args.h:39: