Restore legacy default allocation behavior in SmartPointer default constructor to fix crashes in tests

This commit is contained in:
AndreaRigoni
2026-04-16 14:29:57 +00:00
parent cbb9aa1139
commit e4379811a3

View File

@@ -56,8 +56,13 @@ public:
/**
* @brief Default constructor.
* Allocates a new T following legacy behavior.
*/
SmartPointer() noexcept : m_counter(nullptr) {}
SmartPointer() : m_counter(nullptr) {
if constexpr (std::is_default_constructible_v<T>) {
m_counter = new ReferenceCounter(new T());
}
}
/**
* @brief Constructor from nullptr.