From f713ef5e00864d80915e20bcadd871c10db86890 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Sat, 16 May 2015 03:36:01 +0300 Subject: [PATCH] LazyConstructor memory optimization --- libuavcan/include/uavcan/util/lazy_constructor.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libuavcan/include/uavcan/util/lazy_constructor.hpp b/libuavcan/include/uavcan/util/lazy_constructor.hpp index 93152adc71..08ff9ab5f9 100644 --- a/libuavcan/include/uavcan/util/lazy_constructor.hpp +++ b/libuavcan/include/uavcan/util/lazy_constructor.hpp @@ -26,12 +26,19 @@ namespace uavcan template class UAVCAN_EXPORT LazyConstructor { +#if UAVCAN_CPP_VERSION >= UAVCAN_CPP11 + struct + { + alignas(T) unsigned char pool[sizeof(T)]; + } data_; +#else union { unsigned char pool[sizeof(T)]; long double _aligner1; long long _aligner2; } data_; +#endif T* ptr_;