diff options
| author | Eddie Hung <eddie@fpgeh.com> | 2020-03-15 09:47:20 -0700 |
|---|---|---|
| committer | Eddie Hung <eddie@fpgeh.com> | 2020-04-02 07:14:08 -0700 |
| commit | 7bcbf0c9d1327c1e2fb3b96aa2cd888afbeb11b1 (patch) | |
| tree | ff9a2b8440e3fb1d8c8c10ef157dd3c6d7a1a8e2 /kernel | |
| parent | ba13a40ef4b2aa0f47debdfd1b0a3482aaef3887 (diff) | |
| download | yosys-7bcbf0c9d1327c1e2fb3b96aa2cd888afbeb11b1.tar.gz yosys-7bcbf0c9d1327c1e2fb3b96aa2cd888afbeb11b1.tar.bz2 yosys-7bcbf0c9d1327c1e2fb3b96aa2cd888afbeb11b1.zip | |
kernel: use C++11 fold hack to prevent recursion
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/rtlil.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/kernel/rtlil.h b/kernel/rtlil.h index c612ea769..2d490e635 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -361,9 +361,14 @@ namespace RTLIL // 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. - template<typename T, typename... Args> - bool in(T first, Args... rest) const { - return in(first) || in(rest...); + template<typename... Args> + bool in(Args... args) const { + //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; } |
