| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
Signed-off-by: Sven Göthel <[email protected]>
|
|
|
|
| |
Signed-off-by: Sven Göthel <[email protected]>
|
|
|
|
|
|
| |
mul_overflow}() constexpr,
Signed-off-by: Sven Göthel <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Refines initial enum-class commit f5e9cd9dbaa7f33e4c43ce966f6ebe4f9cb9f99e
- JAU_MAKE_ENUM_IMPL -> JAU_MAKE_ENUM_STRING
- JAU_MAKE_BITFIELD_ENUM_IMPL -> JAU_MAKE_BITFIELD_ENUM_STRING
- Added JAU_MAKE_ENUM_INFO which adds `jau::enum_info<>`
with its iterator and info methods
Methods
- add: long_name()
- change: enum_name() -> name() for `const char*`
- same: to_string() for `std::string`
- add: `*` operator returning the underlying value (like `number`)
Signed-off-by: Sven Göthel <[email protected]>
|
|
|
|
| |
Signed-off-by: Sven Göthel <[email protected]>
|
|
|
|
|
|
| |
use simple `Bool(underling)` expression instead of static_cast<Bool>
Signed-off-by: Sven Göthel <[email protected]>
|
|
|
|
| |
Signed-off-by: Sven Göthel <[email protected]>
|
|
|
|
| |
Signed-off-by: Sven Göthel <[email protected]>
|
| |
|
|
|
|
|
|
|
|
|
| |
JAU_MAKE_BITFIELD_ENUM_IMPL macros
Tested in test_enumutil.cpp as well as by applying in
- jau::fs
- jau::os
- jau::cpu
|
|
|
|
| |
ISO 8601 date string
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
from jau/string_util.hpp
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
perf tests
Due to 'Security Interpretation' implications, see below,
the `snprintf` argument type checker `jau::cfmt` has been added
and utilized in `template <typename... Args> format_string_v(...)`.
jau::cfmt::check() provides strict type matching of arguments against the format string.
Have jau::cfmt::check() to be passed _before_ using std::snprintf(),
removing safety concerns of the latter and benefit from its formatting and performance.
Validates arguments against format string at compile time or runtime,
depending whether passed arguments are of constexpr nature (compile time).
+++
Benchmark
=========
gcc-12
benchmark name samples iterations mean
-------------------------------------------------------------------------------
fmt__check bench 1 1 42.292 us
fmt__check cnstexpr bench 1 2 9.9015 us
format_000a_vsnprintf bench 1 1 214.458 us
format_010a_vsnprintf bench 1 1 215.109 us
fmt__020a macro bench 1 1 193.859 us
fmt__020a cnstexpr-in bench 1 1 191.299 us
fmt__020a_tsnprintf bench 1 1 264.927 us
format_030a_strstream bench 1 1 490.923 us
format_000b_vsnprintf bench 1 1 205.839 us
format_010b_vsnprintf bench 1 1 204.899 us
format_020b__snprintf bench 1 1 254.758 us
format_030b_strstream bench 1 1 476.994 us
+++
clang-18
benchmark name samples iterations mean
-------------------------------------------------------------------------------
fmt__check bench 1 1 47.373 us
fmt__check cnstexpr bench 1 2 9.477 us
format_000a_vsnprintf bench 1 1 190.99 us
format_010a_vsnprintf bench 1 1 200.4 us
fmt__020a macro bench 1 1 181.141 us
fmt__020a cnstexpr-in bench 1 1 178.34 us
fmt__020a_tsnprintf bench 1 1 243.909 us
format_030a_strstream bench 1 1 435.835 us
format_000b_vsnprintf bench 1 1 184.91 us
format_010b_vsnprintf bench 1 1 187.01 us
format_020b__snprintf bench 1 1 234.629 us
format_030b_strstream bench 1 1 415.386 us
+++
Pass `--perf_analysis` for enhanced Catch2 benchmarking w/ 100 samples,
e.g. `test_stringfmt --perf_analysis`
Note: C++20 std::format wasn't available on either compiler toolchain.
Note: Used formatting with C++ stringstream is limited
and I haven't tried hard enought to properly reproduce
the `printf` formatting goal.
Intention of this test is for performance only.
+++
C++ stringstream uses roughly 2.3 (or 5/2 max) of the time as c-lib's `snprintf`.
Test utilizes non-const non-constexpr mutable values
to be formatted at runtime - as well as compile time scenarious.
Therefore stringstream is not able to format at compile time
either, especially when evaluating values with formatting options.
Hence only the va_args reinterpretation of stack data
according to the format string conversion is added in `snprintf`.
As visible - this extra work does not impact performance.
Security Interpretation
=======================
<https://en.cppreference.com/w/cpp/io/c/fprintf>
"If any argument after default conversions is not the type expected
by the corresponding conversion specifier,
or if there are fewer arguments than required by format, the behavior is undefined."
https://en.cppreference.com/w/cpp/language/variadic_arguments#Default_conversions
https://en.cppreference.com/w/cpp/utility/variadic/va_arg
"If the type of the next argument in ap (after promotions) is not compatible with T, the behavior is undefined, unless:
... type promotion details .."
"If va_arg is called when there are no more arguments in ap, the behavior is undefined."
|
| |
|
| |
|
| |
|
|
|
|
| |
cmake: Restructure to project/target settings (from global)
|
| |
|
|
|
|
| |
deduce uint16_t, uint32_t or uint64_t override of cpu_to_le() or bswap() (FIXME)
|
| |
|
|
|
|
| |
pedantic etc; Adding PRAGMA to 'pause' pedantic and zero-length-array
|
| |
|
| |
|
| |
|
|
|
|
| |
jau/version.hpp: Use VersionNumber for jau::VERSION
|
|
|
|
|
|
|
|
|
|
|
|
| |
from_hexstring().
In case hexstr contains an odd number of hex-nibbles, it will be interpreted as follows
- 0xf12 = 0x0f12 = { 0x12, 0x0f } - msb, 1st single low-nibble is most significant
- 12f = 0xf012 = { 0x12, 0xf0 } - lsb, last single high-nibble is most significant
hexStringBytes()'s odd hex-nibble string handling was wrong
- MSB need to append the 1st nibble as highest significant byte
- LSB need to append the last single high-nibble as highest significant byte
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(API!); Fix to_hexstring() making it big-endian save; MSB string: Drop leading zeros
Drop 'offset' argument (API!)
- Redundant from Java API, we shall just pass the (adjusted) pointer
Add `skipLeading0x` arg (API!)
- Some use cases may not want to show the leading MSB `0x`
Fix to_hexstring() making it big-endian save
- byte array expected in LSB, hence bswap is required on MSB
MSB string: Drop leading zeros
- Its annoying to see many leading zeros for e.g. uint64_t, drop them
- TODO: Drop the tail all-zeros for LSB presentation as well ?
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
C++ standard (clangd)
Use all includes (tidy)
- Move catch2 test includes out of include/jau -> include/catch2_jau/jau
allowing simplified tidy HeaderFilterRegex expression
Enforce chosen C++ standard (clangd)
- '-std=c++20' (or matching) is added to .clangd, otherwise C++17 is being used
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
std::vector ...
|
|
|
|
| |
type-traits _v and _t; Use std::string::starts_with(); Use std::numbers::pi_v
|
|
|
|
|
|
|
|
|
| |
allocStore()==0 only failure if size > 0 as a zero size (null memory) shrink_to_fit() is legal; Fix erase() arg types
Cleanup C++20
- Add constexpr..
- Use std::numbers::phi_v<float> for golden ratio
- Use _v and _t type trait macros
|
|
|
|
| |
constexpr_atomic (C++23)
|
|
|
|
| |
std::exception OO tree instance is included (as they are not using virtual base classes)
|
|
|
|
| |
type size)
|
|
|
|
| |
which is still the default impl.
|
|
|
|
| |
no use of builtins
|
|
|
|
| |
sizeof(value_type)
|
| |
|