diff --git a/docs/custom_parser.md b/docs/custom_parser.md index b7ae2446..8a40e232 100644 --- a/docs/custom_parser.md +++ b/docs/custom_parser.md @@ -174,3 +174,33 @@ struct PersonImpl { } }; ``` + +## Implement the `Parser` template + +You can also directly implement the Parser template for your type. +This might be beneficial when you have a third-party container type +that behaves like standard containers. + +In our example, we are implementing the template for `gtl::flat_hash_map`, +but the approach should also work for similar boost containers. + +```cpp +namespace rfl { +namespace parsing { + +template +class is_map_like> : public std::true_type {}; + +template + requires AreReaderAndWriter> +struct Parser, ProcessorsType> + : public MapParser, ProcessorsType> {}; + +template + requires AreReaderAndWriter> +struct Parser, ProcessorsType> + : public VectorParser, ProcessorsType> {}; + +} +} +```