diff --git a/include/rfl/Commented.hpp b/include/rfl/Commented.hpp index 156416ddd..836574938 100644 --- a/include/rfl/Commented.hpp +++ b/include/rfl/Commented.hpp @@ -14,6 +14,7 @@ template struct Commented { public: using Type = std::remove_cvref_t; + using ReflectionType = Type; Commented() : value_(Type()) {} @@ -134,6 +135,9 @@ struct Commented { return *this; } + /// Returns the underlying object. + const ReflectionType& reflection() const { return value_; } + /// Assigns the underlying object. void set(const Type& _value) { value_ = _value; } diff --git a/tests/yaml/test_comment_optional_array.cpp b/tests/yaml/test_comment_optional_array.cpp new file mode 100644 index 000000000..5b6d7e86d --- /dev/null +++ b/tests/yaml/test_comment_optional_array.cpp @@ -0,0 +1,22 @@ +#include + +#include +#include +#include +#include + +#include "write_and_read.hpp" + +namespace test_comment_optional_array { + +struct VeryCoolYaml { + rfl::Commented>> optionalArray = + std::nullopt; +}; + +TEST(yaml, test_comment_optional_array) { + const auto yaml = VeryCoolYaml{}; + write_and_read(yaml); +} + +} // namespace test_comment_optional_array