mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-05 02:33:07 +02:00
refactor: Enable -Wswitch in exhaustive switch
Also, apply the comment according to the dev notes. Also, modify the dev notes to give a lambda-wrapped example. Can be reviewed via --ignore-all-space Co-authored-by: Lőrinc <pap.lorinc@gmail.com>
This commit is contained in:
@@ -854,19 +854,19 @@ Foo(vec);
|
||||
enum class Tabs {
|
||||
info,
|
||||
console,
|
||||
network_graph,
|
||||
peers
|
||||
};
|
||||
|
||||
int GetInt(Tabs tab)
|
||||
{
|
||||
switch (tab) {
|
||||
case Tabs::info: return 0;
|
||||
case Tabs::console: return 1;
|
||||
case Tabs::network_graph: return 2;
|
||||
case Tabs::peers: return 3;
|
||||
} // no default case, so the compiler can warn about missing cases
|
||||
assert(false);
|
||||
int ret = [&]() {
|
||||
switch (tab) {
|
||||
case Tabs::info: return 0;
|
||||
case Tabs::console: return 1;
|
||||
} // no default case, so the compiler can warn about missing cases
|
||||
assert(false);
|
||||
}();
|
||||
LogInfo("Tab %s", ret);
|
||||
return ret;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user