Util: Add user-defined string literal for Json::Value

This commit is contained in:
Riyyi
2022-07-14 20:39:37 +02:00
parent 3ea87a1d28
commit 0841e49b46
+11 -1
View File
@@ -7,7 +7,7 @@
#ifndef JSON_VALUE_H
#define JSON_VALUE_H
#include <cstddef> // nullptr_t
#include <cstddef> // nullptr_t, size_t
#include <cstdint> // uint32_t
#include <initializer_list>
#include <iostream> // istream, ostream
@@ -129,4 +129,14 @@ std::ostream& operator<<(std::ostream& output, const Value& value);
} // namespace Json
/**
* User-defined string literal
*
* Example usage: auto json = "[ 3.14, true, null ]"_json;
*/
inline Json::Value operator"" _json(const char* input, size_t length)
{
return Json::Value::parse(std::string(input, length));
}
#endif // JSON_VALUE_H