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
..
_index.md Issue/add hugo support for documentation (#1449) 2026-06-06 13:12:44 +01:00
largest.md Issue/add hugo support for documentation (#1449) 2026-06-06 13:12:44 +01:00
smallest.md Fix code examples in documentation (#1471) 2026-06-23 18:11:17 +01:00
tuple.md Add etl::apply (#1509) 2026-07-16 09:15:24 +01:00
type_def.md Issue/add hugo support for documentation (#1449) 2026-06-06 13:12:44 +01:00
type-list.md Fixes and additional metafunctions for etl::type_list (#1460) 2026-06-18 10:35:20 +01:00
type-lookup.md Issue/add hugo support for documentation (#1449) 2026-06-06 13:12:44 +01:00
type-select.md Issue/add hugo support for documentation (#1449) 2026-06-06 13:12:44 +01:00
type-traits.md Changed version from 20.50.0 to 20.49.0 2026-09-05 16:15:26 +01:00
unaligned-type.md Help the compiler optimize unaligned_type. (#1598) 2026-09-13 10:33:42 +01:00
user_type.md Issue/add hugo support for documentation (#1449) 2026-06-06 13:12:44 +01:00