diff --git a/iceoryx_hoofs/vocabulary/include/iox/detail/expected.inl b/iceoryx_hoofs/vocabulary/include/iox/detail/expected.inl index 82a164eef09..28306182b0e 100644 --- a/iceoryx_hoofs/vocabulary/include/iox/detail/expected.inl +++ b/iceoryx_hoofs/vocabulary/include/iox/detail/expected.inl @@ -22,67 +22,67 @@ namespace iox { template -detail::success ok() +detail::ok ok() { - return detail::success{}; + return detail::ok{}; } template -detail::success ok(const T& value) +detail::ok ok(const T& value) { - return detail::success{value}; + return detail::ok{value}; } template -detail::success ok(T&& value) +detail::ok ok(T&& value) { - return detail::success{std::forward(value)}; + return detail::ok{std::forward(value)}; } template -detail::success ok(Targs&&... args) +detail::ok ok(Targs&&... args) { - return detail::success{std::forward(args)...}; + return detail::ok{std::forward(args)...}; } template -detail::error err(const T& value) +detail::err err(const T& value) { - return detail::error{value}; + return detail::err{value}; } template -detail::error err(T&& value) +detail::err err(T&& value) { - return detail::error{std::forward(value)}; + return detail::err{std::forward(value)}; } template -detail::error err(Targs&&... args) +detail::err err(Targs&&... args) { - return detail::error{std::forward(args)...}; + return detail::err{std::forward(args)...}; } template -inline expected::expected(const detail::success& successValue) noexcept +inline expected::expected(const detail::ok& successValue) noexcept : m_store(in_place, successValue.value) { } template -inline expected::expected(detail::success&& successValue) noexcept +inline expected::expected(detail::ok&& successValue) noexcept : m_store(in_place, std::move(successValue.value)) { } template -inline expected::expected(const detail::error& errorValue) noexcept +inline expected::expected(const detail::err& errorValue) noexcept : m_store(unexpect, errorValue.value) { } template -inline expected::expected(detail::error&& errorValue) noexcept +inline expected::expected(detail::err&& errorValue) noexcept : m_store(unexpect, std::move(errorValue.value)) { } diff --git a/iceoryx_hoofs/vocabulary/include/iox/detail/expected_helper.hpp b/iceoryx_hoofs/vocabulary/include/iox/detail/expected_helper.hpp index 99cc884053a..238598bf924 100644 --- a/iceoryx_hoofs/vocabulary/include/iox/detail/expected_helper.hpp +++ b/iceoryx_hoofs/vocabulary/include/iox/detail/expected_helper.hpp @@ -47,25 +47,25 @@ namespace detail { /// @brief helper struct to create an expected which is signalling success more easily template -struct success +struct ok { // AXIVION Next Construct AutosarC++19_03-A12.1.5 : This is a false positive since there is no fitting constructor // available for delegation - explicit success(const T& t) noexcept + explicit ok(const T& t) noexcept : value(t) { } // AXIVION Next Construct AutosarC++19_03-A18.9.2 : For universal references std::forward must be used template > - explicit success(T&& t) noexcept + explicit ok(T&& t) noexcept : value(std::forward(t)) { } - // AXIVION Next Construct AutosarC++19_03-A15.4.2, FaultDetection-NoexceptViolations : Intentional behavior. 'success' is not intended to be used with a type which throws + // AXIVION Next Construct AutosarC++19_03-A15.4.2, FaultDetection-NoexceptViolations : Intentional behavior. 'ok' is not intended to be used with a type which throws template - explicit success(Targs&&... args) noexcept + explicit ok(Targs&&... args) noexcept : value(std::forward(args)...) { } @@ -75,7 +75,7 @@ struct success /// @brief helper struct to handle 'void' value type specialization template <> -struct success +struct ok { // dummy value bool value{true}; @@ -83,24 +83,24 @@ struct success /// @brief helper struct to create an expected which is signalling an error more easily template -struct error +struct err { // AXIVION Next Construct AutosarC++19_03-A12.1.5 : This is a false positive since there is no fitting constructor // available for delegation - explicit error(const T& t) noexcept + explicit err(const T& t) noexcept : value(t) { } // AXIVION Next Construct AutosarC++19_03-A18.9.2 : For universal references std::forward must be used template > - explicit error(T&& t) noexcept + explicit err(T&& t) noexcept : value(std::forward(t)) { } template - explicit error(Targs&&... args) noexcept + explicit err(Targs&&... args) noexcept : value(std::forward(args)...) { } diff --git a/iceoryx_hoofs/vocabulary/include/iox/expected.hpp b/iceoryx_hoofs/vocabulary/include/iox/expected.hpp index c5c645c3c65..e0389d235d5 100644 --- a/iceoryx_hoofs/vocabulary/include/iox/expected.hpp +++ b/iceoryx_hoofs/vocabulary/include/iox/expected.hpp @@ -27,10 +27,10 @@ namespace iox { template -using success = detail::success; +using success = detail::ok; template -using error = detail::error; +using error = detail::err; /// @brief convenience function to create an 'expected' with a 'void' value type /// @param T helper template parameter for SFINEA @@ -41,7 +41,7 @@ using error = detail::error; /// } /// @endcode template > -detail::success ok(); +detail::ok ok(); /// @brief convenience function to create an 'expected' with a value type by copy /// @param T value type for the 'expected' @@ -52,7 +52,7 @@ detail::success ok(); /// } /// @endcode template > -detail::success ok(const T& value); +detail::ok ok(const T& value); /// @brief convenience function to create an 'expected' with a value type by move /// @param T value type for the 'expected' @@ -65,7 +65,7 @@ detail::success ok(const T& value); /// } /// @endcode template , typename = enable_if_not_lvalue_referece_t> -detail::success ok(T&& value); +detail::ok ok(T&& value); /// @brief convenience function to create an 'expected' with a value type by argument forwarding /// @param T value type for the 'expected' @@ -76,7 +76,7 @@ detail::success ok(T&& value); /// } /// @endcode template > -detail::success ok(Targs&&... args); +detail::ok ok(Targs&&... args); /// @brief convenience function to create an 'expected' with an error type by copy /// @param T error type for the 'expected' @@ -87,7 +87,7 @@ detail::success ok(Targs&&... args); /// } /// @endcode template -detail::error err(const T& value); +detail::err err(const T& value); /// @brief convenience function to create an 'expected' with an error type by move /// @param T error type for the 'expected' @@ -100,7 +100,7 @@ detail::error err(const T& value); /// } /// @endcode template > -detail::error err(T&& value); +detail::err err(T&& value); /// @brief convenience function to create an 'expected' with an error type by argument forwarding /// @param T error type for the 'expected' @@ -111,7 +111,7 @@ detail::error err(T&& value); /// } /// @endcode template -detail::error err(Targs&&... args); +detail::err err(Targs&&... args); /// @brief Implementation of the C++23 expected class which can contain an error or a success value /// @param ValueType type of the value which can be stored in the expected @@ -171,7 +171,7 @@ class IOX_NO_DISCARD expected final : public FunctionalInterface& successValue) noexcept; + expected(const detail::ok& successValue) noexcept; /// @brief constructs an expected which is signaling success and uses the value /// provided by successValue to move construct its success value @@ -180,7 +180,7 @@ class IOX_NO_DISCARD expected final : public FunctionalInterface&& successValue) noexcept; + expected(detail::ok&& successValue) noexcept; /// @brief constructs an expected which is signaling an error and stores the /// error value provided by errorValue @@ -189,7 +189,7 @@ class IOX_NO_DISCARD expected final : public FunctionalInterface& errorValue) noexcept; + expected(const detail::err& errorValue) noexcept; /// @brief constructs an expected which is signaling an error and stores the /// error value provided by errorValue @@ -198,7 +198,7 @@ class IOX_NO_DISCARD expected final : public FunctionalInterface&& errorValue) noexcept; + expected(detail::err&& errorValue) noexcept; /// @brief creates an expected which is signaling success and perfectly forwards /// the args to the constructor of ValueType