C++ Logo

std-proposals

Advanced search

Re: User-defined conversion for strongly

From: David Ledger <DavidLedger_at_[hidden]>
Date: Tue, 7 Apr 2020 00:18:35 +0000
I like the idea of supporting member functions with C++.
Would meta-classes allow this functionality with an enum-like object?

-----Original Message-----
From: Std-Proposals <std-proposals-bounces_at_[hidden]> On Behalf Of std-proposals-request_at_[hidden]
Sent: 7 April 2020 12:59 AM
To: std-proposals_at_[hidden]
Subject: Std-Proposals Digest, Vol 13, Issue 2

Send Std-Proposals mailing list submissions to
        std-proposals_at_[hidden]

To subscribe or unsubscribe via the World Wide Web, visit
        https://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.isocpp.org%2Fmailman%2Flistinfo.cgi%2Fstd-proposals&amp;data=02%7C01%7C%7C623a67fd43154889187108d7da3aad83%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637217817860600116&amp;sdata=Ffa7BapqxpP81LqJ5NcCfpfmp6cuMwz7KjzA2tMPxsM%3D&amp;reserved=0
or, via email, send a message with subject or body 'help' to
        std-proposals-request_at_[hidden]

You can reach the person managing the list at
        std-proposals-owner_at_[hidden]

When replying, please edit your Subject line so it is more specific than "Re: Contents of Std-Proposals digest..."


Today's Topics:

   1. Re: User-defined conversion for strongly typed enums (Zhihao Yuan)
   2. Re: User-defined conversion for strongly typed enums
      (Micha? Policht)
   3. Re: User-defined conversion for strongly typed enums
      (Przemek Kozio?)
   4. Re: User-defined conversion for strongly typed enums
      (Micha? Policht)
   5. Re: User-defined conversion for strongly typed enums
      (Michael Hava)


----------------------------------------------------------------------

Message: 1
Date: Mon, 06 Apr 2020 03:02:59 +0000
From: Zhihao Yuan <zy_at_[hidden]>
To: "std-proposals_at_[hidden]" <std-proposals_at_[hidden]>
Subject: Re: [std-proposals] User-defined conversion for strongly
        typed enums
Message-ID:
        <0XRDJWL_7uME-fJDz3WWg9WOf7ppuflE8zbVJtmOP3t5CFi8Bn6ZoFS7KagajpfjWYXoKtxQNmyKAlh>
        
Content-Type: text/plain; charset="utf-8"

On Saturday, April 4, 2020 3:17 PM, Przemek Kozio? via Std-Proposals <std-proposals_at_[hidden]> wrote:

> Strongly typed enums provide type safety.
>
> I believe, however, the programmer should have an option to define explicit conversions to the desired types.

I believe enum class should support
member functions.

--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
_______________________________________________
-------------- next part --------------
HTML attachment scrubbed and removed
------------------------------
Message: 2
Date: Mon, 6 Apr 2020 14:23:37 +0200
From: Micha? Policht <michal_at_[hidden]>
To: std-proposals_at_[hidden]
Subject: Re: [std-proposals] User-defined conversion for strongly
	typed enums
