Marco Nilsson eb793d2b82
Help the compiler optimize unaligned_type. (#1598)
* Help the compiler optimize unaligned_type.

This fixes a regression in 266b0f99 when the type was made constexpr. When
switching to a loop to construct the value the compiler was unable to detect
what was going on. We now unroll the loop at compile time into what's
essentially a hand rolled shift and OR operation which the compiler detects
and replaces with a byte swap. Tested on gcc (x86+arm) and clang (x86).

Introduce a static value_from which can be used to convert a value from an
existing buffer. There were previously three options for this, all bad or
awkward in different ways:

- val = etl::be_uint32_t(address)
Copies to temporary storage.

- val = *reinterpret_cast<const etl::be_uint32_t*>(address);
Unreadable.

- etl::be_uint32_t::copy_store_to_value(address, output);
Requires an output parameter.

The new addition is:
- val = etl::be_uint32_t::value_from(address);

Additionally, update the documentation with value_from and the missing,
existing constructors.

* Please clang-format.

---------

Co-authored-by: John Wellbelove <jwellbelove@users.noreply.github.com>
2026-09-13 10:33:42 +01:00
..
binary Issue/add hugo support for documentation (#1449) 2026-06-06 13:12:44 +01:00
blog Various fixes and cleanup (#1507) 2026-07-20 11:19:41 +02:00
callbacks Various fixes and cleanup (#1507) 2026-07-20 11:19:41 +02:00
chrono Various fixes and cleanup (#1507) 2026-07-20 11:19:41 +02:00
codecs Fix code examples in documentation (#1471) 2026-06-23 18:11:17 +01:00
containers Remove spurious link in documentation (#1576) 2026-08-28 09:41:00 +01:00
getting-started Various fixes and cleanup (#1507) 2026-07-20 11:19:41 +02:00
IO Various fixes and cleanup (#1507) 2026-07-20 11:19:41 +02:00
iterators Add missing etl::ranges::distance overload (#1569) 2026-08-26 20:16:54 +01:00
maths Fix code examples in documentation (#1471) 2026-06-23 18:11:17 +01:00
messaging Various fixes and cleanup (#1507) 2026-07-20 11:19:41 +02:00
multi-tasking Documentation updates (#1469) 2026-06-23 18:12:58 +01:00
patterns Fix code examples in documentation (#1471) 2026-06-23 18:11:17 +01:00
pseudo-containers Issue/add hugo support for documentation (#1449) 2026-06-06 13:12:44 +01:00
ranges Add missing etl::ranges::distance overload (#1569) 2026-08-26 20:16:54 +01:00
releases Updated release notes 2026-09-08 20:14:24 +01:00
resourses Issue/add hugo support for documentation (#1449) 2026-06-06 13:12:44 +01:00
source Squashed commit of the following: 2026-07-11 13:02:42 +01:00
state machines Hotfix/documentation updates (#1456) 2026-06-08 08:58:47 +01:00
strings Various cleanup (#1562) 2026-08-22 17:47:16 +02:00
timers Various fixes and cleanup (#1507) 2026-07-20 11:19:41 +02:00
tutorials Various fixes and cleanup (#1507) 2026-07-20 11:19:41 +02:00
types Help the compiler optimize unaligned_type. (#1598) 2026-09-13 10:33:42 +01:00
utilities Support runtime floating-point clamped_value before C++20 (#1595) 2026-09-08 19:45:31 +01:00
_index.md Updated menus for Home page for documentation 2026-09-06 20:36:35 +01:00
about.md Added sponsors page to documentation 2026-09-06 20:36:45 +01:00
Is the ETL free.md Issue/add hugo support for documentation (#1449) 2026-06-06 13:12:44 +01:00
sponsors.md Added sponsors page to documentation 2026-09-07 15:39:46 +01:00