220 12557 <edfe1568-f21e-4acc-9251-575ef95b1f1a@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Matthew Fioravante <fmatthew5876@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: templating qualifiers
Date: Wed, 27 Aug 2014 18:08:15 -0700 (PDT)
Lines: 88
Approved: news@gmane.org
Message-ID: <edfe1568-f21e-4acc-9251-575ef95b1f1a@isocpp.org>
References: <33b97ad6-ade7-4790-8bd4-fb3e79394423@isocpp.org>
 <94181180-9B85-4D12-8A11-2A5CF8D0616C@gmail.com>
 <CAFdMc-1rijiwWj54PXJ+PYxKj=kuKk4Lycd=j11m8xU8p93BXw@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_22_202570427.1409188095404"
X-Trace: ger.gmane.org 1409188104 26746 80.91.229.3 (28 Aug 2014 01:08:24 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 28 Aug 2014 01:08:24 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDELF54RTIGRB74B7KPQKGQENTHILKQ@isocpp.org Thu Aug 28 03:08:18 2014
Return-path: <std-proposals+bncBDELF54RTIGRB74B7KPQKGQENTHILKQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yk0-f197.google.com ([209.85.160.197])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDELF54RTIGRB74B7KPQKGQENTHILKQ@isocpp.org>)
	id 1XMoCH-0007lE-5y
	for gclcip-std-proposals@m.gmane.org; Thu, 28 Aug 2014 03:08:17 +0200
Original-Received: by mail-yk0-f197.google.com with SMTP id 142sf3010465ykq.8
        for <gclcip-std-proposals@m.gmane.org>; Wed, 27 Aug 2014 18:08:16 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe
         :content-type;
        bh=Q7ARQn/7jbkWBCdt54ktBR8WQrLy64Ze23iSaKhXN64=;
        b=UMVbbUw7Vyw3/wzFUMhoWIKtgYfauvDFwM1IL/gsdZkbboDLcXdkbV+NcQQxfUkpjM
         wETsuz7qqKxkOdoLXrLJcpHuUtXOJ8m1ykzLOra4S6wPLPQ9Zqcw2Rap96v70N1/m4d0
         uQeTAVSUwvEt+QMkm17zgSYvD7dmqyJeTVmi6U/BV5dS5FLyhDoQaV/HhIT+cpckoJJA
         Y88aUe2ACwR7U7CNMC22dE6qj6xB02uRlGnBM1KPJG6WsH3+jW9dG0yheIb/80mDCEsc
         +Rh09da1BxQyKgoOhsBqbGdBsFC97zkJLf4Y+S2IK3iEA2GLmrJ7b+ntzOttQXIg6guZ
         /NOg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=Q7ARQn/7jbkWBCdt54ktBR8WQrLy64Ze23iSaKhXN64=;
        b=B8u6nF53TWOkI+TNdxAbQRLkWiHD2N+rUIZ/PxobHm8SqMCQ8gQOLkwj1iPwbz0GpD
         LDpSMhIYi7kFNNjC7XapZQEffC0z0pCUQQCCGVT5kBXN1+wFWNaeQCMytxFWupG5LkZX
         TagXwCGdsjs7mFcqwUBIko1Y0WmYDsUkNSC7rPEBzJyJb3noWVjm/7fxInGcGciIy72M
         xbWU2KVw2IQdfbGULXlHy66/jAkM4kIxF2zQWTCXpieBeVGwIY5168pDH/XXcF9mVT8P
         aksoked3yugHIl43oWuoBwLPqI7VL3UHDMkI7mx0EszFtaeMb+GItm/4atOou+HuMAYM
         k9RA==
X-Gm-Message-State: ALoCoQmdbKZtuPNYBziA13V56TZ2O2JIr3bDdRJsAOzulnuBpQmErEKwXRbXMDveex383yBvs/B9
X-Received: by 10.236.17.234 with SMTP id j70mr461545yhj.26.1409188096371;
        Wed, 27 Aug 2014 18:08:16 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.93.228 with SMTP id d91ls413572qge.41.gmail; Wed, 27 Aug
 2014 18:08:15 -0700 (PDT)
X-Received: by 10.140.30.201 with SMTP id d67mr7772qgd.8.1409188095748;
        Wed, 27 Aug 2014 18:08:15 -0700 (PDT)
In-Reply-To: <CAFdMc-1rijiwWj54PXJ+PYxKj=kuKk4Lycd=j11m8xU8p93BXw@mail.gmail.com>
X-Original-Sender: fmatthew5876@gmail.com
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: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:12557
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/12557>

------=_Part_22_202570427.1409188095404
Content-Type: text/plain; charset=UTF-8



On Wednesday, August 27, 2014 2:48:34 PM UTC-4, dgutson wrote:
>
>
> Not sure if it applies to this: how would this example be implemented? 
>
> struct S 
> { 
>     int x; 
>
>     int& getX() { return x; } 
>     int getX() const { return x; } 
> }; 
>
> when the body is the same, how could this help to write the method only 
> once? 
>
>
I'm not sure that would be possible. Maybe with some ugly template 
conditionals.

Something like

template <>
typename 
std::conditional<std::is_const<decltype(this)>::value,int,int&>::type 
getX() $c { return x; }

But in my opinion that's more ugly and unreadable than the 2 separate 
overloads.

-- 

--- 
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 email 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-proposals/.

------=_Part_22_202570427.1409188095404
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Wednesday, August 27, 2014 2:48:34 PM UTC-4, dg=
utson wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-lef=
t: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><br>Not sure if it=
 applies to this: how would this example be implemented?
<br>
<br>struct S
<br>{
<br>&nbsp; &nbsp; int x;
<br>
<br>&nbsp; &nbsp; int&amp; getX() { return x; }
<br>&nbsp; &nbsp; int getX() const { return x; }
<br>};
<br>
<br>when the body is the same, how could this help to write the method only=
 once?
<br><br></blockquote><div><br></div><div>I'm not sure that would be possibl=
e. Maybe with some ugly template conditionals.</div><div><br></div><div>Som=
ething like</div><div><br></div><div>template &lt;&gt;</div><div>typename s=
td::conditional&lt;std::is_const&lt;decltype(this)&gt;::value,int,int&amp;&=
gt;::type getX() $c { return x; }</div><div><br></div><div>But in my opinio=
n that's more ugly and unreadable than the 2 separate overloads.</div></div=
>

<p></p>

-- <br />
<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 <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<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 />

------=_Part_22_202570427.1409188095404--

.
