Commit 96a37da0 authored by Max Kellermann's avatar Max Kellermann

config/Block: add method With()

parent ece35552
......@@ -59,6 +59,19 @@ struct BlockParam {
*/
[[noreturn]]
void ThrowWithNested() const;
/**
* Invoke a function with the configured value; if the
* function throws, call ThrowWithNested().
*/
template<typename F>
auto With(F &&f) const {
try {
return f(value.c_str());
} catch (...) {
ThrowWithNested();
}
}
};
struct ConfigBlock {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment