220 11955 <8761iv4ijm.fsf@euclid.axiomatics.org> article
Path: news.gmane.org!not-for-mail
From: Gabriel Dos Reis <gdr@axiomatics.org>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: should lambda to function pointer conversion
 become constexpr
Date: Thu, 17 Jul 2014 17:28:13 -0700
Organization: axiomatics.org
Lines: 45
Approved: news@gmane.org
Message-ID: <8761iv4ijm.fsf@euclid.axiomatics.org>
References: <153e8b0e-4f1b-413c-b2e2-7831bd4385e7@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Trace: ger.gmane.org 1405643306 27399 80.91.229.3 (18 Jul 2014 00:28:26 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 18 Jul 2014 00:28:26 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCSYNQUB2UHRBHWUUGPAKGQELQHNF2A@isocpp.org Fri Jul 18 02:28:16 2014
Return-path: <std-proposals+bncBCSYNQUB2UHRBHWUUGPAKGQELQHNF2A@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-oa0-f71.google.com ([209.85.219.71])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCSYNQUB2UHRBHWUUGPAKGQELQHNF2A@isocpp.org>)
	id 1X7w24-00070a-3J
	for gclcip-std-proposals@m.gmane.org; Fri, 18 Jul 2014 02:28:16 +0200
Original-Received: by mail-oa0-f71.google.com with SMTP id g18sf9468264oah.6
        for <gclcip-std-proposals@m.gmane.org>; Thu, 17 Jul 2014 17:28:15 -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:in-reply-to:organization
         :references:sender:date:message-id:lines:mime-version
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type
         :content-transfer-encoding;
        bh=R87sSgvjRcslOGxl9TGu06qY5XdTW4Wi0Cuwl8dOza8=;
        b=TsNeTvWJJ+W54nKlBxSXIi9H7HlXGUGkny56t/SpDpCLs9bxSAfbmhlDWZ1dXgVKQN
         vulH2CQFylL5JLvb1rAluMttbACNTaRIOWg+v0+DgUaTk6veTaLZMHU4Gf+M/X4VhirQ
         AqVKUZBYgiMXYiJA/Ntln3dq7cLk1u6R69eVTL/llgh7dhBvqfIsuXjPwiXBH99k91F0
         sKUjaKvWcC2AeHDoDuQWX5M1S9C0fh8W8Wc3cLqmHJuFalaL/tWOAWg2bAcpfbW4Rb8s
         z2NYiQt4zRnrRvpZZCVlbR2tzQCO03ZzFKkExo3MN37tVzENJAJ7LfuH 
X-Gm-Message-State: ALoCoQnFim9HPGiA0TA2umQfGqK+N7KwGZYIjLz5fRgy3gTaoQ1w2pPiSe5lA9hrgUZrEAhoTJha
X-Received: by 10.182.241.169 with SMTP id wj9mr582568obc.14.1405643295231;
        Thu, 17 Jul 2014 17:28:15 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.182.87.33 with SMTP id u1ls777746obz.79.gmail; Thu, 17 Jul
 2014 17:28:14 -0700 (PDT)
X-Received: by 10.182.66.130 with SMTP id f2mr1046272obt.84.1405643294307;
        Thu, 17 Jul 2014 17:28:14 -0700 (PDT)
Original-Received: from mail.axiomatics.org (www.axiomatics.org. [66.228.53.191])
        by mx.google.com with ESMTP id pb14si8002064oeb.98.2014.07.17.17.28.14
        for <std-proposals@isocpp.org>;
        Thu, 17 Jul 2014 17:28:14 -0700 (PDT)
Received-SPF: none (google.com: gdr@axiomatics.org does not designate permitted sender hosts) client-ip=66.228.53.191;
Original-Received: from euclid.axiomatics.org (localhost [IPv6:::1])
	by mail.axiomatics.org (Postfix) with ESMTP id CBE7BE770
	for <std-proposals@isocpp.org>; Thu, 17 Jul 2014 17:28:13 -0700 (PDT)
In-Reply-To: <153e8b0e-4f1b-413c-b2e2-7831bd4385e7@isocpp.org>
	(frrrwww@gmail.com's message of "Wed, 16 Jul 2014 10:51:47 -0700
	(PDT)")
Original-Sender: gdr@axiomatics.org
Original-Lines: 34
X-Original-Sender: gdr@axiomatics.org
X-Original-Authentication-Results: mx.google.com;       spf=neutral
 (google.com: gdr@axiomatics.org does not designate permitted sender hosts) smtp.mail=gdr@axiomatics.org
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:11955
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/11955>

frrrwww@gmail.com writes:

| Hello,
|=20
| I sometimes use the following pattern:
|=20
| static const struct {
| =C2=A0 =C2=A0 const char* name;
| =C2=A0 =C2=A0 void (*func)(int);
| } functions[] =3D {
| =C2=A0 =C2=A0 =C2=A0{ "function1", [](int) { ... } },
| =C2=A0 =C2=A0 =C2=A0{ "function2", [](int) { ... } },
| =C2=A0 =C2=A0 =C2=A0...
| };
|=20
| And when I look at the generated code, I see that this array gets
| generated at runtime.
|=20
| Ideally I would like to declare this array constexpr, and that would
| work if I used named functions, however it does not for lambda, and I
| cannot see any good reason for that.
|=20
| As the function pointer conversion operator only exists for state-less
| lambda, would'nt it make sense to define them as constexpr and their
| conversion operator as well ?

It does.

It is sad that we needed to introduce a keyword to get the notion
accepted by the C++ community, and we couldn't just infer
'constexprness' from the (inline) definition and use context.

-- Gaby

--=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/.

.
