Follow

Just tried making my packet parsing constexpr until I realized I used std::function which requires function pointers which are themselves only decided at link time...
No constexpr for my parser :(

@huntears Had a bit more of a play around and you can definitely do parsers fully constexpr: gcc.godbolt.org/z/373qqqzWc

Not sure how familiar you are with the language features there so feel free to ask if you want more explanation.

(also btw `_payload.erase(_payload.begin())` in your current code takes time proportional to the length of the payload so would be really slow for large packets if you're doing that for each byte)

(also lmao this definitely nerd sniped me)

@ralismark Thank you a lot for looking into it :D
I will see if I can implement it somehow today.

@ralismark So I learned multiple things already, for example :
- I didn't know pointer-to-members were this good
- constexpr still things magic, cause damn that godbolt output is good XD

@ralismark Can I re-use the code you wrote for my project ?
Because I really like the varInt parser

@huntears sure! credit me if you want, but you don't have to

@ralismark Here is the commit if you're interested, once again thanks a lot :D

Sign in to participate in the conversation
Fosstodon

Fosstodon is an English speaking Mastodon instance that is open to anyone who is interested in technology; particularly free & open source software.