220 10915 <CAB+4KH+eoF=PcS1pTg+neNA60bcbyZZXJsUenud4Md5RAk+MKw@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Andrew Tomazos <andrewtomazos@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Protect Lambda functions against reflection
Date: Wed, 28 May 2014 16:23:52 +0200
Lines: 132
Approved: news@gmane.org
Message-ID: <CAB+4KH+eoF=PcS1pTg+neNA60bcbyZZXJsUenud4Md5RAk+MKw@mail.gmail.com>
References: <108c47a2-d952-4f84-a347-923b2ab742ad@isocpp.org>
	<CAFk2RUaPcXONmVug7-_t+imouCVQv9LQ3Hos-yRo=0X-HBQZKQ@mail.gmail.com>
	<CAB+4KHL3MvqYR3s=grM7t8imKHmnjj8s4PAYO01Z+rtq8sivnw@mail.gmail.com>
	<CAFk2RUasQdm4U+w393wqaD-J_6km+xOHhmd_sRyBx7ESy5Eyjw@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=20cf303bf5e0cd722204fa768fb4
X-Trace: ger.gmane.org 1401287046 934 80.91.229.3 (28 May 2014 14:24:06 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 28 May 2014 14:24:06 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBD5KHQXXWYPRB6HCS6OAKGQE647EMKI@isocpp.org Wed May 28 16:24:00 2014
Return-path: <std-proposals+bncBD5KHQXXWYPRB6HCS6OAKGQE647EMKI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ve0-f200.google.com ([209.85.128.200])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBD5KHQXXWYPRB6HCS6OAKGQE647EMKI@isocpp.org>)
	id 1Wpelm-0007hT-Kp
	for gclcip-std-proposals@m.gmane.org; Wed, 28 May 2014 16:23:54 +0200
Original-Received: by mail-ve0-f200.google.com with SMTP id pa12sf44379498veb.7
        for <gclcip-std-proposals@m.gmane.org>; Wed, 28 May 2014 07:23:53 -0700 (PDT)
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:date
         :message-id:subject:from:to: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;
        bh=LvvQWudS8ZGQQkaXquhqkE7WPOdowELeP7Xm/eBrEY8=;
        b=URvL4DXcsSJ3aeedVngidc8+16YDGY7tQZSqQqV6ydE/g8enTJUOt0/IRxoVn3Up8s
         O4coN1A2u/9nys5JLJE4WuOeTGU2UJoCVy6yzAQUl6ILK/Y5HfaBhYuwAdAez1jp9kd+
         rP6nx1Je0fRzpkblkqzG+kpUk6ZEd7n5Zr+N9NGxwfG4SzBM40W8LHT6jtI893xvIqIb
         fdbGwcXD+o1VLC02CGwt/wHQiuNJzrS0gGnK/pdIB35xsUx14LYIcbJCWPeHhduCUoiT
         5I0fE5NWv3ilWEuoXMl89DnZFCj3vMsdLJAVikBpv3pKRSBVcIULW983zb0i3osSvHrv
         n5sQ==
X-Gm-Message-State: ALoCoQkG8LtqSppgP6KlES5JU/KDQfK/W5jPeeBhKrPidNqofNhqeK6BgLHpIq7JkSwFFF2XUREj
X-Received: by 10.236.197.39 with SMTP id s27mr14843136yhn.36.1401287033838;
        Wed, 28 May 2014 07:23:53 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.50.62.242 with SMTP id b18ls2690637igs.38.canary; Wed, 28 May
 2014 07:23:52 -0700 (PDT)
X-Received: by 10.42.202.70 with SMTP id fd6mr37338595icb.47.1401287032635;
        Wed, 28 May 2014 07:23:52 -0700 (PDT)
Original-Received: from mail-ig0-x232.google.com (mail-ig0-x232.google.com [2607:f8b0:4001:c05::232])
        by mx.google.com with ESMTPS id jh5si33528001icb.50.2014.05.28.07.23.52
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Wed, 28 May 2014 07:23:52 -0700 (PDT)
Received-SPF: pass (google.com: domain of andrewtomazos@gmail.com designates 2607:f8b0:4001:c05::232 as permitted sender) client-ip=2607:f8b0:4001:c05::232;
Original-Received: by mail-ig0-f178.google.com with SMTP id hl10so2495686igb.11
        for <std-proposals@isocpp.org>; Wed, 28 May 2014 07:23:52 -0700 (PDT)
X-Received: by 10.42.110.141 with SMTP id q13mr35897531icp.32.1401287032532;
 Wed, 28 May 2014 07:23:52 -0700 (PDT)
