220 5319 <03a23bfd-10ab-40db-a7f9-3cbd177a2d52@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: =?UTF-8?Q?Micha=C5=82_Dominiak?= <griwes@griwes.info>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Allowing any integral type as an argument for
 user defined literal operators
Date: Sat, 6 Jul 2013 14:15:48 -0700 (PDT)
Lines: 133
Approved: news@gmane.org
Message-ID: <03a23bfd-10ab-40db-a7f9-3cbd177a2d52@isocpp.org>
References: <80016e3a-2dc8-4887-b59b-a8aff20439e0@isocpp.org>
 <CAFk2RUaUCRdjxrpZ+JRRsa+gWwUH0yWCcNSkTFLyWpLo2-ukag@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_3275_1565986.1373145348862"
X-Trace: ger.gmane.org 1373145352 25868 80.91.229.3 (6 Jul 2013 21:15:52 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sat, 6 Jul 2013 21:15:52 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCLPTLXGRAFRBBMS4KHAKGQE3EUXQGA@isocpp.org Sat Jul 06 23:15:54 2013
Return-path: <std-proposals+bncBCLPTLXGRAFRBBMS4KHAKGQE3EUXQGA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vc0-f199.google.com ([209.85.220.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCLPTLXGRAFRBBMS4KHAKGQE3EUXQGA@isocpp.org>)
	id 1UvZpe-0005cm-W2
	for gclcip-std-proposals@m.gmane.org; Sat, 06 Jul 2013 23:15:51 +0200
Original-Received: by mail-vc0-f199.google.com with SMTP id gf11sf4002149vcb.6
        for <gclcip-std-proposals@m.gmane.org>; Sat, 06 Jul 2013 14:15:49 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=x-beenthere:date:from:to:message-id:in-reply-to:references:subject
         :mime-version:x-original-sender:reply-to:precedence:mailing-list
         :list-id:x-google-group-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=biZkiiJpw1I3EnKpxZ6Ui8iuWOVaQwSJm4e0V9GK/mU=;
        b=LtThFPIAaNx44UArZrXArgWJOu+5Gm07O+OWU8rf7KjFEkmH5JGvsar8p/6EUzcsGc
         bN1+iFW+Amet2dBEqbgq8xFAPayCKJ7S0VzOVHBT79TZfVWHID/mpV9Yh0soMWkmGrHH
         D/i+VZPdRreU005LqKfnqSHNk6HXze22Yu11jzPcPqSgifTBmeBdg+jgNX/juuEna27h
         rRjSOjzhmIXsuWclhg6nhvYB0foZKLP6LUChGHiTLANznnNnZwTQmNWoZxqWFBWsTYA9
         CV83vI/ljtF4hDHVElXUtfyz5+G+7LEKOWijyhJWaofNJkuioIEgokKT2aJbthop6DRA
         1i9Q==
X-Received: by 10.224.55.200 with SMTP id v8mr18192548qag.7.1373145349784;
        Sat, 06 Jul 2013 14:15:49 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.49.12.169 with SMTP id z9ls1463233qeb.20.gmail; Sat, 06 Jul
 2013 14:15:49 -0700 (PDT)
X-Received: by 10.49.62.3 with SMTP id u3mr353818qer.26.1373145349196;
        Sat, 06 Jul 2013 14:15:49 -0700 (PDT)
In-Reply-To: <CAFk2RUaUCRdjxrpZ+JRRsa+gWwUH0yWCcNSkTFLyWpLo2-ukag@mail.gmail.com>
X-Original-Sender: griwes@griwes.info
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:5319
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/5319>

------=_Part_3275_1565986.1373145348862
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable



On Saturday, 6 July 2013 23:02:04 UTC+2, Ville Voutilainen wrote:
>
>
>
>
> On 6 July 2013 23:26, Micha=C5=82 Dominiak <gri...@griwes.info <javascrip=
t:>>wrote:
>
>> Today I came across a very silly issue: you cannot do `uint64_t=20
>> operator""_foo(uint64_t)`, because `uint64_t` is a typedef for `unsigned=
=20
>> long`, not `unsigned long long` on both Clang and GCC on Linux (despite =
the=20
>> fact that `sizeof(unsigned long) =3D=3D sizeof(unsigned long long)`). Yo=
u have=20
>> to type the long type name, just because the typedef isn't for the exact=
=20
>> type required by the standard. I hope we all agree this is a silly=20
>> situation.
>>
>> So, I'd like to propose allowing `operator""`s to take arguments of any=
=20
>> integral types.
>>
>
> It's not supposed to take any integral types. The operator takes an=20
> unsigned type because any negation
> happens outside it. Since we already have such a restriction for the type=
=20
> a literal operator accepts, it's
> not a far stretch to have a further limitation. I wouldn't mind it=20
> accepting any unsigned integral type,
> but I don't see it a big deal that you have to have a certain signature=
=20
> for a literal operator.
>

Ok, s/any/any unsigned/.=20
=20

> Not allowing multiple kinds of integral types as literal operator=20
> parameters also avoid having
> to deal with overload resolution for the literal operators, and not=20
> allowing narrow types avoids
> having to deal with narrowing conversions.
>
=20
No-one says allowing any unsigned argument type would allow overloading (I=
=20
think it would be a counter-feature, really). And since you know all the=20
values passed to the operator at compile time, no narrowing would ever=20
happen - just slap the user with an error about the value being to big for=
=20
given type.

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.



------=_Part_3275_1565986.1373145348862
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<br><br>On Saturday, 6 July 2013 23:02:04 UTC+2, Ville Voutilainen  wrote:<=
blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bord=
er-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><br><div><br><=
br><div class=3D"gmail_quote">On 6 July 2013 23:26, Micha=C5=82 Dominiak <s=
pan dir=3D"ltr">&lt;<a href=3D"javascript:" target=3D"_blank" gdf-obfuscate=
d-mailto=3D"rcRsle36NrQJ">gri...@griwes.info</a>&gt;</span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">Today I came across a very silly issue: you =
cannot do `uint64_t operator""_foo(uint64_t)`, because `uint64_t` is a type=
def for `unsigned long`, not `unsigned long long` on both Clang and GCC on =
Linux (despite the fact that `sizeof(unsigned long) =3D=3D sizeof(unsigned =
long long)`). You have to type the long type name, just because the typedef=
 isn't for the exact type required by the standard. I hope we all agree thi=
s is a silly situation.<div>
<br></div><div>So, I'd like to propose allowing `operator""`s to take argum=
ents of any integral types.</div></blockquote><div><br></div><div>It's not =
supposed to take any integral types. The operator takes an unsigned type be=
cause any negation<br>
</div><div>happens outside it. Since we already have such a restriction for=
 the type a literal operator accepts, it's<br>not a far stretch to have a f=
urther limitation. I wouldn't mind it accepting any unsigned integral type,=
<br>
but I don't see it a big deal that you have to have a certain signature for=
 a literal operator.<br></div></div></div></div></blockquote><div><br></div=
><div>Ok, s/any/any unsigned/.&nbsp;</div><div>&nbsp;</div><blockquote clas=
s=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #c=
cc solid;padding-left: 1ex;"><div dir=3D"ltr"><div><div class=3D"gmail_quot=
e"><div></div><div>Not allowing multiple kinds of integral types as literal=
 operator parameters also avoid having<br></div>
<div>to deal with overload resolution for the literal operators, and not al=
lowing narrow types avoids<br>having to deal with narrowing conversions.<br=
></div></div></div></div></blockquote><div>&nbsp;<br></div><div>No-one says=
 allowing any unsigned argument type would allow overloading (I think it wo=
uld be a counter-feature, really). And since you know all the values passed=
 to the operator at compile time, no narrowing would ever happen - just sla=
p the user with an error about the value being to big for given type.</div>

<p></p>

-- <br />
&nbsp;<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_3275_1565986.1373145348862--

.
