I'm trying to create a simple parser with metaparse to demonstrate how I can return my own custom types.
If I had a custom type ValNum, how can I integrate this into a basic parser such that it is returned by the parser after matching a number? Apologies if this is trivial but I've been struggling to achieve this.
template<int Value>
struct ValNum {
constexpr static int value = Value;
};
You can return custom types by using the
transformfunction along with a metafunction.Here's a really quick example of returning a custom type (butchering the
identitymetafunction class they gave in the link and a couple over examples I found in their offical GitHub)Hope this helps someone.