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


Groups > comp.lang.c++ > #8956

Re: maximum cases in a switch ?

From Leo Equinox Gaspard <ekinox1995@gmail.com>
Newsgroups comp.lang.c++
Subject Re: maximum cases in a switch ?
Date 2011-08-17 00:18 +0200
Organization A noiseless patient Spider
Message-ID <j2eq99$7jo$2@dont-email.me> (permalink)
References (5 earlier) <Xns9F3E59BF6EBC4jgreerdoubletakecom@88.198.244.100> <j20tlv$una$1@dont-email.me> <Xns9F3F635C0B26Ajgreerdoubletakecom@88.198.244.100> <j23ilq$3ro$1@dont-email.me> <Xns9F3FA69F387ADjgreerdoubletakecom@88.198.244.100>

Show all headers | View raw


Le 12/08/2011 22:22, Joe Greer a écrit :
> Lynn McGuire<lmc@winsim.com>  wrote in news:j23ilq$3ro$1@dont-email.me:
>
>
>> What is POD ?  The data descriptors live the lifetime of
>> the app and are built at compile time to save runtime.
>> "Performance is a Feature" applies to all software:
>>      http://www.codinghorror.com/blog/2011/06/performance-is-a-feature.h
>>      tml
>>
>> I gained 100X in speed when I converted my app from
>> smalltalk to C++ and do not intend to give it back over
>> some language semantics.  Besides that, the data descriptors
>> are contained in almost 100 classes (this particular class
>> is the biggest at 525) and changing this code would be
>> un-needful.
>>
>> Please note that I got my original question answered and
>> I really appreciate that.  It means that my current data
>> storage descriptor design is extensible and that meets my
>> needs for now.
>>
>> Thanks,
>> Lynn
>>
>
> POD = Plain Old Data  i.e. a struct or class with no special behavior in
> the case.
>
> Only you know what your app needs to do.  I am just exploring
> possibilities that you can either use or reject as suits your needs.
>
> joe

I already answered, but it looks like there had been a misunderstanding, so,
in order to be nice, I will re-post with removing the useless parts.

AFAIK a POD may have special behavior.

I just checked the latest free paper about C++0x, and I saw this.

(9.10)
A POD struct is a class that is both a trivial class and a standard-layout
class, and has no non-static data members of type non-POD struct, non-POD
union (or arrays of such types). Similarly, a POD union is a union that is
both a trivial class and a standard layout class, and has no non-static
data members of type non-POD struct, non-POD union (or arrays of such
types). A POD class is a class that is either a POD struct or a POD union.

So, as we are speaking of POD classes, we need :
- trivial
- standard-layout
- no non-static data members that are non-POD

Now, trivial classes.

(9.6)
A trivial class is a class that has a trivial default constructor (12.1)
and is trivially copyable.
[Note: In particular, a trivially copyable class does not have virtual
functions or virtual base classes. - end note]

So, we need :
- trivial default constructor
- trivially copyable
- no virtual functions
- no virtual base classes
- standard-layout
- no non-static data members that are non-POD

Now, trivially copyable.

(9.6)
A trivially copyable class is a class that:
- has no non-trivial copy constructors (12.8),
- has no non-trivial move constructors (12.8),
- has no non-trivial copy assignment operators (13.5.3, 12.8),
- has no non-trivial move assignment operators (13.5.3, 12.8),
- has a trivial destructor (12.4).

So, we need :
- trivial default, copy and move constructors
- trivial copy and move assignment operators
- trivial destructor
- no virtual functions, base classes
- standard-layout
- no non-static data members that are non-POD

Now, standard-layout.

(9.7)
A standard-layout class is a class that:
- has no non-static data members of type non-standard-layout class
   (or arrays of such types) or reference,
- has no virtual functions (10.3) and no virtual base classes (10.1),
- has the same access control (Clause 11) for all non-static data
   members,
- has no non-standard-layout base classes,
- either has no non-static data members in the most derived class and
   at most one base class with non-static data members, or has no base
   class with non-static data members, and
- has no base classes of the same type as the first non-static data
   member.

