Skip to content

Commit a589a56

Browse files
committed
Supply value_type typedef in json_arrayt for STL algorithm usage.
Some of the STL algorithms require the `value_type` typedef on containers. Adding this typedef allows these algorithms to be used with `json_arrayt`. The following example will not compile without this commit. ``` std::vector<std::string> example_strings = {"green", "eggs", "ham"}; json_arrayt json_array; std::transform( example_strings.cbegin(), example_strings.cend(), std::back_inserter(json_array), [](std::string string) { return json_stringt(string); }); ```
1 parent d069719 commit a589a56

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/util/json.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ class json_arrayt:public jsont
169169
array.push_back(jsont());
170170
return array.back();
171171
}
172+
173+
typedef jsont value_type; // NOLINT(readability/identifiers)
172174
};
173175

174176
class json_stringt:public jsont

0 commit comments

Comments
 (0)