Original-Received: by 10.64.7.179 with HTTP; Wed, 28 May 2014 07:23:52 -0700 (PDT)
In-Reply-To: <CAFk2RUasQdm4U+w393wqaD-J_6km+xOHhmd_sRyBx7ESy5Eyjw@mail.gmail.com>
X-Original-Sender: andrewtomazos@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of andrewtomazos@gmail.com designates 2607:f8b0:4001:c05::232 as
 permitted sender) smtp.mail=andrewtomazos@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: <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:10915
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/10915>

--20cf303bf5e0cd722204fa768fb4
Content-Type: text/plain; charset=UTF-8

On Tue, May 27, 2014 at 8:04 PM, Ville Voutilainen <
ville.voutilainen@gmail.com> wrote:

> If you want to allow a reflection mechanism to access any member regardless
> of whether it's used in a context that has proper access, I predict you're
> inviting people to propose a facility that allows defining which members do
> not participate in reflection. Then again, I expect such a facility to
> surface
> regardless of access. :)
>

Given this class C:

class C
{
public:
    int f() { return x; }
private:
    int x;
};

and given an object c of type C:

C c = ...;

Using the raw N4027 primitives, you could write:

// get pointer to second member of C
int C::* p = std::class_member_pointer_v<C, 1>;

int y = c.*p; // read x

c.*p = 42; // write x

But you can check access control as follows:

static_assert(std::class_member_access_level_v<C,1> ==
    std::public_access, "must have public access");

(Of course the primitives are not designed to be used this way on
individual classes, they are designed to be used within templates on
generic type template parameters T of class type.)

What do you mean a facility that "allows defining which members do not
participate in reflection"?  You can always filter the member list in your
reflection library in whatever way you want.  You can give it a list the
names of members you want reflected, or you can give it a list of names to
be excluded, or you can give members some naming convention and filter
based on a regular expression on their name, etc.

It isn't clear to me what you are imagining- are you talking about a core
language addition to somehow mark in the class specifier something isn't
visible to reflection.  Like a "noreflect" specifier or something?

-- 

--- 
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/.

--20cf303bf5e0cd722204fa768fb4
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Tue, May 27, 2014 at 8:04 PM, Ville Voutilainen <span d=
ir=3D"ltr">&lt;<a href=3D"mailto:ville.voutilainen@gmail.com" target=3D"_bl=
ank">ville.voutilainen@gmail.com</a>&gt;</span> wrote:<br><div class=3D"gma=
il_extra">

<div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margi=
n:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex=
">If you want to allow a reflection mechanism to access any member regardle=
ss<br>

of whether it&#39;s used in a context that has proper access, I predict you=
&#39;re<br>
inviting people to propose a facility that allows defining which members do=
<br>
not participate in reflection. Then again, I expect such a facility to surf=
ace<br>
regardless of access. :)<br></blockquote><br>Given this class C:<br><div><b=
r></div><div>class C<br>{<br></div><div>public:<br></div><div>=C2=A0 =C2=A0=
 int f() { return x; }<br></div><div>private:<br></div><div>
=C2=A0 =C2=A0 int x;<br>};<br><br></div><div>and given an object c of type =
C:<br><br>C c =3D ...;<br></div><div><br></div><div>Using the raw N4027 pri=
mitives, you could write:<br><br></div><div>// get pointer to second member=
 of C<br>
</div><div>int C::* p =3D std::class_member_pointer_v&lt;C, 1&gt;;<br></div=
><div><br>int y =3D c.*p; // read x<br><br></div><div>c.*p =3D 42; // write=
 x<br>
<br></div><div>But you can check access control as follows:<br><br></div>st=
atic_assert(std::class_member_access_level_v&lt;C,1&gt; =3D=3D<br><div>=C2=
=A0=C2=A0=C2=A0 std::public_access, &quot;must have public access&quot;);<b=
r><br></div><div>
(Of course the primitives are not designed to be used this way on individua=
l classes, they are designed to be used within templates on generic type te=
mplate parameters T of class type.)<br></div><div><br></div><div>What do yo=
u mean a facility that &quot;allows defining which members do not participa=
te in reflection&quot;?=C2=A0 You can always filter the member list in your=
 reflection library in whatever way you want.=C2=A0 You can give it a list =
the names of members you want reflected, or you can give it a list of names=
 to be excluded, or you can give members some naming convention and filter =
based on a regular expression on their name, etc.<br>
<br>It isn&#39;t clear to me what you are imagining- are you talking about =
a core language addition to somehow mark in the class specifier something i=
sn&#39;t visible to reflection.=C2=A0 Like a &quot;noreflect&quot; specifie=
r or something?<br>
<br></div></div></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 />

--20cf303bf5e0cd722204fa768fb4--

.
