aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgatecat <gatecat@ds0.me>2021-09-27 22:03:11 +0100
committerGitHub <noreply@github.com>2021-09-27 22:03:11 +0100
commit9d8d3bdbc48133ff7758c9c5293e5904bc6e5ba7 (patch)
treee532d82773047cfb5f101740a349d59976287108
parent535b2490c422f2343e97404c7c304c71b549e3a3 (diff)
parent0b0baf34467e82293c33ed04e966155e3bcc544f (diff)
downloadnextpnr-9d8d3bdbc48133ff7758c9c5293e5904bc6e5ba7.tar.gz
nextpnr-9d8d3bdbc48133ff7758c9c5293e5904bc6e5ba7.tar.bz2
nextpnr-9d8d3bdbc48133ff7758c9c5293e5904bc6e5ba7.zip
Merge pull request #827 from YosysHQ/gatecat/idstring-in
idstring: Add 'in' function from Yosys
-rw-r--r--common/idstring.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/common/idstring.h b/common/idstring.h
index 28f5456d..019e0a2a 100644
--- a/common/idstring.h
+++ b/common/idstring.h
@@ -58,6 +58,16 @@ struct IdString
bool empty() const { return index == 0; }
unsigned int hash() const { return index; }
+
+ template <typename... Args> bool in(Args... args) const
+ {
+ // 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(const IdString &rhs) const { return *this == rhs; }
};
NEXTPNR_NAMESPACE_END