mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-07 01:54:10 +00:00
kernel: use C++11 fold hack to prevent recursion
This commit is contained in:
parent
ba13a40ef4
commit
7bcbf0c9d1
|
@ -361,9 +361,14 @@ namespace RTLIL
|
||||||
// often one needs to check if a given IdString is part of a list (for example a list
|
// often one needs to check if a given IdString is part of a list (for example a list
|
||||||
// of cell types). the following functions helps with that.
|
// of cell types). the following functions helps with that.
|
||||||
|
|
||||||
template<typename T, typename... Args>
|
template<typename... Args>
|
||||||
bool in(T first, Args... rest) const {
|
bool in(Args... args) const {
|
||||||
return in(first) || in(rest...);
|
//return in(first) || in(rest...);
|
||||||
|
|
||||||
|
// Credit: https://articles.emptycrate.com/2016/05/14/folds_in_cpp11_ish.html
|
||||||
|
bool result = false;
|
||||||
|
(void) std::initializer_list<int>{ (result = result || in(args), 0)... };
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool in(IdString rhs) const { return *this == rhs; }
|
bool in(IdString rhs) const { return *this == rhs; }
|
||||||
|
|
Loading…
Reference in a new issue