Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.std.c++ > #652

Re: Is a union a kind of class?

From Daniel Krügler <daniel.kruegler@googlemail.com>
Newsgroups comp.std.c++
Subject Re: Is a union a kind of class?
Date 2013-08-31 23:52 -0700
Organization A noiseless patient Spider
Message-ID <kvscmq$65o$1@dont-email.me> (permalink)
References <52204496.5050408@bawi.org>

Show all headers | View raw


Am 31.08.2013 09:12, schrieb Seungbeom Kim:
>
>
> In the taxonomy of C++ types, is a union a (kind of) class?


Yes, it is a class type.

> 9[class]/5 clearly says, "A union is a class defined with the class-key
> union [...]". 5.1.2[expr.prim.lambda]/3 and 9[class]/10 also mention "a
> non-union class [type]", and 5.9[expr.rel]/2 "provided their class is
> not a union", all of which imply that a union is a class.


Right.

> On the other hand, 3.9.2[basic.compound]/1 lists classes and unions
> separately, which strongly implies that a union is not a class.


It lists them separately, but it still describes union as (special) classes:

"unions, which are classes [..]"

The bullet before speaks of

"classes containing a sequence of objects of various types [..]"

which is also a constrained set of class types. In other words: These
two bullets describe the two families of class types: union class
types and non-union class types but in a more descriptive way. These
bullets do not define these families, but refer to Clause 9 where they
are defined more specifically.

I have a hard time to follow your interpretation "that a union is not a class".

> If a union is a class, I think 3.9.2/1 is confusing (at best) and should
> be considered a defect.


I think that goes a little bit too far. 3.9.2/1 does not *define* the
two families of class types, but lists some characteristics (This list
is not considered as complete), the actual definition is defined in
Clause 9. In both bullets are different types described, that are both
class types. IMO the meaning of the types described in these bullets
is unambiguously clear, when read in the context of the definition
provided in Clause 9.

What kind of better wording would you like to see here? It may easily
be possible to fix that editorially.

Greetings from Bremen,

Daniel Krügler










--
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]

Back to comp.std.c++ | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Is a union a kind of class? Seungbeom Kim <musiphil@bawi.org> - 2013-08-31 01:12 -0600
  Re: Is a union a kind of class? Daniel Krügler <daniel.kruegler@googlemail.com> - 2013-08-31 23:52 -0700
  Re: Is a union a kind of class? James Kuyper <jameskuyper@verizon.net> - 2013-08-31 23:52 -0700
  Re: Is a union a kind of class? johnolithicsoftware@googlemail.com - 2013-12-19 11:24 -0800
    Re: Is a union a kind of class? "news" <news@fx21.iad.highwinds-media.com> - 2013-12-22 19:27 -0600
      Re: Is a union a kind of class? James Kuyper <jameskuyper@verizon.net> - 2013-12-27 13:11 -0600
        Re: Is a union a kind of class? evansl <cppljevans@googlemail.com> - 2013-12-29 23:00 -0600
          Re: Is a union a kind of class? James Kuyper <jameskuyper@verizon.net> - 2013-12-31 17:45 -0600

csiph-web