Util: Add user-defined string literal for Json::Value
This commit is contained in:
+11
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user