@@ -897,7 +897,7 @@ struct Result
897
897
AwaitableObject<std::shared_ptr<const Object>>, AwaitableScalar<Type>>;
898
898
899
899
// Convert a single value of the specified type to JSON.
900
- [[nodiscard]] static AwaitableResolver convert (future_type result, ResolverParams params);
900
+ [[nodiscard]] static AwaitableResolver convert (future_type result, ResolverParams&& params);
901
901
902
902
// Validate a single scalar value is the expected type.
903
903
static void validateScalar (const response::Value& value);
@@ -907,25 +907,25 @@ struct Result
907
907
// Export all of the built-in converters
908
908
template <>
909
909
GRAPHQLSERVICE_EXPORT AwaitableResolver Result<int >::convert(
910
- AwaitableScalar<int > result, ResolverParams params);
910
+ AwaitableScalar<int > result, ResolverParams&& params);
911
911
template <>
912
912
GRAPHQLSERVICE_EXPORT AwaitableResolver Result<double >::convert(
913
- AwaitableScalar<double > result, ResolverParams params);
913
+ AwaitableScalar<double > result, ResolverParams&& params);
914
914
template <>
915
915
GRAPHQLSERVICE_EXPORT AwaitableResolver Result<std::string>::convert(
916
- AwaitableScalar<std::string> result, ResolverParams params);
916
+ AwaitableScalar<std::string> result, ResolverParams&& params);
917
917
template <>
918
918
GRAPHQLSERVICE_EXPORT AwaitableResolver Result<bool >::convert(
919
- AwaitableScalar<bool > result, ResolverParams params);
919
+ AwaitableScalar<bool > result, ResolverParams&& params);
920
920
template <>
921
921
GRAPHQLSERVICE_EXPORT AwaitableResolver Result<response::IdType>::convert(
922
- AwaitableScalar<response::IdType> result, ResolverParams params);
922
+ AwaitableScalar<response::IdType> result, ResolverParams&& params);
923
923
template <>
924
924
GRAPHQLSERVICE_EXPORT AwaitableResolver Result<response::Value>::convert(
925
- AwaitableScalar<response::Value> result, ResolverParams params);
925
+ AwaitableScalar<response::Value> result, ResolverParams&& params);
926
926
template <>
927
927
GRAPHQLSERVICE_EXPORT AwaitableResolver Result<Object>::convert(
928
- AwaitableObject<std::shared_ptr<const Object>> result, ResolverParams params);
928
+ AwaitableObject<std::shared_ptr<const Object>> result, ResolverParams&& params);
929
929
930
930
// Export all of the scalar value validation methods
931
931
template <>
@@ -1010,7 +1010,7 @@ struct ModifiedResult
1010
1010
// Peel off the none modifier. If it's included, it should always be last in the list.
1011
1011
template <TypeModifier Modifier = TypeModifier::None, TypeModifier... Other>
1012
1012
[[nodiscard]] static AwaitableResolver convert (
1013
- AwaitableObject<typename ResultTraits<Type>::type> result, ResolverParams params )
1013
+ AwaitableObject<typename ResultTraits<Type>::type> result, ResolverParams&& paramsArg )
1014
1014
requires NoneObjectDerivedType<Type, Modifier>
1015
1015
{
1016
1016
// Call through to the Object specialization with a static_pointer_cast for subclasses of
@@ -1019,6 +1019,9 @@ struct ModifiedResult
1019
1019
static_assert (std::is_same_v<std::shared_ptr<Type>, typename ResultTraits<Type>::type>,
1020
1020
" this is the derived object type" );
1021
1021
1022
+ // Move the paramsArg into a local variable before the first suspension point.
1023
+ auto params = std::move (paramsArg);
1024
+
1022
1025
co_await params.launch ;
1023
1026
1024
1027
auto awaitedResult = co_await Result<Object>::convert (
@@ -1031,7 +1034,7 @@ struct ModifiedResult
1031
1034
// Peel off the none modifier. If it's included, it should always be last in the list.
1032
1035
template <TypeModifier Modifier = TypeModifier::None, TypeModifier... Other>
1033
1036
[[nodiscard]] static AwaitableResolver convert (
1034
- typename ResultTraits<Type>::future_type result, ResolverParams params)
1037
+ typename ResultTraits<Type>::future_type result, ResolverParams&& params)
1035
1038
requires NoneScalarOrObjectType<Type, Modifier>
1036
1039
{
1037
1040
static_assert (sizeof ...(Other) == 0 , " None modifier should always be last" );
@@ -1043,9 +1046,13 @@ struct ModifiedResult
1043
1046
// Peel off final nullable modifiers for std::shared_ptr of Object and subclasses of Object.
1044
1047
template <TypeModifier Modifier, TypeModifier... Other>
1045
1048
[[nodiscard]] static AwaitableResolver convert (
1046
- typename ResultTraits<Type, Modifier, Other...>::future_type result, ResolverParams params)
1049
+ typename ResultTraits<Type, Modifier, Other...>::future_type result,
1050
+ ResolverParams&& paramsArg)
1047
1051
requires NullableResultSharedPtr<Type, Modifier, Other...>
1048
1052
{
1053
+ // Move the paramsArg into a local variable before the first suspension point.
1054
+ auto params = std::move (paramsArg);
1055
+
1049
1056
co_await params.launch ;
1050
1057
1051
1058
auto awaitedResult = co_await std::move (result);
@@ -1064,7 +1071,8 @@ struct ModifiedResult
1064
1071
// Peel off nullable modifiers for anything else, which should all be std::optional.
1065
1072
template <TypeModifier Modifier, TypeModifier... Other>
1066
1073
[[nodiscard]] static AwaitableResolver convert (
1067
- typename ResultTraits<Type, Modifier, Other...>::future_type result, ResolverParams params)
1074
+ typename ResultTraits<Type, Modifier, Other...>::future_type result,
1075
+ ResolverParams&& paramsArg)
1068
1076
requires NullableResultOptional<Type, Modifier, Other...>
1069
1077
{
1070
1078
static_assert (std::is_same_v<std::optional<typename ResultTraits<Type, Other...>::type>,
@@ -1083,6 +1091,9 @@ struct ModifiedResult
1083
1091
}
1084
1092
}
1085
1093
1094
+ // Move the paramsArg into a local variable before the first suspension point.
1095
+ auto params = std::move (paramsArg);
1096
+
1086
1097
co_await params.launch ;
1087
1098
1088
1099
auto awaitedResult = co_await std::move (result);
@@ -1101,7 +1112,8 @@ struct ModifiedResult
1101
1112
// Peel off list modifiers.
1102
1113
template <TypeModifier Modifier, TypeModifier... Other>
1103
1114
[[nodiscard]] static AwaitableResolver convert (
1104
- typename ResultTraits<Type, Modifier, Other...>::future_type result, ResolverParams params)
1115
+ typename ResultTraits<Type, Modifier, Other...>::future_type result,
1116
+ ResolverParams&& paramsArg)
1105
1117
requires ListModifier<Modifier>
1106
1118
{
1107
1119
if constexpr (!ObjectBaseType<Type>)
@@ -1116,6 +1128,9 @@ struct ModifiedResult
1116
1128
}
1117
1129
}
1118
1130
1131
+ // Move the paramsArg into a local variable before the first suspension point.
1132
+ auto params = std::move (paramsArg);
1133
+
1119
1134
std::vector<AwaitableResolver> children;
1120
1135
const auto parentPath = params.errorPath ;
1121
1136
@@ -1242,7 +1257,7 @@ struct ModifiedResult
1242
1257
std::function<response::Value(typename ResultTraits<Type>::type, const ResolverParams&)>;
1243
1258
1244
1259
[[nodiscard]] static AwaitableResolver resolve (typename ResultTraits<Type>::future_type result,
1245
- ResolverParams params , ResolverCallback&& resolver)
1260
+ ResolverParams&& paramsArg , ResolverCallback&& resolver)
1246
1261
{
1247
1262
static_assert (!ObjectBaseType<Type>, " ModfiedResult<Object> needs special handling" );
1248
1263
@@ -1257,6 +1272,9 @@ struct ModifiedResult
1257
1272
auto pendingResolver = std::move (resolver);
1258
1273
ResolverResult document;
1259
1274
1275
+ // Move the paramsArg into a local variable before the first suspension point.
1276
+ auto params = std::move (paramsArg);
1277
+
1260
1278
try
1261
1279
{
1262
1280
co_await params.launch ;
0 commit comments