config/Block: add method With()
This commit is contained in:
parent
ece35552fe
commit
96a37da03d
@ -59,6 +59,19 @@ struct BlockParam {
|
|||||||
*/
|
*/
|
||||||
[[noreturn]]
|
[[noreturn]]
|
||||||
void ThrowWithNested() const;
|
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 {
|
struct ConfigBlock {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user