Re: enums that are really just sets of constants



Den 2017-04-19 kl. 12:24, skrev Murray Cumming:
On Wed, 2017-04-19 at 10:30 +0100, Jonathan Wakely wrote:
You can also use a namespace to give them their own scope, which has
less overhead than a class type (no RTTI for the class, no way for
users to create instances of the class type, or pointers to it, which
would have no purpose if it's just being used to create a new scope
for the enumerators).
Good point.

I'm leaning towards this at the moment.
Is it possible to define a namespace within a class?
class A {
public:
  namespace B {
    enum C { .... };
  }
  void f();
  ...
};
If we choose to put the enum or the set of named integer constants in a namespace, must we refrain from putting them inside a class, such as the Gtk::ResponseType enum within the Gtk::Dialog class?
But shouldn't we just avoid old-style enums completely?
Why? Both types still have uses in modern C++. Old doesn't mean bad.


_WRAP_GERROR still generates old-style enums. We would not gain anything by changing that.

Kjell


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]