220 26556 <CAFk2RUaaP4XC9H7d9e1GBDi8JA4F2dSf2i=qB7mqRUXj1Lui5Q@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Ville Voutilainen <ville.voutilainen@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: auto type deduction for *_cast return argument
Date: Tue, 5 Jul 2016 11:08:37 +0300
Lines: 41
Approved: news@gmane.org
Message-ID: <CAFk2RUaaP4XC9H7d9e1GBDi8JA4F2dSf2i=qB7mqRUXj1Lui5Q@mail.gmail.com>
References: <58140e46-2adc-4eac-8f51-72d3685cdf0b@isocpp.org> <7E3409C2-A2AC-4562-BB06-6D5D5ACE8AC8@gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-Trace: ger.gmane.org 1467706132 19116 80.91.229.3 (5 Jul 2016 08:08:52 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 5 Jul 2016 08:08:52 +0000 (UTC)
To: "ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBC5JHI7A7ALRBBWW5W5QKGQEFSBCTZQ@isocpp.org Tue Jul 05 10:08:48 2016
Return-path: <std-proposals+bncBC5JHI7A7ALRBBWW5W5QKGQEFSBCTZQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pf0-f199.google.com ([209.85.192.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBC5JHI7A7ALRBBWW5W5QKGQEFSBCTZQ@isocpp.org>)
	id 1bKLPT-0001Co-6c
	for gclcip-std-proposals@m.gmane.org; Tue, 05 Jul 2016 10:08:47 +0200
Original-Received: by mail-pf0-f199.google.com with SMTP id g62sf434964404pfb.3
        for <gclcip-std-proposals@m.gmane.org>; Tue, 05 Jul 2016 01:08:39 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post
         :list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=SEknLSt60wlhrAKf0wA8Tq1iJcWzLU/C1TRdGnU+Vtw=;
        b=ac7uh7Td7i6AL2psAWC3fzFtymfAyXw9Mr62S8mLtqyLNRazTiuZsL7A7TMcoLyY2V
         8jG2UGP2zfG4ArMVtz3Eddptf8Cw1xqsEdnNYsAm5QQZBZJOmy0RGIwUvNLWsBsLNbP9
         YUhXgqlJRcmnMNYUyffiOTnn7bbGRdPLFWzGicXeltfNmNlHRxExOlHHJa48Y56WY4sL
         TKBR2wHtShBe8NsEgy4X6Lnk2HbwZGczlNZePAOqCUPqu6xRroVA15xNinfsgD0KYmVM
         VlqonJbyanAue/cCheoJx1Jl1VatPpkt3kCLswGzkVQtxoe8sM73U0H+AhEqN7CfTsDL
         PkfA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:in-reply-to:references:from:date
         :message-id:subject:to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=SEknLSt60wlhrAKf0wA8Tq1iJcWzLU/C1TRdGnU+Vtw=;
        b=B2HKSVbGBQZvnBYkOKZ3Ra4BFYwUmoqnyE8REf6+Ypr6Quo9P5RYhi/5ZA+ld9BsOk
         FDR3X+RCNUwtrQzu7tbpfrAtEYCKUjgdw1DI7ZSDg8K1FXS1NN+xv0u3+lZbXOyW63Zm
         RATPwvKrKLrBNQFzAnzAhElIqdhnLvKfeuR9aBDPW+7jm7cfZPdBaksAnWhChG6lL6dE
         peVl0sdnN9VGgMD//N3WDRsNXtouC/LzyvOYO4RTYac41BVfNFVAe1eGiaPXnY/SZtuX
         djl40Y+4sUGZUWqgxW4n9HyJf+9HYRstLdndYSxvpucoXe7vWpDDAE5hxlnsy9+K8QOP
         1dVA==
X-Gm-Message-State: ALyK8tLPji/C7ouMpAVx+DWDzpMYc0Rj4I4na8/hpenBVxmsKUnNEypfRHAjcfuNEx97SQ==
X-Received: by 10.66.7.165 with SMTP id k5mr9277921paa.10.1467706119022;
        Tue, 05 Jul 2016 01:08:39 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.19.205 with SMTP id 74ls1803061iot.6.gmail; Tue, 05 Jul
 2016 01:08:38 -0700 (PDT)
X-Received: by 10.159.54.201 with SMTP id p67mr5625523uap.59.1467706117961;
        Tue, 05 Jul 2016 01:08:37 -0700 (PDT)
Original-Received: from mail-vk0-x230.google.com (mail-vk0-x230.google.com. [2607:f8b0:400c:c05::230])
        by mx.google.com with ESMTPS id q189si2395476vkb.96.2016.07.05.01.08.37
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Tue, 05 Jul 2016 01:08:37 -0700 (PDT)
Received-SPF: pass (google.com: domain of ville.voutilainen@gmail.com designates 2607:f8b0:400c:c05::230 as permitted sender) client-ip=2607:f8b0:400c:c05::230;
Original-Received: by mail-vk0-x230.google.com with SMTP id k68so168652879vkb.0
        for <std-proposals@isocpp.org>; Tue, 05 Jul 2016 01:08:37 -0700 (PDT)
X-Received: by 10.31.85.3 with SMTP id j3mr5345781vkb.130.1467706117558; Tue,
 05 Jul 2016 01:08:37 -0700 (PDT)
Original-Received: by 10.103.64.83 with HTTP; Tue, 5 Jul 2016 01:08:37 -0700 (PDT)
In-Reply-To: <7E3409C2-A2AC-4562-BB06-6D5D5ACE8AC8@gmail.com>
X-Original-Sender: ville.voutilainen@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com;       spf=pass (google.com: domain of
 ville.voutilainen@gmail.com designates 2607:f8b0:400c:c05::230 as permitted
 sender) smtp.mailfrom=ville.voutilainen@gmail.com;       dmarc=pass (p=NONE
 dis=NONE) header.from=gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://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>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:26556
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/26556>

On 5 July 2016 at 10:59, Jonathan Coe <jonathanbcoe@gmail.com> wrote:
> Thanks for suggesting this, I'm afraid I don't think I like this idea.
>
> It saves a bit of typing but would make it less clear what's going on and in
> cases where a function signature changes would change the meaning of
> existing code without any edits being made
>
> f(A a);
>
> Changed to
>
> f(B b);
>
> Would change the meaning of
>
> f(dynamic_cast(x));
>
> In a rather non-obvious way.


I don't think the behaviour of existing casts should be changed, but
presumably, with template argument deduction for
constructors, we can define new wrapper types that take the wrapped
type as an argument of a constructor template
and have a conversion operator template that does the right kind of
cast before returning the result. Then we can
do something like

f(auto_dyn_cast(x));

There are of course cases where the target type can't be deduced from
the context, like when used in an init-capture
of a lambda, or with an auto-typed variable declaration, or in a
deduced template argument.

-- 
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFk2RUaaP4XC9H7d9e1GBDi8JA4F2dSf2i%3DqB7mqRUXj1Lui5Q%40mail.gmail.com.

.
