summaryrefslogtreecommitdiffstats
path: root/include/jau/packed_attribute.hpp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2022-04-19 08:47:15 +0200
committerSven Gothel <[email protected]>2022-04-19 08:47:15 +0200
commit5e0efff48aed2044388151637d0969daf6aabd4d (patch)
treee20cfd99fbee06a352e0e90fc967a3cc02af8d22 /include/jau/packed_attribute.hpp
parent6bc535742a897aa253a47638aad30d4869563e27 (diff)
Fix clang 11.0.1 C++17 and prepare C++20 (WIP)v0.8.1
- Make 'to_string(const endian& v)' external, remove constexpr - Move packed_t from byte_util.hpp -> packed_attribute.hpp w/o endian conversion - Note: Using pointer_cast and packed_t actually implements constexpr bit_cast - Add 'get_value(const packed_t<T>* source, const bool littleEndian) noexcept' to byte_util.hpp - pointer_cast<> needs to have const removed from underlying pointer type - uint[128,192,256]_t(const uint8_t v[]): Use '*this = pointer_cast<packed_t<uint128_t>*>( v )->store' as constexpr solution. - WIP: Consider making it bitcast! - ordered_atomic.hpp: Use C++17 aliased enum or C++20 inlince constexpr aliases std::memory_order types - type_traits_queries.hpp: is_scoped_enum<> is C++23
Diffstat (limited to 'include/jau/packed_attribute.hpp')
-rw-r--r--include/jau/packed_attribute.hpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/jau/packed_attribute.hpp b/include/jau/packed_attribute.hpp
index 54e264c..bd9136d 100644
--- a/include/jau/packed_attribute.hpp
+++ b/include/jau/packed_attribute.hpp
@@ -53,4 +53,16 @@
#endif
#endif
+ /**
+ * Safe access to a pointer cast from unaligned memory via __packed__ attribute,
+ * i.e. utilizing compiler generated safe load and store operations.
+ * <p>
+ * This template shall cause no costs, the cast data pointer is identical to 'T & p = &store'.
+ * </p>
+ */
+ template<typename T> __pack ( struct packed_t {
+ T store;
+ } ) ;
+
+
#endif /* PACKED_ATTRIBUTE_HPP_ */