Skip to content

Commit 3b677d6

Browse files
committed
Let response::Value hold copy-on-write shared_ptr
1 parent fd09323 commit 3b677d6

File tree

2 files changed

+163
-35
lines changed

2 files changed

+163
-35
lines changed

include/graphqlservice/GraphQLResponse.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ struct Value
131131
GRAPHQLRESPONSE_EXPORT Value(Value&& other) noexcept;
132132
GRAPHQLRESPONSE_EXPORT explicit Value(const Value& other);
133133

134+
GRAPHQLRESPONSE_EXPORT Value(std::shared_ptr<const Value> other) noexcept;
135+
134136
GRAPHQLRESPONSE_EXPORT Value& operator=(Value&& rhs) noexcept;
135137
Value& operator=(const Value& rhs) = delete;
136138

@@ -213,8 +215,12 @@ struct Value
213215
std::unique_ptr<ScalarType> scalar;
214216
};
215217

218+
using SharedData = std::shared_ptr<const Value>;
219+
216220
using TypeData = std::variant<MapData, ListType, StringData, NullData, BooleanType, IntType,
217-
FloatType, EnumData, ScalarData>;
221+
FloatType, EnumData, ScalarData, SharedData>;
222+
223+
const TypeData& data() const noexcept;
218224

219225
TypeData _data;
220226
};

0 commit comments

Comments
 (0)