diff --git a/iceoryx_hoofs/vocabulary/include/iox/detail/expected.inl b/iceoryx_hoofs/vocabulary/include/iox/detail/expected.inl index c1e1f6562dd..4bc6995d83e 100644 --- a/iceoryx_hoofs/vocabulary/include/iox/detail/expected.inl +++ b/iceoryx_hoofs/vocabulary/include/iox/detail/expected.inl @@ -71,6 +71,13 @@ inline expected::expected(variant&& { } +template +inline expected::expected() noexcept + : m_store(in_place_index(), ValueType{}) +{ + static_assert(std::is_default_constructible::value, "'ValueType' must be default constructible!"); +} + template inline expected::expected(const success& successValue) noexcept : m_store(in_place_index(), successValue.value) diff --git a/iceoryx_hoofs/vocabulary/include/iox/expected.hpp b/iceoryx_hoofs/vocabulary/include/iox/expected.hpp index 2ca2008bea6..d7b8a9a57bb 100644 --- a/iceoryx_hoofs/vocabulary/include/iox/expected.hpp +++ b/iceoryx_hoofs/vocabulary/include/iox/expected.hpp @@ -136,9 +136,8 @@ template class IOX_NO_DISCARD expected final : public FunctionalInterface, void, ErrorType> { public: - /// @brief default ctor is deleted since you have to clearly state if the - /// expected contains a success value or an error value - expected() = delete; + /// @brief default ctor is creates an object which contains an expected value + expected() noexcept = default; /// @brief the copy constructor calls the copy constructor of the contained success value /// or the error value - depending on what is stored in the expected @@ -263,9 +262,9 @@ class IOX_NO_DISCARD expected final : public FunctionalInterface, ValueType, ErrorType> { public: - /// @brief default ctor is deleted since you have to clearly state if the - /// expected contains a success value or an error value - expected() = delete; + /// @brief default ctor is creates an object which contains an expected value + /// @note the 'ValueType' must be default constructible + expected() noexcept; /// @brief the copy constructor calls the copy constructor of the contained success value /// or the error value - depending on what is stored in the expected