Commit 4b55caa9 authored by Dominik Charousset's avatar Dominik Charousset

Reflect inspector API change in docs

parent 0d97fcde
...@@ -335,8 +335,8 @@ Specializing on the Data Format ...@@ -335,8 +335,8 @@ Specializing on the Data Format
------------------------------- -------------------------------
Much like ``is_loading`` allows client code to dispatch based on the mode of an Much like ``is_loading`` allows client code to dispatch based on the mode of an
inspector, the constant ``has_human_readable_format`` allows client code to inspector, the member function ``has_human_readable_format()`` allows client
dispatch based on the data format. code to dispatch based on the data format.
The canonical example for choosing a different data representation for The canonical example for choosing a different data representation for
human-readable input and output is the ``enum`` type. When generating data for human-readable input and output is the ``enum`` type. When generating data for
...@@ -372,7 +372,7 @@ an ``enum class`` otherwise. ...@@ -372,7 +372,7 @@ an ``enum class`` otherwise.
template <class Inspector> template <class Inspector>
static bool apply_object(Inspector& f, weekday& x) { static bool apply_object(Inspector& f, weekday& x) {
if constexpr (Inspector::has_human_readable_format) { if (f.has_human_readable_format()) {
auto get = [&x] { return to_string(x); }; auto get = [&x] { return to_string(x); };
auto set = [&x](std::string str) { return parse(str, x); }; auto set = [&x](std::string str) { return parse(str, x); };
f.object(x).fields(f.field("value", get, set)); f.object(x).fields(f.field("value", get, set));
...@@ -383,7 +383,7 @@ an ``enum class`` otherwise. ...@@ -383,7 +383,7 @@ an ``enum class`` otherwise.
template <class Inspector> template <class Inspector>
static bool apply_value(Inspector& f, weekday& x) { static bool apply_value(Inspector& f, weekday& x) {
if constexpr (Inspector::has_human_readable_format) { if (f.has_human_readable_format()) {
auto get = [&x] { return to_string(x); }; auto get = [&x] { return to_string(x); };
auto set = [&x](std::string str) { return parse(str, x); }; auto set = [&x](std::string str) { return parse(str, x); };
return inspect_value(f, get, set); return inspect_value(f, get, set);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment