File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
src/core/json/include/sourcemeta/core Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -798,6 +798,17 @@ class SOURCEMETA_CORE_JSON_EXPORT JSON {
798
798
const typename Object::Container::hash_type hash,
799
799
const JSON &otherwise) const -> const JSON &;
800
800
801
+ // Constant reference parameters can accept xvalues which will be destructed
802
+ // after the call. When the function returns such a parameter also as constant
803
+ // reference, then the returned reference can be used after the object it
804
+ // refers to has been destroyed.
805
+ // https://clang.llvm.org/extra/clang-tidy/checks/bugprone/return-const-ref-from-parameter.html
806
+ // This overload avoids mis-uses of retuning const reference parameter as
807
+ // constant reference.
808
+ [[nodiscard]] auto at_or (const String &key,
809
+ const typename Object::Container::hash_type hash,
810
+ JSON &&otherwise) const -> const JSON & = delete;
811
+
801
812
// / This method retrieves a reference to the first element of a JSON array.
802
813
// / This method is undefined if the input JSON instance is an empty array. For
803
814
// / example:
You can’t perform that action at this time.
0 commit comments