So, we need :
- trivial default, copy and move constructors
- trivial copy and move assignment operators
- trivial destructor
- no virtual functions, base classes
- no non-static data members that are not standard-layout
- no virtual functions, base classes
- only one access control for all non-static data members
- no non-standard-layout base classes
- only one class in the hierarchy that has non-static data members
- no base classes of the same type as the first non-static data member
- no non-static data members that are non-POD

Restrictions 3 and 5 are the same.
Restriction 4 is a subset of restriction 10.

So, we need :
- trivial default, copy and move constructors
- trivial copy and move assignment operators
- trivial destructor
- no virtual functions, base classes
- only one access control for all non-static data members
- no non-standard-layout base classes
- only one class in the hierarchy that has non-static data members
- no base classes of the same type as the first non-static data member
- no non-static data members that are non-POD

So, we can do anything we want with static members and member functions.

Am I mistaking anywhere ?

Cheers & hth,
Leo

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

maximum cases in a switch ? Lynn McGuire <lmc@winsim.com> - 2011-08-09 11:03 -0500
  Re: maximum cases in a switch ? LR <lruss@superlink.net> - 2011-08-09 12:27 -0400
    Re: maximum cases in a switch ? Lynn McGuire <lmc@winsim.com> - 2011-08-09 12:23 -0500
      Re: maximum cases in a switch ? Joe Greer <jgreer@doubletake.com> - 2011-08-10 12:45 +0000
        Re: maximum cases in a switch ? Victor Bazarov <v.bazarov@comcast.invalid> - 2011-08-10 09:09 -0400
          Re: maximum cases in a switch ? Joe Greer <jgreer@doubletake.com> - 2011-08-11 12:49 +0000
            Re: maximum cases in a switch ? Lynn McGuire <lmc@winsim.com> - 2011-08-11 10:48 -0500
              Re: maximum cases in a switch ? Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2011-08-11 18:26 +0200
                Re: maximum cases in a switch ? Lynn McGuire <lmc@winsim.com> - 2011-08-11 11:45 -0500
                Re: maximum cases in a switch ? Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2011-08-11 20:06 +0200
                Re: maximum cases in a switch ? Lynn McGuire <lmc@winsim.com> - 2011-08-11 14:47 -0500
                Re: maximum cases in a switch ? Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2011-08-11 22:32 +0200
                Re: maximum cases in a switch ? gwowen <gwowen@gmail.com> - 2011-08-12 06:00 -0700
                Re: maximum cases in a switch ? Lynn McGuire <lmc@winsim.com> - 2011-08-12 10:49 -0500
              Re: maximum cases in a switch ? Joe Greer <jgreer@doubletake.com> - 2011-08-12 13:46 +0000
                Re: maximum cases in a switch ? Lynn McGuire <lmc@winsim.com> - 2011-08-12 10:58 -0500
                Re: maximum cases in a switch ? Joe Greer <jgreer@doubletake.com> - 2011-08-12 20:22 +0000
                Re: maximum cases in a switch ? Lynn McGuire <lmc@winsim.com> - 2011-08-12 15:57 -0500
                Re: maximum cases in a switch ? Leo Equinox Gaspard <ekinox1995@gmail.com> - 2011-08-13 20:58 +0200
                Re: maximum cases in a switch ? Victor Bazarov <v.bazarov@comcast.invalid> - 2011-08-13 18:16 -0400
                Re: maximum cases in a switch ? Leo Equinox Gaspard <ekinox1995@gmail.com> - 2011-08-16 07:55 +0200
                Re: maximum cases in a switch ? Victor Bazarov <v.bazarov@comcast.invalid> - 2011-08-16 09:04 -0400
                Re: maximum cases in a switch ? Leo Equinox Gaspard <ekinox1995@gmail.com> - 2011-08-17 00:11 +0200
                Re: maximum cases in a switch ? Ian Collins <ian-news@hotmail.com> - 2011-08-17 10:24 +1200
                Re: maximum cases in a switch ? Leo Equinox Gaspard <ekinox1995@gmail.com> - 2011-08-17 01:33 +0200
                Re: maximum cases in a switch ? Leo Equinox Gaspard <ekinox1995@gmail.com> - 2011-08-17 00:18 +0200
                Re: maximum cases in a switch ? Ian Collins <ian-news@hotmail.com> - 2011-08-17 10:29 +1200
                Re: maximum cases in a switch ? Leo Equinox Gaspard <ekinox1995@gmail.com> - 2011-08-17 01:37 +0200
                Re: maximum cases in a switch ? Ian Collins <ian-news@hotmail.com> - 2011-08-17 12:02 +1200
  Re: maximum cases in a switch ? Juha Nieminen <nospam@thanks.invalid> - 2011-08-09 16:38 +0000
  Re: maximum cases in a switch ? Victor Bazarov <v.bazarov@comcast.invalid> - 2011-08-09 15:42 -0400
    Re: maximum cases in a switch ? Lynn McGuire <lmc@winsim.com> - 2011-08-09 15:39 -0500
      Re: maximum cases in a switch ? Leo Equinox Gaspard <ekinox1995@gmail.com> - 2011-08-09 23:39 +0200
        Re: maximum cases in a switch ? Lynn McGuire <lmc@winsim.com> - 2011-08-09 17:18 -0500
      Re: maximum cases in a switch ? Victor Bazarov <v.bazarov@comcast.invalid> - 2011-08-09 20:06 -0400
        Re: maximum cases in a switch ? Juha Nieminen <nospam@thanks.invalid> - 2011-08-10 06:54 +0000
          Re: maximum cases in a switch ? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-08-10 12:20 +0000
            Re: maximum cases in a switch ? Lynn McGuire <lmc@winsim.com> - 2011-08-10 11:34 -0500
              Re: maximum cases in a switch ? Paul Brettschneider <paul.brettschneider@yahoo.fr> - 2011-08-10 20:34 +0200
                Re: maximum cases in a switch ? Paul Brettschneider <paul.brettschneider@yahoo.fr> - 2011-08-10 21:06 +0200
              Re: maximum cases in a switch ? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-08-11 21:00 +0000
      Re: maximum cases in a switch ? Marcel Müller <news.5.maazl@spamgourmet.com> - 2011-08-10 11:10 +0200
        Re: maximum cases in a switch ? Juha Nieminen <nospam@thanks.invalid> - 2011-08-10 10:40 +0000
          Re: maximum cases in a switch ? Victor Bazarov <v.bazarov@comcast.invalid> - 2011-08-10 09:02 -0400
            Re: maximum cases in a switch ? Juha Nieminen <nospam@thanks.invalid> - 2011-08-11 08:05 +0000
          Re: maximum cases in a switch ? Marcel Müller <news.5.maazl@spamgourmet.com> - 2011-08-10 21:17 +0200
        Re: maximum cases in a switch ? Lynn McGuire <lmc@winsim.com> - 2011-08-10 11:12 -0500
          Re: maximum cases in a switch ? "Paul" <pchristor@yahoo.co.uk> - 2011-08-11 11:07 +0100
            Re: maximum cases in a switch ? Leigh Johnston <leigh@i42.co.uk> - 2011-08-13 00:14 +0100
              Re: maximum cases in a switch ? "Paul" <pchristor@yahoo.co.uk> - 2011-08-13 14:54 +0100
                Re: maximum cases in a switch ? Leigh Johnston <leigh@i42.co.uk> - 2011-08-13 15:26 +0100
                Re: maximum cases in a switch ? Juha Nieminen <nospam@thanks.invalid> - 2011-08-14 18:14 +0000
                Re: maximum cases in a switch ? "Paul" <pchristor@yahoo.co.uk> - 2011-08-15 01:09 +0100
                Re: maximum cases in a switch ? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-08-15 02:15 -0700
                Re: maximum cases in a switch ? "Paul" <pchristor@yahoo.co.uk> - 2011-08-15 12:18 +0100
                Re: maximum cases in a switch ? Leigh Johnston <leigh@i42.co.uk> - 2011-08-15 13:22 +0100
                Re: maximum cases in a switch ? "Paul" <pchristor@yahoo.co.uk> - 2011-08-15 13:38 +0100
                Re: maximum cases in a switch ? Leigh Johnston <leigh@i42.co.uk> - 2011-08-15 14:06 +0100
                Re: maximum cases in a switch ? "Paul" <pchristor@yahoo.co.uk> - 2011-08-15 16:05 +0100
                Re: maximum cases in a switch ? Leigh Johnston <leigh@i42.co.uk> - 2011-08-15 16:20 +0100
                Re: maximum cases in a switch ? "Paul" <pchristor@yahoo.co.uk> - 2011-08-15 20:24 +0100
                Re: maximum cases in a switch ? Leigh Johnston <leigh@i42.co.uk> - 2011-08-15 22:09 +0100
                Re: maximum cases in a switch ? Leigh Johnston <leigh@i42.co.uk> - 2011-08-15 22:19 +0100
                Re: maximum cases in a switch ? "Paul" <pchristor@yahoo.co.uk> - 2011-08-16 03:10 +0100
                Re: maximum cases in a switch ? Leigh Johnston <leigh@i42.co.uk> - 2011-08-16 13:08 +0100
                Re: maximum cases in a switch ? "Paul" <pchristor@yahoo.co.uk> - 2011-08-16 14:01 +0100
                Re: maximum cases in a switch ? Leigh Johnston <leigh@i42.co.uk> - 2011-08-16 14:10 +0100
                Re: maximum cases in a switch ? "Paul" <pchristor@yahoo.co.uk> - 2011-08-16 03:07 +0100
                Re: maximum cases in a switch ? Leigh Johnston <leigh@i42.co.uk> - 2011-08-16 13:05 +0100
                Re: maximum cases in a switch ? "Paul" <pchristor@yahoo.co.uk> - 2011-08-16 13:57 +0100
                Re: maximum cases in a switch ? Leigh Johnston <leigh@i42.co.uk> - 2011-08-16 14:07 +0100
                Re: maximum cases in a switch ? "Paul" <pchristor@yahoo.co.uk> - 2011-08-16 19:29 +0100
                Re: maximum cases in a switch ? Leigh Johnston <leigh@i42.co.uk> - 2011-08-16 19:35 +0100
                Re: maximum cases in a switch ? "Paul" <pchristor@yahoo.co.uk> - 2011-08-17 00:01 +0100
                Re: maximum cases in a switch ? Leigh Johnston <leigh@i42.co.uk> - 2011-08-17 00:11 +0100
                Re: maximum cases in a switch ? "Paul" <pchristor@yahoo.co.uk> - 2011-08-17 01:23 +0100
                Re: maximum cases in a switch ? Juha Nieminen <nospam@thanks.invalid> - 2011-08-15 13:32 +0000
                Re: maximum cases in a switch ? "Paul" <pchristor@yahoo.co.uk> - 2011-08-15 15:20 +0100
                Re: maximum cases in a switch ? Leigh Johnston <leigh@i42.co.uk> - 2011-08-15 15:33 +0100
                Re: maximum cases in a switch ? Juha Nieminen <nospam@thanks.invalid> - 2011-08-16 07:34 +0000
                Re: maximum cases in a switch ? "Paul" <pchristor@yahoo.co.uk> - 2011-08-16 13:49 +0100
                Re: maximum cases in a switch ? Juha Nieminen <nospam@thanks.invalid> - 2011-08-16 15:02 +0000
                Re: maximum cases in a switch ? Leigh Johnston <leigh@i42.co.uk> - 2011-08-16 16:07 +0100
                Re: maximum cases in a switch ? "Paul" <pchristor@yahoo.co.uk> - 2011-08-16 19:50 +0100
                Re: maximum cases in a switch ? Leigh Johnston <leigh@i42.co.uk> - 2011-08-16 19:57 +0100
                Re: maximum cases in a switch ? "Paul" <pchristor@yahoo.co.uk> - 2011-08-17 00:12 +0100
                Re: maximum cases in a switch ? "Paul" <pchristor@yahoo.co.uk> - 2011-08-16 19:34 +0100
                Re: maximum cases in a switch ? Juha Nieminen <nospam@thanks.invalid> - 2011-08-17 12:55 +0000
                Re: maximum cases in a switch ? "Paul" <pchristor@yahoo.co.uk> - 2011-08-17 14:32 +0100
                Re: maximum cases in a switch ? Juha Nieminen <nospam@thanks.invalid> - 2011-08-17 20:11 +0000
                Re: maximum cases in a switch ? "Paul" <pchristor@yahoo.co.uk> - 2011-08-18 11:00 +0100
                Re: maximum cases in a switch ? Joshua Maurice <joshuamaurice@gmail.com> - 2011-08-15 15:35 -0700
                Re: maximum cases in a switch ? Gareth Owen <gwowen@gmail.com> - 2011-08-17 06:34 +0100
                Re: maximum cases in a switch ? "Paul" <pchristor@yahoo.co.uk> - 2011-08-17 12:23 +0100
                Re: maximum cases in a switch ? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-08-17 02:01 -0700
                Re: maximum cases in a switch ? "Paul" <pchristor@yahoo.co.uk> - 2011-08-17 12:29 +0100
                Re: maximum cases in a switch ? Leigh Johnston <leigh@i42.co.uk> - 2011-08-17 14:13 +0100
                Re: maximum cases in a switch ? "Paul" <pchristor@yahoo.co.uk> - 2011-08-17 14:18 +0100
                Re: maximum cases in a switch ? Leigh Johnston <leigh@i42.co.uk> - 2011-08-17 14:43 +0100
                Re: maximum cases in a switch ? "Paul" <pchristor@yahoo.co.uk> - 2011-08-17 15:23 +0100
                Re: maximum cases in a switch ? Leigh Johnston <leigh@i42.co.uk> - 2011-08-17 15:31 +0100
                Re: maximum cases in a switch ? "Paul" <pchristor@yahoo.co.uk> - 2011-08-17 15:48 +0100
                Re: maximum cases in a switch ? Leigh Johnston <leigh@i42.co.uk> - 2011-08-17 15:53 +0100
                Re: maximum cases in a switch ? SG <s.gesemann@gmail.com> - 2011-08-17 07:54 -0700
                Re: maximum cases in a switch ? "Paul" <pchristor@yahoo.co.uk> - 2011-08-17 20:40 +0100
                Re: maximum cases in a switch ? Larry Evans <cppljevans@suddenlink.net> - 2011-08-17 10:54 -0500
                Re: maximum cases in a switch ? Robert Wessel <robertwessel2@yahoo.com> - 2011-08-17 12:44 -0500
                jump table vs. vector of function pointers(was Re: maximum cases in a switch ? Larry Evans <cppljevans@suddenlink.net> - 2011-08-17 15:18 -0500
                Re: jump table vs. vector of function pointers(was Re: maximum cases in a switch ? Alain Ketterlin <alain@dpt-info.u-strasbg.fr> - 2011-08-17 22:48 +0200
                Re: jump table vs. vector of function pointers(was Re: maximum cases in a switch ? Larry Evans <cppljevans@suddenlink.net> - 2011-08-17 16:49 -0500
                Re: maximum cases in a switch ? Thomas David Rivers <rivers@dignus.com> - 2011-08-17 13:50 -0400
                Re: maximum cases in a switch ? "Paul" <pchristor@yahoo.co.uk> - 2011-08-17 22:04 +0100
                Re: maximum cases in a switch ? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-08-22 03:23 -0700
    Re: maximum cases in a switch ? Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-08-12 05:51 -0700
      Re: maximum cases in a switch ? Victor Bazarov <v.bazarov@comcast.invalid> - 2011-08-13 08:45 -0400
    Re: maximum cases in a switch ? James Kanze <james.kanze@gmail.com> - 2011-08-21 16:55 -0700
      Re: maximum cases in a switch ? Robert Wessel <robertwessel2@yahoo.com> - 2011-08-21 23:22 -0500
        Re: maximum cases in a switch ? Victor Bazarov <v.bazarov@comcast.invalid> - 2011-08-22 08:14 -0400
        Re: maximum cases in a switch ? James Kanze <james.kanze@gmail.com> - 2011-08-22 10:56 -0700

csiph-web