aboutsummaryrefslogtreecommitdiffstats
path: root/include/jau
Commit message (Collapse)AuthorAgeFilesLines
* aabbox[23]f::intersects: Use possible branchless min/max approach, add perf-testHEADmasterSven Göthel2024-10-092-51/+48
| | | | Signed-off-by: Sven Göthel <[email protected]>
* jau::math::vec*: Add min/max methodSven Göthel2024-10-094-3/+67
| | | | Signed-off-by: Sven Göthel <[email protected]>
* int_math: Use proper has_builtin_{add_overflow, sub_overflow, ↵Sven Göthel2024-10-091-37/+69
| | | | | | mul_overflow}() constexpr, Signed-off-by: Sven Göthel <[email protected]>
* Enhance `enum class` support via jau::enumsSven Göthel2024-10-093-71/+382
| | | | | | | | | | | | | | | | | 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]>
* Remove trailing whitespaceSven Göthel2024-10-099-41/+41
| | | | Signed-off-by: Sven Göthel <[email protected]>
* jau::Bool: Add `*` operator returning the underlying value (like `value`), ↵Sven Göthel2024-10-091-12/+14
| | | | | | use simple `Bool(underling)` expression instead of static_cast<Bool> Signed-off-by: Sven Göthel <[email protected]>
* cow_iterator: Use equality and C++20 spaceship comparison ops onlySven Göthel2024-10-091-36/+14
| | | | Signed-off-by: Sven Göthel <[email protected]>
* Simplified jau::{is->has}_builtin_bit_cast{_available->}()Sven Göthel2024-10-092-43/+16
| | | | Signed-off-by: Sven Göthel <[email protected]>
* jau::mp::ops: Use static_assert where applicableSven Göthel2024-09-281-2/+2
|
* Introduce `enum class` support via jau::enums and JAU_MAKE_ENUM_IMPL + ↵Sven Göthel2024-09-285-485/+396
| | | | | | | | | JAU_MAKE_BITFIELD_ENUM_IMPL macros Tested in test_enumutil.cpp as well as by applying in - jau::fs - jau::os - jau::cpu
* Add fraction_timespec::from(std::string_view, ...) for tolerant parsing of ↵Sven Göthel2024-09-141-20/+71
| | | | ISO 8601 date string
* jau::cfmt: cleanup and add robusteness, adding alternative recursive versionSven Göthel2024-09-142-29/+31
|
* Add scoped enum Bool as a bool alternative w/o dangerous implicit conversionSven Göthel2024-09-141-0/+59
|
* cleanup: includes, space, missing inline (ODR), drop cast, drop return statementSven Göthel2024-09-143-14/+12
|
* cleanup spaceSven Göthel2024-09-145-26/+26
|
* file_util: simplify scoped enum operatorSven Göthel2024-09-141-21/+21
|
* type_cue: Add to_string() and fprint(FILE *, ..) - decouple compilation unit ↵Sven Göthel2024-09-022-58/+79
| | | | from jau/string_util.hpp
* `snprintf` argument type checker `jau::cfmt` and simple string formatting ↵Sven Göthel2024-09-022-0/+870
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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."
* [v]format_string(): Drop noexcept due to vector usage, e.g. v.resize() may throwSven Göthel2024-08-291-2/+2
|
* float_types.hpp: Fix static_assertion and float_literalsSven Göthel2024-08-081-4/+4
|
* C++: Fix includesSven Göthel2024-08-083-5/+1
|
* Wasm: Add prelim support unit tests with STANDALONE_WASM (emscripten); ↵Sven Göthel2024-07-171-0/+21
| | | | cmake: Restructure to project/target settings (from global)
* [cow_]darray: Include <numbers> for phi (emscripten caught)Sven Göthel2024-05-262-7/+8
|
* emscripten fix: to_hexstring(aptr): Hardcode as emscripten is unable to ↵Sven Göthel2024-05-261-4/+11
| | | | deduce uint16_t, uint32_t or uint64_t override of cpu_to_le() or bswap() (FIXME)
* emscripten fix: include/jau/basic_types.hpp: include <thread>Sven Göthel2024-05-261-0/+1
|
* make: Ensure CC_FLAGS_WARNING is used for all (adding GCC), i.e. using ↵Sven Göthel2024-05-262-0/+14
| | | | pedantic etc; Adding PRAGMA to 'pause' pedantic and zero-length-array
* basic_types: Make all Exception* default ctor and assignments noexceptSven Göthel2024-05-261-28/+28
|
* Fix or silent misc clang-tidy warningsSven Göthel2024-05-253-13/+11
|
* fraction/fraction_timespec: Use correct jau::sign()Sven Göthel2024-05-251-3/+3
|
* VersionNumber: Add parsing git description to regexp and maintain it; ↵Sven Göthel2024-05-252-23/+120
| | | | jau/version.hpp: Use VersionNumber for jau::VERSION
* Fix hexStringBytes() odd hex-nibble string; Add convenient uint64_t ↵Sven Göthel2024-05-251-0/+22
| | | | | | | | | | | | 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
* jau::bytesHexString: Drop 'offset' argument (API!); Add `skipLeading0x` arg ↵Sven Göthel2024-05-252-18/+31
| | | | | | | | | | | | | | | | | (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 ?
* Add jau::util::VersionNumberSven Göthel2024-05-241-0/+257
|
* Add std::string threadName(const std::thread::id) using its hashcodeSven Göthel2024-05-241-0/+2
|
* C++20 clang-tidy fixesSven Göthel2024-05-2419-200/+204
|
* Fix clangd/cland-tidy integration: Use all includes (tidy), enforce chosen ↵Sven Göthel2024-05-242-246/+0
| | | | | | | | | | | 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
* octets: Fix Exception* Type Names; Fix put_octets (drop noexcept)Sven Göthel2024-05-201-12/+148
|
* Make cow_darray::equal_comparator noexceptSven Göthel2024-05-201-2/+2
|
* darray: Add [[nodiscard]] for *alloc* opsSven Göthel2024-05-201-3/+3
|
* Exception*: Pass type as {pr, x}value for move-opSven Göthel2024-05-202-27/+25
|
* Replace static arrays using non-standard (illegal) dynamic size with ↵Sven Göthel2024-05-192-15/+16
| | | | std::vector ...
* cleanup C++20: Review bugprone-casting-through-void; Fix includes; Use ↵Sven Göthel2024-05-196-31/+35
| | | | type-traits _v and _t; Use std::string::starts_with(); Use std::numbers::pi_v
* darray: C++20 cleanup; Add resize(); Fix reallocStore()==0 and ↵Sven Göthel2024-05-192-36/+67
| | | | | | | | | 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
* cleanup C++20: cpp_lang_util: Fix constexpr_non_literal_var (C++23), ↵Sven Göthel2024-05-191-8/+8
| | | | constexpr_atomic (C++23)
* cleanup C++20: Cleanup and test Exception* OO tree, ensure only one ↵Sven Göthel2024-05-199-117/+280
| | | | std::exception OO tree instance is included (as they are not using virtual base classes)
* cleanup C++20: Adjust enum values (Use 1U << x for unsigned values; reduce ↵Sven Göthel2024-05-193-13/+13
| | | | type size)
* cleanup C++20: Use non-optimized new zero_bytes_sec() instead of ::bzero(), ↵Sven Göthel2024-05-199-73/+136
| | | | which is still the default impl.
* ordered_atomic: Allow prefix ++ and -- via fetch_{add,sub}() {+,-} 1, still ↵Sven Göthel2024-05-131-3/+23
| | | | no use of builtins
* math vec*/rect* alignment: Use (and validate) natural alignment to ↵Sven Göthel2024-05-135-123/+227
| | | | sizeof(value_type)
* cpuid: Add page_size for Windows, use zero for undefined (not 1)Sven Göthel2024-05-121-1/+1
|