Mr Flibble
unread,Jul 10, 2018, 5:43:17 PM7/10/18You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
Whilst coding my C++ JSON parser, "NoFussJSON", I used generic lambdas for
the first time. How cool/elegant are they? Look here:
case element::Number:
{
json_string newNumber{ currentElement.start, currentElement.start ==
nextOutputCh ? nextInputCh : nextOutputCh };
if (currentState == json_detail::state::NumberInt)
{
std::visit([this, ¤tElement](auto&& arg)
{
buy_value(currentElement, arg);
}, string_to_number(newNumber.as_view()));
}
else
buy_value(currentElement, neolib::string_to_double(newNumber.as_view()));
}
break;
They make using variants a breeze. The variant in question here is the
result of string_to_number function which can be int32_t, uint32_t,
int64_t, uint64_t or double depending on the parsed number string.
/Flibble
--
"Suppose it’s all true, and you walk up to the pearly gates, and are
confronted by God," Bryne asked on his show The Meaning of Life. "What
will Stephen Fry say to him, her, or it?"
"I’d say, bone cancer in children? What’s that about?" Fry replied.
"How dare you? How dare you create a world to which there is such misery
that is not our fault. It’s not right, it’s utterly, utterly evil."
"Why should I respect a capricious, mean-minded, stupid God who creates a
world that is so full of injustice and pain. That’s what I would say."