Message-ID: <8ce37859-7b78-3eaf-8bb1-d34ff189414a_at_[hidden]>
Content-Type: text/plain; charset=utf-8
> class X {
> public:
> ? ? struct ID {
> ? ? ? ? enum {
> ? ? ? ? ? ? NAME = 0x0,
> ? ? ? ? ? ? SIZE = 0x2,
> ? ? ? ? };
> ? ? };
> 
An what's wrong with the above? I'd rather go in that direction and try to unify all C++ constructs instead of introducing enum-specific syntax.
Regards,
Micha?
------------------------------
Message: 3
Date: Mon, 6 Apr 2020 14:29:45 +0200
From: Przemek Kozio? <przemkoz85_at_[hidden]>
To: std-proposals_at_[hidden]
Subject: Re: [std-proposals] User-defined conversion for strongly
	typed enums
Message-ID:
	<CAALK0dSYBE5Q+_NJ9dfdEdAgvKxTPEFNMSgM-20Gn3Py4U7KTA_at_[hidden]>
Content-Type: text/plain; charset="utf-8"
I think the main purpose of a struct is not name scoping.
On Mon, Apr 6, 2020 at 2:23 PM Micha? Policht via Std-Proposals < std-proposals_at_[hidden]> wrote:
>
> > class X {
> > public:
> >     struct ID {
> >         enum {
> >             NAME = 0x0,
> >             SIZE = 0x2,
> >         };
> >     };
> >
>
> An what's wrong with the above? I'd rather go in that direction and 
> try to unify all C++ constructs instead of introducing enum-specific syntax.
>
> Regards,
> Micha?
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flist
> s.isocpp.org%2Fmailman%2Flistinfo.cgi%2Fstd-proposals&amp;data=02%7C01
> %7C%7C623a67fd43154889187108d7da3aad83%7C84df9e7fe9f640afb435aaaaaaaaa
> aaa%7C1%7C0%7C637217817860600116&amp;sdata=Ffa7BapqxpP81LqJ5NcCfpfmp6c
> uMwz7KjzA2tMPxsM%3D&amp;reserved=0
>
-------------- next part --------------
HTML attachment scrubbed and removed
------------------------------
Message: 4
Date: Mon, 6 Apr 2020 14:46:34 +0200
From: Micha? Policht <michal_at_[hidden]>
To: Przemek Kozio? <przemkoz85_at_[hidden]>,
	std-proposals_at_[hidden]
Subject: Re: [std-proposals] User-defined conversion for strongly
	typed enums
Message-ID: <bb42e871-dc38-455d-2d26-c97f4c4be8e0_at_[hidden]>
Content-Type: text/plain; charset=utf-8
> I think the main purpose of a struct is not name scoping. 
It is one of its characteristics.
------------------------------
Message: 5
Date: Mon, 6 Apr 2020 14:55:18 +0000
From: Michael Hava <mfh_at_[hidden]>
To: "std-proposals_at_[hidden]" <std-proposals_at_[hidden]>
Subject: Re: [std-proposals] User-defined conversion for strongly
	typed enums
Message-ID:
	<VI1PR04MB46882760D8C428B6A71E2B42B4C20_at_[hidden]>
	
Content-Type: text/plain; charset="utf-8"
Gotta agree ? is there a rationale why we don?t have those?
From: Std-Proposals <std-proposals-bounces_at_[hidden]> On Behalf Of Zhihao Yuan via Std-Proposals
Sent: Monday, April 6, 2020 5:03 AM
To: std-proposals_at_[hidden]
Cc: Zhihao Yuan <zy_at_[hidden]>
Subject: Re: [std-proposals] User-defined conversion for strongly typed enums
On Saturday, April 4, 2020 3:17 PM, Przemek Kozio? via Std-Proposals <std-proposals_at_[hidden]<mailto:std-proposals_at_[hidden]>> wrote:
Strongly typed enums provide type safety.
I believe, however, the programmer should have an option to define explicit conversions to the desired types.
I believe enum class should support
member functions.
--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
_______________________________________________
-------------- next part --------------
HTML attachment scrubbed and removed
------------------------------
Subject: Digest Footer
Std-Proposals mailing list
Std-Proposals_at_[hidden]
https://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.isocpp.org%2Fmailman%2Flistinfo.cgi%2Fstd-proposals&amp;data=02%7C01%7C%7C623a67fd43154889187108d7da3aad83%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637217817860600116&amp;sdata=Ffa7BapqxpP81LqJ5NcCfpfmp6cuMwz7KjzA2tMPxsM%3D&amp;reserved=0
------------------------------
End of Std-Proposals Digest, Vol 13, Issue 2
********************************************

Received on 2020-04-06 19:21:31