17 #ifndef IOX_UTILS_DESIGN_PATTERN_CREATION_HPP
18 #define IOX_UTILS_DESIGN_PATTERN_CREATION_HPP
20 #include "iceoryx_utils/cxx/expected.hpp"
24 namespace DesignPattern
97 template <
typename DerivedClass,
typename ErrorType>
102 using result_t = iox::cxx::expected<DerivedClass, ErrorType>;
103 using errorType_t = ErrorType;
111 template <
typename... Targs>
112 static result_t
create(Targs&&... args) noexcept;
118 static result_t
verify(DerivedClass&& newObject) noexcept;
127 template <
typename... Targs>
141 bool m_isInitialized{
false};
142 ErrorType m_errorValue;
147 #include "iceoryx_utils/internal/design_pattern/creation.inl"
This pattern can be used if you write an abstraction where you have to throw an exception in the cons...
Definition: creation.hpp:99
bool isInitialized() const noexcept
returns true if the object was constructed successfully, otherwise false
Definition: creation.inl:47
static result_t create(Targs &&... args) noexcept
factory method which guarantees that either a working object is produced or an error value describing...
Definition: creation.inl:41
static iox::cxx::expected< ErrorType > placementCreate(void *const memory, Targs &&... args) noexcept
factory method which guarantees that either a working object is produced or an error value describing...
Definition: creation.inl:66
static result_t verify(DerivedClass &&newObject) noexcept
verifies if a class was created successfully
Definition: creation.inl:54
expected implementation from the C++20 proposal with C++11. The interface is inspired by the proposal...
Definition: expected.hpp:163