diff --git a/include/rfl/parsing/Parser_default.hpp b/include/rfl/parsing/Parser_default.hpp index 0d7c8502..5bdf21cc 100644 --- a/include/rfl/parsing/Parser_default.hpp +++ b/include/rfl/parsing/Parser_default.hpp @@ -69,7 +69,7 @@ struct Parser { using ReflectionType = std::remove_cvref_t; const auto wrap_in_t = [](auto _named_tuple) -> Result { try { - return T{_named_tuple}; + return T{std::move(_named_tuple)}; } catch (std::exception& e) { return error(e.what()); } diff --git a/tests/json/test_movable.cpp b/tests/json/test_movable.cpp new file mode 100644 index 00000000..6bc420e2 --- /dev/null +++ b/tests/json/test_movable.cpp @@ -0,0 +1,28 @@ +#include +#include +#include +#include +#include +#include + +#include "write_and_read.hpp" + + +struct MoveableType { + int x; + + + MoveableType(MoveableType&&) = default; + MoveableType(const MoveableType&) = delete; + + using ReflectionType = int; + MoveableType(int&& x) : x(x) {} + int reflection() const { return x; } +}; + +TEST(json, test_moveable) { + MoveableType moveable = {2}; + + write_and_read( + moveable, R"(2)"); +} \ No newline at end of file