mesa/src
Paul Berry cfe39ea14e i965: Allow C++ type safety in the use of enum brw_urb_write_flags.
(From a suggestion by Francisco Jerez)

If an enum represents a bitfield of flags, e.g.:

enum E {
  A = 1,
  B = 2,
  C = 4,
  D = 8,
};

then C++ normally prohibits statements like this:

enum E x = A | B;

because A and B are implicitly converted to ints before OR-ing them,
and an int can't be stored in an enum without a type cast.  C, on the
other hand, allows an int to be implicitly converted to an enum
without casting.

In the past we've dealt with this situation by storing flag bitfields
as ints.  This avoids ugly casting at the expense of some type safety
that C++ would normally have offered (e.g. we get no warning if we
accidentally use the wrong enum type).

However, we can get the best of both worlds if we override the |
operator.  The ugly casting is confined to the operator overload, and
we still get the benefit of C++ making sure we don't use the wrong
enum type.

v2: Remove unnecessary comment and unnecessary use of "enum" keyword.
Use static_cast.

Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Francisco Jerez <currojerez@riseup.net>
2013-08-26 10:15:51 -07:00
..
egl gbm: Link to libwayland-drm if Wayland EGL platform is enabled 2013-08-12 15:16:22 -07:00
gallium radeonsi: Also set the depth component mask bit for stencil-only exports 2013-08-26 15:47:50 +02:00
gbm gbm: Link to libwayland-drm if Wayland EGL platform is enabled 2013-08-12 15:16:22 -07:00
getopt
glsl glsl: Add built-in function prototypes for GLSL 3.30 2013-08-25 20:32:39 -07:00
glx glx: Generate GLXBadDrawable when drawable is zero 2013-08-13 17:53:33 -07:00
gtest gtest: Build it only for 'make check'. 2013-01-13 12:38:44 +01:00
mapi glapi/gen: build temporary files in the build directory 2013-08-21 18:34:59 +02:00
mesa i965: Allow C++ type safety in the use of enum brw_urb_write_flags. 2013-08-26 10:15:51 -07:00
Makefile.am gbm: Link to libwayland-drm if Wayland EGL platform is enabled 2013-08-12 15:16:22 -07:00
SConscript Remove libGLU 2012-08-31 10:58:15 -07:00