[Intel C++ 14.0] Macro enum class

[Intel C++ 14.0] Macro enum class

Hellow my friends!

In MSVC2013 perfectly works for me this macro (which allow use enum class as flag enum and disallow convert to int):

#pragma once

#define EnumClass(Enum, Type) \
enum class Enum : Type; \
inline Enum  operator &  (Enum x, Enum y)  {return static_cast<Enum> (static_cast<Type>(x) & static_cast<Type>(y));}; \
inline Enum  operator |  (Enum x, Enum y)  {return static_cast<Enum> (static_cast<Type>(x) | static_cast<Type>(y));}; \
inline Enum  operator ^  (Enum x, Enum y)  {return static_cast<Enum> (static_cast<Type>(x) ^ static_cast<Type>(y));}; \
inline Enum  operator ~  (Enum x)          {return static_cast<Enum> (~static_cast<Type>(x));};                       \
inline Enum& operator &= (Enum& x, Enum y) {x = x & y; return x;};                                                    \
inline Enum& operator |= (Enum& x, Enum y) {x = x | y; return x;};                                                    \
inline Enum& operator ^= (Enum& x, Enum y) {x = x ^ y; return x;};                                                    \
enum class Enum : Type

But in Intel C++ 14.0 fails on:

 

                EnumClass(ToolhelpSnapshotFlag, unsigned __int32)
                {
                    List     = 0x00000001,
                    Process  = 0x00000002,
                    Thread   = 0x00000004,
                    Module   = 0x00000008,
                    Module32 = 0x00000010,
                    All      = List | Process | Thread | Module, //error : expression must have a constant value
                    Inherit  = 0x80000000
                };

How to enable works this on Intel C++ 14.0 without converting result of all operators to underlying type?

 

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hello,

I can reproduce the problem and created a ticket for engineering: DPD200515852

On our compiler for Linux this case passes. So, it seems to be some compatibility setting for VS that's in the way. I'll let you know once we've fixed that or whether there's some workaround.

Thank you for reporting & best regards,

Georg Zitzlsberger

Hello,

this should be fixed with Intel(R) Composer XE 2013 SP1 Update 3, available soon.

Best regards,

Georg Zitzlsberger

Leave a Comment

Please sign in to add a comment. Not a member? Join today