diff --git a/btas/util/mohndle.h b/btas/util/mohndle.h index 9646eca8..f895c6cc 100644 --- a/btas/util/mohndle.h +++ b/btas/util/mohndle.h @@ -195,7 +195,7 @@ namespace btas { [](auto&& v) -> const Storage* { using v_t = std::remove_reference_t; if constexpr (std::is_same_v || std::is_same_v) { - return &null_storage_; + return &null_storage(); } else if constexpr (std::is_same_v) { return &v; } else if constexpr (std::is_same_v) { @@ -294,7 +294,11 @@ namespace btas { } #endif - inline static Storage null_storage_ = {}; // used if this is null + /// delays construction of null storage object until first use + static Storage& null_storage() { + static Storage null = {}; + return null; + } }; template >>