c++ - Is there a correct way to avoid warnings when comparing two different enums? -


When comparing emium from different sources, such as the following code emits GCC warnings without these C-styling What is the way to avoid warnings?

  straight enumerator {enum {VALUE = 5}; }; Template & lt; Int V> Templated Encoreter {enum {VALUE = V}; }; If (calculator :: VALUE == TemplatedEnumerator <5>: VALUE) {...}  

and GCC emits the following types of warning:

  GCC: Warning: Comparison between 'Anonymous ...' and 'Enam ...'  

Simple answer in your case: Do not use a enum , use an inline-defined static const int :

  struct enenerator {Fixed Intel cost VALUE = 5; }; Template & lt; Int V> Structure Templated Ennerter {Stable Intel Cost VALUE = V; };  

In this particular case, it is equivalent and should be treated by all the compilers of the last few years (I know for a fact that all the prominent people do).

Also see:


Comments