On 23 May 2017 at 08:51, Kjell Ahlstedt <[email protected]> wrote:

> Den 2017-05-13 kl. 10:04, skrev Kjell Ahlstedt:
>
> Yet another suggestion in https://bugzilla.gnome.org/
> show_bug.cgi?id=86864#c43
>
> Can we decide what to do with the few enums that we want to be implicitly
> convertible to int? My suggestion in https://bugzilla.gnome.org/
> show_bug.cgi?id=86864#c43 is
>
>   class ResponseType_Enum final
>   {
>   public:
>     enum ResponseType
>     {
>       NONE = -1,
>       REJECT = -2,
>       ACCEPT = -3,
>       ...
>     };
>     ResponseType_Enum() = delete;
>   };
>   using ResponseType = ResponseType_Enum::ResponseType;
>
> I tried to make a mixture of a plain (old-style) enum and an enum class.
> It shall be implicitly convertible to int, and its enumerators shall be
> scoped. In other respects it shall be possible to use it as if it's an
> enum, e.g.
>
>   ResponseType r = ResponseType::REJECT;
>   int i = r;
> but not
>   r = REJECT;
>   i = REJECT;
> and preferably not
>   r = i;
>
> Daniel has remarked that _Enum is not a good suffix for a class name. I
> agree. Can you think of a better suffix? I don't want to call the class
> *ResponseType*. That would clash with *using ResponseType = ...*. If it
> shall be possible to use *ResponseType* as if it's the name of an enum,
> it must be the name of an enum or an alias for a name of an enum. Or are
> there other possibilities that are not too complicated?
>

Would Response::Type work?

struct Response final
{
  enum Type { ... };
  Response() = delete;
};

void foo(Response::Type = Response::REJECT);
_______________________________________________
gtkmm-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/gtkmm-list

Reply via email to