etl/docs/types/unaligned-type.md
John Wellbelove 4a88884b39
Issue/add hugo support for documentation (#1449)
* Add ranges

* Initial Hugo setup

* Work in progress

* Added selection for local or remote site

* Updated to 'light' theme

* Changed to using Hextra Hugo theme

* Changed to using Hextra Hugo theme

* Changed to Hextra Hugo theme

* Change to Hextra Hugo theme

* Updated Hugo setup.

* Updated Hugo setup.

# Conflicts:
#	docs/releases/_index.md

* Work in progress

* Added new fonts

Added new documentation

* Latest documentation updates

* Latest documentation updates

# Conflicts:
#	docs/containers/array.md
#	docs/containers/array_view.md
#	docs/containers/array_wrapper.md
#	docs/containers/bip_buffer_spsc_atomic.md
#	docs/containers/bitset.md
#	docs/containers/indirect_vector.md
#	docs/containers/vector.md
#	docs/getting-started/compilers.md

* Added bloom_filter markdown doc

* Added more documentation

Updated CSS for light and dark modes

* Fixed some menus

Added mode documentation files

* Updated CSS rules

Added badges to home page
Added uniqur_ptr + pool tutorial

* Fixed formatting on the home page markdown

Modified light amd dark code formatting

* Updated unique_ptr-with-pool

* Added container and shared message tutorials

* Updates to documentation

* Added const_multimap

* Updated source-formatting.md

* Added initial raw text files form Web site editor

* Innore coverage build directory

* Exported raw text documentation files from the web site editor

* Hugo updates

* Added Hugo intalation and markdown descriptions

* More addition to the documentation

* Added closure.md and updates to delegate.md

* Added format.md

* Added documentation for etl::delegate_observable, etl::function, Base64 codec

* Added io_port documentation

* Added basic_format_spec

* Added documentation for string_stream and string utilities.

* Added more documentation

Updated the documentation CSS

* Added documentation for clocks, day, duration

* Added more documentation for chrono classes

Updated callouts

* More chrono documentation

* Completed chrono documentation

* Maths functions documentation

* Completed maths documentation

* Completed maths documentation

* Completed maths documentation

* Completed maths documentation

* Added multiple documentation files

* Added iterator.md

* Added debug_count.md and versions.md

* Added debug_count.md and versions.md

* Added more documentation

* More documentation

* Added some design pattern documentation

Modified some of the layout files
Modified the About documentation

* Converted more documentation pages

Modified the site CSS

* Added more documentation

Moced some documentation files to new directories

* Added more documentation

Tweaks to CSS

* Added callback_timer_deferred_locked documentation

* Added callback_timer_locked documentation

* More documentation updates

* More documentation updates

* More documentation updates

* New documentation files.

Harmonised file name format

* New documentation files.

* Multiple document updates

* Multiple document updates

* Final conversion of web pages

* Updates before PR

* Updates before PR

* Updates before PR

# Conflicts:
#	docs/blog/_index.md

* Final pre PR updates

* Updates to message framework documentation

* Renamed directory

* Fix spelling

* Added author and date to blog files

Moved documentation files merged from development

* Fixed 'Description' typo

* Fix typos

# Conflicts:
#	docs/IO/io_port.md
#	docs/containers/sets/const-multiset.md
#	docs/containers/sets/const-set.md
#	docs/maths/correlation.md
#	docs/maths/gamma.md

* Renamed two files to lower case

* Minor renaming

* Added author and date

* Updated callout on bresenham_line.md

Added support for showing the ETL version on the documentation first page, by copying the version.txt file as a hugo asset.
Updated the Python 'update_release.py' to copy 'version.txt'

* Replace space in filename with hyphen.

Added more information to hugo-commands.md

* Replace space in filename with hyphen.

Added more information to hugo-commands.md

# Conflicts:
#	docs/getting-started/view-the-docs-locally/hugo-commands.md

* Added a link to pseudo_moving_average.md

* Updated title pages for groups

* Fixed missing 404 for non-existent pages

* Fixed coordinate variable names in the 'Calculating the intersection' example

---------

Co-authored-by: Roland Reichwein <Roland.Reichwein@bmw.de>
Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.com>
Co-authored-by: John Wellbelove <john.wellbelove@etlcpp.co.uk>
2026-06-06 13:12:44 +01:00

7.1 KiB
Raw Blame History

title
unaligned_type

{{< callout type="info">}} Header: unaligned_type.h
From: 20.23.0
{{< /callout >}}

A wrapper for fundamental types around unaligned internal storage.
Allows big and little endian storage.

Marked as packed for MSVC, GCC amd Clang.

template <typename T, int Endian>
class unaligned_type

Where Endian is etl::endian::big or etl::endian::little.


For C++11 or above

template <typename T, int Endian>
using unaligned_type_t = typename etl::unaligned_type<T, Endian>::type;

For C++17 or above

template <typename T, int Endian>
constexpr size_t unaligned_type_v = etl::unaligned_type<T, Endian>::Size;

The following types are predefined.

Host order

Only defined if ETL_ENDIANNESS_IS_CONSTEXPR.

host_char_t
host_schar_t
host_uchar_t
host_short_t
host_ushort_t
host_int_t
host_uint_t
host_long_t
host_ulong_t
host_long_long_t
host_ulong_long_t
host_int8_t       ETL_USING_8BIT_TYPES
host_uint8_t      ETL_USING_8BIT_TYPES
host_int16_t
host_uint16_t
host_int32_t
host_uint32_t
host_int64_t      ETL_USING_64BIT_TYPES
host_uint64_t     ETL_USING_64BIT_TYPES
host_float_t
host_double_t
host_long_double_t

Little Endian

le_char_t
le_schar_t
le_uchar_t
le_short_t
le_ushort_t
le_int_t
le_uint_t
le_long_t
le_ulong_t
le_long_long_t
le_ulong_long_t
le_int8_t       ETL_USING_8BIT_TYPES
le_uint8_t      ETL_USING_8BIT_TYPES
le_int16_t
le_uint16_t
le_int32_t
le_uint32_t
le_int64_t      ETL_USING_64BIT_TYPES
le_uint64_t     ETL_USING_64BIT_TYPES
le_float_t
le_double_t
le_long_double_t

Big Endian

be_char_t
be_schar_t
be_uchar_t
be_short_t
be_ushort_t
be_int_t
be_uint_t
be_long_t
be_ulong_t
be_long_long_t
be_ulong_long_t
be_int8_t       ETL_USING_8BIT_TYPES
be_uint8_t      ETL_USING_8BIT_TYPES
be_int16_t
be_uint16_t
be_int32_t
be_uint32_t
be_int64_t      ETL_USING_64BIT_TYPES
be_uint64_t     ETL_USING_64BIT_TYPES
be_float_t
be_double_t
be_long_double_t

Network Order

Synonym for Big Endian

using net_char_t        = be_char_t
using net_schar_t       = be_schar_t
using net_uchar_t       = be_uchar_t
using net_short_t       = be_short_t
using net_ushort_t      = be_ushort_t
using net_int_t         = be_int_t
using be_uint_t         = net_uint_t
using net_long_t        = be_long_t       
using net_ulong_t       = be_ulong_t
using net_long_long_t   = be_long_long_t  
using net_ulong_long_t  = be_ulong_long_t
using net_int8_t        = be_int8_t       ETL_USING_8BIT_TYPES
using net_uint8_t       = be_uint8_t      ETL_USING_8BIT_TYPES
using net_int16_t       = be_int16_t
using net_uint16_t      = be_uint16_t
using net_int32_t       = be_int32_t       
using net_uint32_t      = be_uint32_t
using net_int64_t       = be_int64_t      ETL_USING_64BIT_TYPES
using net_uint64_t      = be_uint64_t     ETL_USING_64BIT_TYPES
using net_float_t       = be_float_t
using net_double_t      = be_double_t
using net_long_double_t = be_long_double_t

Constants

int Endian
The endianness of the type.
size_t Size
The size, in char, of the type.

Constructors

ETL_CONSTEXPR unaligned_type()

Description
Constructs an uninitialised unaligned_type.


unaligned_type(T value)

Description
Constructs with the supplied value.


template <int Endian_Other>
unaligned_type(const unaligned_type<T, Endian_Other>& other)

Description
Constructs from another unaligned_type. The endianness is converted, if necessary.

Member types

using pointer                = char*;
using const_pointer          = const char*;
using iterator               = char*;
using const_iterator         = const char*;
using reverse_iterator       = etl::reverse_iterator<iterator>;
using const_reverse_iterator = etl::reverse_iterator<const_iterator>;

Member functions

pointer data()

Description
Pointer to the beginning of the storage.


ETL_CONSTEXPR14 const_pointer data() const

Description
Const pointer to the beginning of the storage.


ETL_CONSTEXPR14 size_t size() const

Description
Size of the storage.


iterator begin()

Description
Iterator to the beginning of the storage.


ETL_CONSTEXPR14 const_iterator begin() const

Description
Const iterator to the beginning of the storage.


ETL_CONSTEXPR14 const_iterator cbegin() const

Description
Const iterator to the beginning of the storage.


reverse_iterator rbegin()

Description
Reverse iterator to the beginning of the storage.


ETL_CONSTEXPR14 const_reverse_iterator rbegin() const

Description
Const reverse iterator to the beginning of the storage.


ETL_CONSTEXPR14 const_reverse_iterator crbegin() const

Description
Const reverse iterator to the beginning of the storage.


iterator end()

Description
Iterator to the end of the storage.


ETL_CONSTEXPR14 const_iterator end() const

Description
Const iterator to the end of the storage.


ETL_CONSTEXPR14 const_iterator cend() const

Description
Const iterator to the end of the storage.


reverse_iterator rend()

Description
Reverse iterator to the end of the storage.


ETL_CONSTEXPR14 const_reverse_iterator rend() const

Description
Const reverse iterator to the end of the storage.


ETL_CONSTEXPR14 const_reverse_iterator crend() const

Description
Const reverse iterator to the end of the storage.


char& operator[](int i)

Description
Index operator.


ETL_CONSTEXPR14 const char& operator[](int i) const

Description
Const index operator.


ETL_CONSTEXPR14 unaligned_type& operator =(T value)

Description
Assignment operator.


ETL_CONSTEXPR14 operator T() const

Description
Conversion operator.


ETL_CONSTEXPR14 T value() const

Description
Gets the value.


template <int Endian_Other>
ETL_CONSTEXPR14 unaligned_type& operator =(const unaligned_type<T, Endian_Other>& other)

Description
Assignment operator from other endianness.


ETL_CONSTEXPR14 bool operator ==(const unaligned_type& lhs, const unaligned_type& rhs)

Description
Equality operator.
Removed: 20.39.3


ETL_CONSTEXPR14 bool operator ==(const unaligned_type& lhs, T rhs)

Description
Equality operator.
Removed: 20.39.3


ETL_CONSTEXPR14 bool operator ==(T lhs, const unaligned_type& rhs)

Description
Equality operator.
Removed: 20.39.3


ETL_CONSTEXPR14 bool operator !=(const unaligned_type& lhs, T rhs)

Description
Inequality operator.
Removed: 20.39.3


ETL_CONSTEXPR14 bool operator !=(const unaligned_type& lhs, const unaligned_type& rhs)

Description
Inequality operator.
Removed: 20.39.3


ETL_CONSTEXPR14 bool operator !=(T lhs, const unaligned_type& rhs)

Description
Inequality operator.
Removed: 20.39.3