mercredi 17 août 2016

How should I parse __PRETTY_FUNCTION__?

I want to properly parse the __PRETTY_FUNCTION__ string and get something nice and structured, with which I could, say, iterate over the method parameters, or have a map from the template parameter names to their "values" (their values in string form, I mean).

Should I just "do it myself" with a bunch of std::string::find()'s and ::rfind()'s? Is there a more elegant way using some kind of parsing-related library - or would that be overkill and take a lot to set up? Or maybe some of the compilers have utility libraries which offer this functionality?

I've noticed some ad-hoc functions in other SO questions for, say, getting the namespace, or getting the class name etc., but I don't want to just have a bunch of these.





Aucun commentaire:

Enregistrer un commentaire