@@ -174,3 +174,33 @@ struct PersonImpl {
174
174
}
175
175
};
176
176
```
177
+
178
+ ## Implement the ` Parser ` template
179
+
180
+ You can also directly implement the Parser template for your type.
181
+ This might be beneficial when you have a third-party container type
182
+ that behaves like standard containers.
183
+
184
+ In our example, we are implementing the template for ` gtl::flat_hash_map ` ,
185
+ but the approach should also work for similar boost containers.
186
+
187
+ ``` cpp
188
+ namespace rfl {
189
+ namespace parsing {
190
+
191
+ template <class K, class V, class Hash, class KeyEqual, class Allocator>
192
+ class is_map_like<gtl::flat_hash_map<K, V, Hash, KeyEqual, Allocator>> : public std::true_type {};
193
+
194
+ template <class R, class W, class T, class Hash, class KeyEqual, class ProcessorsType>
195
+ requires AreReaderAndWriter<R, W, gtl::flat_hash_map<std::string, T, Hash>>
196
+ struct Parser<R, W, gtl::flat_hash_map<std::string, T, Hash, KeyEqual>, ProcessorsType>
197
+ : public MapParser<R, W, gtl::flat_hash_map<std::string, T, Hash, KeyEqual>, ProcessorsType> {};
198
+
199
+ template <class R, class W, typename K, typename V, class Hash, class KeyEqual, class Allocator, class ProcessorsType>
200
+ requires AreReaderAndWriter<R, W, gtl::flat_hash_map<K, V, Hash, KeyEqual, Allocator>>
201
+ struct Parser<R, W, gtl::flat_hash_map<K, V, Hash, KeyEqual, Allocator>, ProcessorsType>
202
+ : public VectorParser<R, W, gtl::flat_hash_map<K, V, Hash, KeyEqual, Allocator>, ProcessorsType> {};
203
+
204
+ }
205
+ }
206
+ ```
0 commit comments