Enums und Bitfelder
-
Hallo,
nehmen wir folgende Typen:
enum Type { a, b, c, d }; class Wrap { public: Type t : 2; };Stellt der Standard an dieser Stelle sicher, dass die Werte von Type in Wrap::t passen, indem er fordert, dass Wrap::t unsigned ist? Ich sehe das nicht.
-
Falsches Forum, der C-Standard verbietet enum-Bitfelder.
Im C++-Standard findet sich ein Hinweis, der folgendes besagt:
If the value of an enumerator is stored into a bit-field of the same enumeration type and the number of bits in the bit-field is large enough to hold all the values of that enumeration type, the original enumerator value and the value of the bit-field shall compare equal. [...]
(9.6p4)
Also muß man sich um Vergleiche und Zuweisungen keine tieferen Gedanken machen, es funktioniert halt.
-
Daniel E. schrieb:
Falsches Forum, der C-Standard verbietet enum-Bitfelder.
Im C++-Standard findet sich ein Hinweis, der folgendes besagt:
If the value of an enumerator is stored into a bit-field of the same enumeration type and the number of bits in the bit-field is large enough to hold all the values of that enumeration type, the original enumerator value and the value of the bit-field shall compare equal. [...]
(9.6p4)
Also muß man sich um Vergleiche und Zuweisungen keine tieferen Gedanken machen, es funktioniert halt.
Danke
-
Dieser Thread wurde von Moderator/in c.rackwitz aus dem Forum ANSI C in das Forum C++ verschoben.
Im Zweifelsfall bitte auch folgende Hinweise beachten:
C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?Dieses Posting wurde automatisch erzeugt.