Fix endian swapping classes reading volatile values twice.

This commit is contained in:
Jonas 'Sortie' Termansen 2023-01-03 23:47:14 +01:00
parent 3997116656
commit cbf0c1dc97
1 changed files with 6 additions and 1 deletions

View File

@ -128,7 +128,12 @@ public:
__endian_base() { }
__endian_base(const T& t) : representation(swap(t)) { }
operator T() const { return swap(representation); }
operator T() const volatile { return swap((const T) representation); }
operator T() const volatile
{
T value = representation;
__endian_base<T, endianness> wrapper(value);
return wrapper.representation;
}
__endian_base& operator=(const T& rhs)
{