diff --git a/rjp++/include/rjp_util.hpp b/rjp++/include/rjp_util.hpp index 46c6404..047d330 100644 --- a/rjp++/include/rjp_util.hpp +++ b/rjp++/include/rjp_util.hpp @@ -22,7 +22,7 @@ #include #include "integral.hpp" -namespace rjp::detail{ +namespace rjp{ namespace detail{ template,std::remove_reference_t>::value> struct convert_helper; @@ -64,6 +64,14 @@ namespace rjp::detail{ struct get_ref{ using type = std::remove_reference_t&&; }; + template + struct get_ref{ + using type = To&&; + }; + template + struct get_ref{ + using type = To&&; + }; } template @@ -71,14 +79,16 @@ namespace rjp::detail{ return static_cast::type>(std::forward(from)); } - template - void set_to_underlying(RJP_value* val, typename Val::underlying_type); - template<> - void set_to_underlying(RJP_value* val, RJP_int i); - template<> - void set_to_underlying(RJP_value* val, RJP_float f); - template<> - void set_to_underlying(RJP_value* val, RJP_bool b); + namespace detail{ + template + void set_to_underlying(RJP_value* val, typename Val::underlying_type); + template<> + void set_to_underlying(RJP_value* val, RJP_int i); + template<> + void set_to_underlying(RJP_value* val, RJP_float f); + template<> + void set_to_underlying(RJP_value* val, RJP_bool b); + } } #endif diff --git a/rjp++/tests/output.cpp b/rjp++/tests/output.cpp index bc52cd9..b4ae311 100644 --- a/rjp++/tests/output.cpp +++ b/rjp++/tests/output.cpp @@ -35,14 +35,14 @@ rjp::value case_6(void){ rjp::value case_8(void){ rjp::object obj; obj.add("key"_ss, 7); - return std::move(obj); + return rjp::cast(obj); } //handle object with subobject rjp::value case_9(void){ rjp::object obj; rjp::object sub = obj.add("key"_ss); sub.add("subkey"_ss, false); - return std::move(obj); + return rjp::cast(obj); } //handle object with multiple members rjp::value case_10(void){ @@ -50,7 +50,7 @@ rjp::value case_10(void){ rjp::object sub = obj.add("key"_ss); sub.add("subkey"_ss, false); sub.add("subkey2"_ss, true); - return std::move(obj); + return rjp::cast(obj); } //handle object member ordering rjp::value case_11(void){ @@ -58,7 +58,7 @@ rjp::value case_11(void){ rjp::object sub = obj.add("key"_ss); sub.add("subkey2"_ss, true); sub.add("subkey"_ss, false); - return std::move(obj); + return rjp::cast(obj); } //handle orderedobject member ordering /*RJP_value* case_12(void){ @@ -82,13 +82,13 @@ RJP_value* case_13(void){ rjp::value case_14(void){ rjp::array arr; arr.add(5); - return std::move(arr); + return rjp::cast(arr); } //handle array with subarray rjp::value case_15(void){ rjp::array arr; arr.add().add(false); - return std::move(arr); + return rjp::cast(arr); } //handle array with multiple elements rjp::value case_16(void){ @@ -96,7 +96,7 @@ rjp::value case_16(void){ rjp::array sub = arr.add(); sub.add(false); sub.add(true); - return std::move(arr); + return rjp::cast(arr); } //handle array with multiple elements and subarray rjp::value case_17(void){ @@ -105,7 +105,7 @@ rjp::value case_17(void){ rjp::array sub = arr.add(); sub.add(false); sub.add(true); - return std::move(arr); + return rjp::cast(arr); } //handle array with subobject with subarray rjp::value case_18(void){ @@ -114,7 +114,7 @@ rjp::value case_18(void){ rjp::object subobj = arr.add(); rjp::array subarr = subobj.add("key"_ss); subarr.add(false); - return std::move(arr); + return rjp::cast(arr); } //handle object with many members rjp::value case_19(void){ @@ -126,7 +126,7 @@ rjp::value case_19(void){ subobj.add(rexy::static_string(c), i % 2 == 0); c[3] += 1; } - return std::move(arr); + return rjp::cast(arr); } //handle orderedobject with many members as array element /*RJP_value* case_20(void){ @@ -151,7 +151,7 @@ rjp::value case_21(void){ rjp::array arr = obj.add("arr"_ss); for(int i = 0;i < 10;++i) arr.add(i); - return std::move(obj); + return rjp::cast(obj); } /* //handle unorderedobject conversion