summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorFrancisco Jerez <currojerez@riseup.net>2018-02-24 18:37:34 -0800
committerFrancisco Jerez <currojerez@riseup.net>2018-02-27 11:38:18 -0800
commit69b4a9d21d00e1f72b52e818cc059ee1642f263e (patch)
tree68506ea49d7ffebb4c0d317c9c80fbd6b2c104ee /src/util
parent9f223d860b6fed0ae296bcd1b8ae14dca66a7986 (diff)
util/bitset: Make C++ wrapper trivially constructible.
In order to fix a build failure on compilers not implementing unrestricted unions, which is a C++11 feature. v2: Provide signed integer comparison and assignment operators instead of BITSET_WORD ones to avoid spurious ambiguity warnings on comparisons with a signed integer literal. Fixes: ba79a90fb52e1e81fb "glsl: Switch ast_type_qualifier to a 128-bit bitset." Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105238 Tested-by: Roland Scheidegger <sroland@vmware.com> Tested-By: George Kyriazis <george.kyriazis@intel.com> Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Diffstat (limited to 'src/util')
-rw-r--r--src/util/bitset.h37
1 files changed, 20 insertions, 17 deletions
diff --git a/src/util/bitset.h b/src/util/bitset.h
index 7bb5f3c83cf..b4c21520238 100644
--- a/src/util/bitset.h
+++ b/src/util/bitset.h
@@ -142,23 +142,6 @@ __bitset_next_set(unsigned i, BITSET_WORD *tmp,
* it as, and N is the number of bits in the bitset.
*/
#define DECLARE_BITSET_T(T, N) struct T { \
- /* XXX - Replace this with an implicitly-defined \
- * constructor when support for C++11 defaulted \
- * constructors can be assumed (available on GCC 4.4 and \
- * later) in order to make the object trivially \
- * constructible like a fundamental integer type for \
- * convenience. \
- */ \
- T() \
- { \
- } \
- \
- T(BITSET_WORD x) \
- { \
- for (unsigned i = 0; i < BITSET_WORDS(N); i++, x = 0) \
- words[i] = x; \
- } \
- \
EXPLICIT_CONVERSION \
operator bool() const \
{ \
@@ -168,6 +151,13 @@ __bitset_next_set(unsigned i, BITSET_WORD *tmp,
return false; \
} \
\
+ T & \
+ operator=(int x) \
+ { \
+ const T c = {{ (BITSET_WORD)x }}; \
+ return *this = c; \
+ } \
+ \
friend bool \
operator==(const T &b, const T &c) \
{ \
@@ -180,6 +170,19 @@ __bitset_next_set(unsigned i, BITSET_WORD *tmp,
return !(b == c); \
} \
\
+ friend bool \
+ operator==(const T &b, int x) \
+ { \
+ const T c = {{ (BITSET_WORD)x }}; \
+ return b == c; \
+ } \
+ \
+ friend bool \
+ operator!=(const T &b, int x) \
+ { \
+ return !(b == x); \
+ } \
+ \
friend T \
operator~(const T &b) \
{ \