220 17486 <15891333.nZL6fDpIhZ@lastique-pc> article
Path: news.gmane.org!not-for-mail
From: Andrey Semashev <andrey.semashev@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: constexpr function arguments
Date: Fri, 24 Apr 2015 01:15:27 +0300
Lines: 63
Approved: news@gmane.org
Message-ID: <15891333.nZL6fDpIhZ@lastique-pc>
References: <1799313.qMEWgUf3zn@lastique-pc> <8221738.H9gkvWvTUl@lastique-pc> <CANh8DEmE3x4FVoy-cM+4hbALqcA5uC5CRVxQYd_Vs_FXROtGHw@mail.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 1429827343 5120 80.91.229.3 (23 Apr 2015 22:15:43 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 23 Apr 2015 22:15:43 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCXY5TXHWYJRBAW64WUQKGQEBZ2THIY@isocpp.org Fri Apr 24 00:15:37 2015
Return-path: <std-proposals+bncBCXY5TXHWYJRBAW64WUQKGQEBZ2THIY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-la0-f71.google.com ([209.85.215.71])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCXY5TXHWYJRBAW64WUQKGQEBZ2THIY@isocpp.org>)
	id 1YlPPF-0004Pv-7k
	for gclcip-std-proposals@m.gmane.org; Fri, 24 Apr 2015 00:15:37 +0200
Original-Received: by laat2 with SMTP id t2sf8028406laa.2
        for <gclcip-std-proposals@m.gmane.org>; Thu, 23 Apr 2015 15:15:31 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:to:subject:date:message-id:user-agent
         :in-reply-to:references:mime-version:content-type:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe;
        bh=kuSwRgNX68goDE0lnmuZ6/XHrNiz/0tWJKFL760Z+sE=;
        b=imEPO+G9ZRENN3Xr3NTPU2QoQjulFg3o1arcFz7qn+QClN9URvWjW9hbmQ/t76IGXG
         sE8jR3jR+Oc9qWdKe/IA0neDvafj1y/yqkY2HMjXTr6UgM5cBSpN3aiQA7YLG7+YxVJp
         a2T9OR435K5iAvYUnQWRGMv5mlXbM+ebD5gW7hkZiYWNcHfCUWsOOPgzSF1TkzoqjF39
         sZb2Jgu7f5/9lb+EVSr7gZ0B/QNlZpssDCAsQk9p/oFp5HRgPjECYvrgUpLkyBbahGVp
         wyyvwAInsZtQB8zyN9Bwq/Tmu1uy3aEnBBEkWw10BiFyAX/BWoMteYRzdn+YgmWvBp7m
         JWWg==
X-Gm-Message-State: ALoCoQm61adHnX7vNnuqn86+dgEaTBQK3rDIBUoG+FKi+uW9kDZPmIfFlPbAxSNyOTh0eq4FrzUv
X-Received: by 10.194.249.1 with SMTP id yq1mr2460629wjc.2.1429827331672;
        Thu, 23 Apr 2015 15:15:31 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.152.207.65 with SMTP id lu1ls381419lac.104.gmail; Thu, 23 Apr
 2015 15:15:30 -0700 (PDT)
X-Received: by 10.112.134.167 with SMTP id pl7mr4336641lbb.50.1429827330093;
        Thu, 23 Apr 2015 15:15:30 -0700 (PDT)
Original-Received: from mail-la0-x22b.google.com (mail-la0-x22b.google.com. [2a00:1450:4010:c03::22b])
        by mx.google.com with ESMTPS id es16si6876861lbc.122.2015.04.23.15.15.30
        for <std-proposals@isocpp.org>
        (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Thu, 23 Apr 2015 15:15:30 -0700 (PDT)
Received-SPF: pass (google.com: domain of andrey.semashev@gmail.com designates 2a00:1450:4010:c03::22b as permitted sender) client-ip=2a00:1450:4010:c03::22b;
Original-Received: by lagv1 with SMTP id v1so22691514lag.3
        for <std-proposals@isocpp.org>; Thu, 23 Apr 2015 15:15:29 -0700 (PDT)
X-Received: by 10.112.78.105 with SMTP id a9mr4323174lbx.70.1429827329737;
        Thu, 23 Apr 2015 15:15:29 -0700 (PDT)
Original-Received: from lastique-pc.localnet (broadband-178-140-129-233.nationalcablenetworks.ru. [178.140.129.233])
        by mx.google.com with ESMTPSA id z2sm2144830lae.20.2015.04.23.15.15.27
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Thu, 23 Apr 2015 15:15:28 -0700 (PDT)
User-Agent: KMail/4.14.1 (Linux/3.16.0-34-generic; KDE/4.14.1; x86_64; ; )
In-Reply-To: <CANh8DEmE3x4FVoy-cM+4hbALqcA5uC5CRVxQYd_Vs_FXROtGHw@mail.gmail.com>
X-Original-Sender: andrey.semashev@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of andrey.semashev@gmail.com designates 2a00:1450:4010:c03::22b as
 permitted sender) smtp.mail=andrey.semashev@gmail.com;       dkim=pass
 header.i=@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-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:17486
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/17486>

On Thursday 23 April 2015 14:30:26 'Matt Calabrese' via ISO C++ Standard - 
Future Proposals wrote:
> On Thu, Apr 23, 2015 at 2:09 PM, Andrey Semashev <andrey.semashev@gmail.com>
> wrote:
> > It would be great if constexpr-ness just transparently propagated into the
> > function body, but then the function would likely need an intrinsic to
> > detect
> > if a certain argument (or more generically speaking, an expression) is a
> > constant expression. Say, an is_constexpr() operator, which returns a
> > constexpr bool. Do you think such addition would be more feasible?

[snip]

> As for whether constexpr-ness could truly transparently propagate, I think
> it wouldn't be quite so simple to make it actually transparent as it likely
> would involve making changes to the type system (unless people see other
> routes forward).

Isn't it possible to just describe the rules under which constexpr-ness should 
propagate without changing the type system? Something like "if the function 
argument is initialized with a constant expression, and the function 
definition is visible at the call site then that argument is a constexpr 
within that function body in the context of that particular call." Function-
local static variables would still have to be shared between all constexpr or 
not calls to such function but I think it's not a problem. The address 
operator would return a pointer to the function that takes runtime arguments. 
All in all it would appear as if for some calls the function has shadow 
specializations which are not detectable other than by calling them.

It could result in code bloat though. So it's probably better to mark such 
arguments with constexpr so that such special rules are applied only where 
needed. It wouldn't affect overload resolution because the function is the 
same (as constexpr would not participate in the function type).

  template< typename T >
  void atomic<T>::store(T val, constexpr memory_order order)
  {
    // ...
  }

  atomic<T> a;

  memory_order o = memory_order_relaxed;
  a.store(10, o); // order is not constexpr within store(); the fully runtime
                  // version of store() is called

  a.store(10, memory_order_relaxed); // order is constexpr within store();
                                     // a shadow version of store() is called

  auto p = &atomic<T>::store; // decltype(p) is
                              // void (atomic<T>::*)(T, memory_order);
                              // p points to the fully runtime version
                              // of store()


-- 

--- 
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/.

.
