Topic: Opaque (or strong) typedef approach
Author: Pablo Oliva <pabloliva87@gmail.com>
Date: Thu, 19 May 2016 16:50:07 -0300
Raw View
--94eb2c0b8ce4fed1340533374742
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Hi all,
We have been working on the Opaque (or Strong) typedef topic discussed in
n3515 and p0109r0.
We decided to take a different approach from those that were discussed both
in the prior art sections and in the papers themselves.
When a typedef is opaque, the compiler looks for the definition of the
underlying type, and then it replaces the typedef declaration by a copy of
the underlying type=E2=80=99s definition, with its name replaced by the typ=
edef=E2=80=99s
name all along the type (in methods' implementations, special methods and
attribute types).
This approach doesn=E2=80=99t work for native types, but we thought that it=
would
be useful to have it as a thought experiment to see if a typedef of this
sort would have any real usage.
For instance, if we had:
struct Base{};
struct S : Base
{};
opaque_typedef S T;
f(S* s)
{}
g(Base* bp)
{}
template<class C>
struct someTemplate
{};
int main()
{
T t;
f(&t); // doesn=E2=80=99t compile
g(&t); // compiles
std::is_same<someTemplate<S>, someTemplate<T>>::value; // false
}
We implemented this approach as a clang plugin in which opaque typedefs are
implemented as an attribute (just for the sake of implementation
simplicity). A compliant solution should have a new syntax rather than use
an attribute.
The prototype is available upon request via private message.
We would like to receive feedback about how (or if) this approach sounds
promising to you, and of any issues regarding the clang plugin.
Thanks,
Pablo Oliva and Daniel Gutson.
--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/CAPzzLYkeMgAKKVGCfHGXZch5TqdsQqNgyFXdpDeiGnByYpt=
v7g%40mail.gmail.com.
--94eb2c0b8ce4fed1340533374742
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><span id=3D"docs-internal-guid-55d2082d-ca8c-b796-9106-e0e=
279f63258"><p dir=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;margin-b=
ottom:0pt"><span style=3D"font-size:14.6667px;font-family:Arial;color:rgb(0=
,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transpa=
rent">Hi all, </span></p><br><p dir=3D"ltr" style=3D"line-height:1.38;margi=
n-top:0pt;margin-bottom:0pt"><span style=3D"font-size:14.6667px;font-family=
:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;backgr=
ound-color:transparent">We have been working on the Opaque (or Strong) type=
def topic discussed in n3515 and p0109r0. </span></p><br><p dir=3D"ltr" sty=
le=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style=3D"fon=
t-size:14.6667px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline=
;white-space:pre-wrap;background-color:transparent">We decided to take a di=
fferent approach from those that were discussed both in the prior art secti=
ons and in the papers themselves.</span></p><br><p dir=3D"ltr" style=3D"lin=
e-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:14=
..6667px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-sp=
ace:pre-wrap;background-color:transparent">When a typedef is opaque, the co=
mpiler looks for the definition of the underlying type, and then it replace=
s the typedef declaration by a copy of the underlying type=E2=80=99s defini=
tion, with its name replaced by the typedef=E2=80=99s name all along the ty=
pe (in methods' implementations, special methods and attribute types).<=
/span></p><br><p dir=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;margi=
n-bottom:0pt"><span style=3D"font-size:14.6667px;font-family:Arial;color:rg=
b(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:tran=
sparent">This approach doesn=E2=80=99t work for native types, but we though=
t that it would be useful to have it as a thought experiment to see if a ty=
pedef of this sort would have any real usage. </span></p><br><p dir=3D"ltr"=
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style=3D=
"font-size:14.6667px;font-family:Arial;color:rgb(0,0,0);vertical-align:base=
line;white-space:pre-wrap;background-color:transparent">For instance, if we=
had:</span></p><br><p dir=3D"ltr" style=3D"line-height:1.38;margin-top:0pt=
;margin-bottom:0pt"><span style=3D"color:rgb(0,0,0);vertical-align:baseline=
;white-space:pre-wrap;background-color:transparent"><font face=3D"monospace=
, monospace" size=3D"1">struct Base{};</font></span></p><font face=3D"monos=
pace, monospace" size=3D"1"><br></font><p dir=3D"ltr" style=3D"line-height:=
1.38;margin-top:0pt;margin-bottom:0pt"><span style=3D"color:rgb(0,0,0);vert=
ical-align:baseline;white-space:pre-wrap;background-color:transparent"><fon=
t face=3D"monospace, monospace" size=3D"1">struct S : Base</font></span></p=
><p dir=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"=
><span style=3D"color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wr=
ap;background-color:transparent"><font face=3D"monospace, monospace" size=
=3D"1">{};</font></span></p><font face=3D"monospace, monospace" size=3D"1">=
<br></font><p dir=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;margin-b=
ottom:0pt"><span style=3D"color:rgb(0,0,0);vertical-align:baseline;white-sp=
ace:pre-wrap;background-color:transparent"><font face=3D"monospace, monospa=
ce" size=3D"1">opaque_typedef S T;</font></span></p><font face=3D"monospace=
, monospace" size=3D"1"><br></font><p dir=3D"ltr" style=3D"line-height:1.38=
;margin-top:0pt;margin-bottom:0pt"><span style=3D"color:rgb(0,0,0);vertical=
-align:baseline;white-space:pre-wrap;background-color:transparent"><font fa=
ce=3D"monospace, monospace" size=3D"1">f(S* s)</font></span></p><p dir=3D"l=
tr" style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style=
=3D"color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;backgroun=
d-color:transparent"><font face=3D"monospace, monospace" size=3D"1">{}</fon=
t></span></p><font face=3D"monospace, monospace" size=3D"1"><br></font><p d=
ir=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><spa=
n style=3D"color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;ba=
ckground-color:transparent"><font face=3D"monospace, monospace" size=3D"1">=
g(Base* bp)</font></span></p><p dir=3D"ltr" style=3D"line-height:1.38;margi=
n-top:0pt;margin-bottom:0pt"><span style=3D"color:rgb(0,0,0);vertical-align=
:baseline;white-space:pre-wrap;background-color:transparent"><font face=3D"=
monospace, monospace" size=3D"1">{}</font></span></p><font face=3D"monospac=
e, monospace" size=3D"1"><br></font><p dir=3D"ltr" style=3D"line-height:1.3=
8;margin-top:0pt;margin-bottom:0pt"><span style=3D"color:rgb(0,0,0);vertica=
l-align:baseline;white-space:pre-wrap;background-color:transparent"><font f=
ace=3D"monospace, monospace" size=3D"1">template<class C></font></spa=
n></p><p dir=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;margin-bottom=
:0pt"><span style=3D"color:rgb(0,0,0);vertical-align:baseline;white-space:p=
re-wrap;background-color:transparent"><font face=3D"monospace, monospace" s=
ize=3D"1">struct someTemplate</font></span></p><p dir=3D"ltr" style=3D"line=
-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style=3D"color:rgb(0,0=
,0);vertical-align:baseline;white-space:pre-wrap;background-color:transpare=
nt"><font face=3D"monospace, monospace" size=3D"1">{};</font></span></p><fo=
nt face=3D"monospace, monospace" size=3D"1"><br></font><p dir=3D"ltr" style=
=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style=3D"color=
:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:t=
ransparent"><font face=3D"monospace, monospace" size=3D"1">int main()</font=
></span></p><p dir=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;margin-=
bottom:0pt"><span style=3D"color:rgb(0,0,0);vertical-align:baseline;white-s=
pace:pre-wrap;background-color:transparent"><font face=3D"monospace, monosp=
ace" size=3D"1">{</font></span></p><p dir=3D"ltr" style=3D"line-height:1.38=
;margin-top:0pt;margin-bottom:0pt"><font face=3D"monospace, monospace" size=
=3D"1"><span style=3D"color:rgb(0,0,0);vertical-align:baseline;white-space:=
pre-wrap;background-color:transparent"><span class=3D"" style=3D"white-spac=
e:pre"> </span></span><span style=3D"color:rgb(0,0,0);vertical-align:baseli=
ne;white-space:pre-wrap;background-color:transparent">T t;</span></font></p=
><font face=3D"monospace, monospace" size=3D"1"><br></font><p dir=3D"ltr" s=
tyle=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><font face=3D"mo=
nospace, monospace" size=3D"1"><span style=3D"color:rgb(0,0,0);vertical-ali=
gn:baseline;white-space:pre-wrap;background-color:transparent"><span class=
=3D"" style=3D"white-space:pre"> </span></span><span style=3D"color:rgb(0,0=
,0);vertical-align:baseline;white-space:pre-wrap;background-color:transpare=
nt">f(&t); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0// doesn=E2=80=99t=
compile</span></font></p><p dir=3D"ltr" style=3D"line-height:1.38;margin-t=
op:0pt;margin-bottom:0pt"><font face=3D"monospace, monospace" size=3D"1"><s=
pan style=3D"color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;=
background-color:transparent"><span class=3D"" style=3D"white-space:pre"> <=
/span></span><span style=3D"color:rgb(0,0,0);vertical-align:baseline;white-=
space:pre-wrap;background-color:transparent">g(&t); =C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 =C2=A0// compiles</span></font></p><p dir=3D"ltr" style=3D"lin=
e-height:1.38;margin-top:0pt;margin-bottom:0pt"><font face=3D"monospace, mo=
nospace" size=3D"1"><span style=3D"color:rgb(0,0,0);vertical-align:baseline=
;white-space:pre-wrap;background-color:transparent"><span class=3D"" style=
=3D"white-space:pre"> </span></span><span style=3D"color:rgb(0,0,0);vertica=
l-align:baseline;white-space:pre-wrap;background-color:transparent">std::is=
_same<someTemplate<S>, someTemplate<T>>::value; // false<=
/span></font></p><p dir=3D"ltr" style=3D"line-height:1.38;margin-top:0pt;ma=
rgin-bottom:0pt"><span style=3D"color:rgb(0,0,0);vertical-align:baseline;wh=
ite-space:pre-wrap;background-color:transparent"><font face=3D"monospace, m=
onospace" size=3D"1">}</font></span></p><br><p dir=3D"ltr" style=3D"line-he=
ight:1.38;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:14.666=
7px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:=
pre-wrap;background-color:transparent">We implemented this approach as a cl=
ang plugin in which opaque typedefs are implemented as an attribute (just f=
or the sake of implementation simplicity). A compliant solution should have=
a new syntax rather than use an attribute.</span></p><p dir=3D"ltr" style=
=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-=
size:14.6667px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;w=
hite-space:pre-wrap;background-color:transparent">The prototype is availabl=
e upon request via private message.</span></p><br><p dir=3D"ltr" style=3D"l=
ine-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:=
14.6667px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-=
space:pre-wrap;background-color:transparent">We would like to receive feedb=
ack about how (or if) this approach sounds promising to you, and of any iss=
ues regarding the clang plugin.</span></p><br><p dir=3D"ltr" style=3D"line-=
height:1.38;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:14.6=
667px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-spac=
e:pre-wrap;background-color:transparent">Thanks,</span></p><br><p dir=3D"lt=
r" style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style=
=3D"font-size:14.6667px;font-family:Arial;color:rgb(0,0,0);vertical-align:b=
aseline;white-space:pre-wrap;background-color:transparent"><span class=3D""=
style=3D"white-space:pre"> </span></span><span style=3D"font-size:14.6667p=
x;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pr=
e-wrap;background-color:transparent">Pablo Oliva and Daniel Gutson.</span><=
/p><div><span style=3D"font-size:14.6667px;font-family:Arial;color:rgb(0,0,=
0);vertical-align:baseline;white-space:pre-wrap;background-color:transparen=
t"><br></span></div></span></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAPzzLYkeMgAKKVGCfHGXZch5TqdsQqNgyFXd=
pDeiGnByYptv7g%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAPzzLYkeMgAKKVGC=
fHGXZch5TqdsQqNgyFXdpDeiGnByYptv7g%40mail.gmail.com</a>.<br />
--94eb2c0b8ce4fed1340533374742--
.
Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Fri, 20 May 2016 00:33:42 +0200
Raw View
This is a multi-part message in MIME format.
--------------3FF519DE7AD8D8AEEF220D2D
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Le 19/05/2016 =C3=A0 21:50, Pablo Oliva a =C3=A9crit :
>
> Hi all,
>
>
> We have been working on the Opaque (or Strong) typedef topic discussed=20
> in n3515 and p0109r0.
>
>
> We decided to take a different approach from those that were discussed=20
> both in the prior art sections and in the papers themselves.
>
>
> When a typedef is opaque, the compiler looks for the definition of the=20
> underlying type, and then it replaces the typedef declaration by a=20
> copy of the underlying type=E2=80=99s definition, with its name replaced =
by=20
> the typedef=E2=80=99s name all along the type (in methods' implementation=
s,=20
> special methods and attribute types).
>
>
> This approach doesn=E2=80=99t work for native types, but we thought that =
it=20
> would be useful to have it as a thought experiment to see if a typedef=20
> of this sort would have any real usage.
>
>
> For instance, if we had:
>
>
> struct Base{};
>
>
> struct S : Base
>
> {};
>
>
> opaque_typedef S T;
>
>
> f(S* s)
>
> {}
>
>
> g(Base* bp)
>
> {}
>
>
> template<class C>
>
> struct someTemplate
>
> {};
>
>
> int main()
>
> {
>
> T t;
>
>
> f(&t); // doesn=E2=80=99t compile
>
> g(&t); // compiles
>
> std::is_same<someTemplate<S>, someTemplate<T>>::value; // false
>
> }
>
>
> We implemented this approach as a clang plugin in which opaque=20
> typedefs are implemented as an attribute (just for the sake of=20
> implementation simplicity). A compliant solution should have a new=20
> syntax rather than use an attribute.
>
> The prototype is available upon request via private message.
>
>
> We would like to receive feedback about how (or if) this approach=20
> sounds promising to you, and of any issues regarding the clang plugin.
>
>
Hi,
we can do this already if we can redefine the type S using templates and=20
tags
template <class Tag>
struct S_tagged : Base
{};
struct S_tag{};
using S =3D S_tagged<S_tag>;
struct T_tag{};
using T =3D S_tagged<T_tag>;
Your language based approach can be applied without changing the type S,=20
but has no additional advantage and has the same liabilities: we can not=20
restrict/change the interface, the copy is restricted to members. Not=20
been able to create an opaque type of a int is a major drawback IMHO.
How does your plugin behaves for friend functions? Are these part of the=20
definition of S?
What happens if the implementation of the class S makes use of external=20
functions that take S as parameter?
Do you have some real use cases that are applicable? I like the approach=20
taken in p0109r0. How your approach is better for you?
Vicente
--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/dd78e76d-23b4-254c-2e58-0790a446c1e6%40wanadoo.f=
r.
--------------3FF519DE7AD8D8AEEF220D2D
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<meta content=3D"text/html; charset=3Dutf-8" http-equiv=3D"Content-Type=
">
</head>
<body bgcolor=3D"#FFFFFF" text=3D"#000000">
<div class=3D"moz-cite-prefix">Le 19/05/2016 =C3=A0 21:50, Pablo Oliva =
a
=C3=A9crit=C2=A0:<br>
</div>
<blockquote
cite=3D"mid:CAPzzLYkeMgAKKVGCfHGXZch5TqdsQqNgyFXdpDeiGnByYptv7g@mail.gmail.=
com"
type=3D"cite">
<div dir=3D"ltr"><span
id=3D"docs-internal-guid-55d2082d-ca8c-b796-9106-e0e279f63258">
<p dir=3D"ltr"
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><sp=
an style=3D"font-size:14.6667px;font-family:Arial;color:rgb(0,0,0);vertical=
-align:baseline;white-space:pre-wrap;background-color:transparent">Hi all, =
</span></p>
<br>
<p dir=3D"ltr"
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><sp=
an style=3D"font-size:14.6667px;font-family:Arial;color:rgb(0,0,0);vertical=
-align:baseline;white-space:pre-wrap;background-color:transparent">We have =
been working on the Opaque (or Strong) typedef topic discussed in n3515 and=
p0109r0. </span></p>
<br>
<p dir=3D"ltr"
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><sp=
an style=3D"font-size:14.6667px;font-family:Arial;color:rgb(0,0,0);vertical=
-align:baseline;white-space:pre-wrap;background-color:transparent">We decid=
ed to take a different approach from those that were discussed both in the =
prior art sections and in the papers themselves.</span></p>
<br>
<p dir=3D"ltr"
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><sp=
an style=3D"font-size:14.6667px;font-family:Arial;color:rgb(0,0,0);vertical=
-align:baseline;white-space:pre-wrap;background-color:transparent">When a t=
ypedef is opaque, the compiler looks for the definition of the underlying t=
ype, and then it replaces the typedef declaration by a copy of the underlyi=
ng type=E2=80=99s definition, with its name replaced by the typedef=E2=80=
=99s name all along the type (in methods' implementations, special methods =
and attribute types).</span></p>
<br>
<p dir=3D"ltr"
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><sp=
an style=3D"font-size:14.6667px;font-family:Arial;color:rgb(0,0,0);vertical=
-align:baseline;white-space:pre-wrap;background-color:transparent">This app=
roach doesn=E2=80=99t work for native types, but we thought that it would b=
e useful to have it as a thought experiment to see if a typedef of this sor=
t would have any real usage. </span></p>
<br>
<p dir=3D"ltr"
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><sp=
an style=3D"font-size:14.6667px;font-family:Arial;color:rgb(0,0,0);vertical=
-align:baseline;white-space:pre-wrap;background-color:transparent">For inst=
ance, if we had:</span></p>
<br>
<p dir=3D"ltr"
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><sp=
an style=3D"color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;b=
ackground-color:transparent"><font face=3D"monospace, monospace" size=3D"1"=
>struct Base{};</font></span></p>
<font face=3D"monospace, monospace" size=3D"1"><br>
</font>
<p dir=3D"ltr"
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><sp=
an style=3D"color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;b=
ackground-color:transparent"><font face=3D"monospace, monospace" size=3D"1"=
>struct S : Base</font></span></p>
<p dir=3D"ltr"
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><sp=
an style=3D"color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;b=
ackground-color:transparent"><font face=3D"monospace, monospace" size=3D"1"=
>{};</font></span></p>
<font face=3D"monospace, monospace" size=3D"1"><br>
</font>
<p dir=3D"ltr"
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><sp=
an style=3D"color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;b=
ackground-color:transparent"><font face=3D"monospace, monospace" size=3D"1"=
>opaque_typedef S T;</font></span></p>
<font face=3D"monospace, monospace" size=3D"1"><br>
</font>
<p dir=3D"ltr"
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><sp=
an style=3D"color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;b=
ackground-color:transparent"><font face=3D"monospace, monospace" size=3D"1"=
>f(S* s)</font></span></p>
<p dir=3D"ltr"
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><sp=
an style=3D"color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;b=
ackground-color:transparent"><font face=3D"monospace, monospace" size=3D"1"=
>{}</font></span></p>
<font face=3D"monospace, monospace" size=3D"1"><br>
</font>
<p dir=3D"ltr"
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><sp=
an style=3D"color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;b=
ackground-color:transparent"><font face=3D"monospace, monospace" size=3D"1"=
>g(Base* bp)</font></span></p>
<p dir=3D"ltr"
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><sp=
an style=3D"color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;b=
ackground-color:transparent"><font face=3D"monospace, monospace" size=3D"1"=
>{}</font></span></p>
<font face=3D"monospace, monospace" size=3D"1"><br>
</font>
<p dir=3D"ltr"
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><sp=
an style=3D"color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;b=
ackground-color:transparent"><font face=3D"monospace, monospace" size=3D"1"=
>template<class C></font></span></p>
<p dir=3D"ltr"
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><sp=
an style=3D"color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;b=
ackground-color:transparent"><font face=3D"monospace, monospace" size=3D"1"=
>struct someTemplate</font></span></p>
<p dir=3D"ltr"
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><sp=
an style=3D"color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;b=
ackground-color:transparent"><font face=3D"monospace, monospace" size=3D"1"=
>{};</font></span></p>
<font face=3D"monospace, monospace" size=3D"1"><br>
</font>
<p dir=3D"ltr"
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><sp=
an style=3D"color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;b=
ackground-color:transparent"><font face=3D"monospace, monospace" size=3D"1"=
>int main()</font></span></p>
<p dir=3D"ltr"
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><sp=
an style=3D"color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;b=
ackground-color:transparent"><font face=3D"monospace, monospace" size=3D"1"=
>{</font></span></p>
<p dir=3D"ltr"
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><fo=
nt
face=3D"monospace, monospace" size=3D"1"><span style=3D"color=
:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:t=
ransparent"><span class=3D"" style=3D"white-space:pre"> </span></span><span=
style=3D"color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;bac=
kground-color:transparent">T t;</span></font></p>
<font face=3D"monospace, monospace" size=3D"1"><br>
</font>
<p dir=3D"ltr"
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><fo=
nt
face=3D"monospace, monospace" size=3D"1"><span style=3D"color=
:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:t=
ransparent"><span class=3D"" style=3D"white-space:pre"> </span></span><span=
style=3D"color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;bac=
kground-color:transparent">f(&t); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0// doesn=E2=80=99t compile</span></font></p>
<p dir=3D"ltr"
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><fo=
nt
face=3D"monospace, monospace" size=3D"1"><span style=3D"color=
:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:t=
ransparent"><span class=3D"" style=3D"white-space:pre"> </span></span><span=
style=3D"color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;bac=
kground-color:transparent">g(&t); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =C2=A0=
// compiles</span></font></p>
<p dir=3D"ltr"
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><fo=
nt
face=3D"monospace, monospace" size=3D"1"><span style=3D"color=
:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:t=
ransparent"><span class=3D"" style=3D"white-space:pre"> </span></span><span=
style=3D"color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;bac=
kground-color:transparent">std::is_same<someTemplate<S>, someTempl=
ate<T>>::value; // false</span></font></p>
<p dir=3D"ltr"
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><sp=
an style=3D"color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;b=
ackground-color:transparent"><font face=3D"monospace, monospace" size=3D"1"=
>}</font></span></p>
<br>
<p dir=3D"ltr"
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><sp=
an style=3D"font-size:14.6667px;font-family:Arial;color:rgb(0,0,0);vertical=
-align:baseline;white-space:pre-wrap;background-color:transparent">We imple=
mented this approach as a clang plugin in which opaque typedefs are impleme=
nted as an attribute (just for the sake of implementation simplicity). A co=
mpliant solution should have a new syntax rather than use an attribute.</sp=
an></p>
<p dir=3D"ltr"
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><sp=
an style=3D"font-size:14.6667px;font-family:Arial;color:rgb(0,0,0);vertical=
-align:baseline;white-space:pre-wrap;background-color:transparent">The prot=
otype is available upon request via private message.</span></p>
<br>
<p dir=3D"ltr"
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><sp=
an style=3D"font-size:14.6667px;font-family:Arial;color:rgb(0,0,0);vertical=
-align:baseline;white-space:pre-wrap;background-color:transparent">We would=
like to receive feedback about how (or if) this approach sounds promising =
to you, and of any issues regarding the clang plugin.</span></p>
</span><br>
</div>
</blockquote>
Hi,<br>
<br>
we can do this already if we can redefine the type S using templates
and tags<br>
<br>
template <class Tag><br>
<span id=3D"docs-internal-guid-55d2082d-ca8c-b796-9106-e0e279f63258">
<p dir=3D"ltr"
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span s=
tyle=3D"color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;backg=
round-color:transparent"><font face=3D"monospace, monospace" size=3D"1">str=
uct S_tagged : Base</font></span></p>
<p dir=3D"ltr"
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span s=
tyle=3D"color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;backg=
round-color:transparent"><font face=3D"monospace, monospace" size=3D"1">{};=
</font></span></p>
<font face=3D"monospace, monospace" size=3D"1"><br>
struct S_tag{};<br>
</font>
<p dir=3D"ltr"
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span s=
tyle=3D"color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;backg=
round-color:transparent"><font face=3D"monospace, monospace" size=3D"1">usi=
ng S =3D S_tagged<</font></span><span style=3D"color:rgb(0,0,0);vertical=
-align:baseline;white-space:pre-wrap;background-color:transparent"><font fa=
ce=3D"monospace, monospace" size=3D"1"><span id=3D"docs-internal-guid-55d20=
82d-ca8c-b796-9106-e0e279f63258"><font face=3D"monospace, monospace" size=
=3D"1">S_tag></font></span>;</font></span></p>
<font face=3D"monospace, monospace" size=3D"1"><br>
</font></span><br>
<span id=3D"docs-internal-guid-55d2082d-ca8c-b796-9106-e0e279f63258"><f=
ont
face=3D"monospace, monospace" size=3D"1">struct T_tag{};<br>
</font>
<p dir=3D"ltr"
style=3D"line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span s=
tyle=3D"color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;backg=
round-color:transparent"><font face=3D"monospace, monospace" size=3D"1">usi=
ng T =3D S_tagged<T</font></span><span style=3D"color:rgb(0,0,0);vertica=
l-align:baseline;white-space:pre-wrap;background-color:transparent"><font f=
ace=3D"monospace, monospace" size=3D"1"><span id=3D"docs-internal-guid-55d2=
082d-ca8c-b796-9106-e0e279f63258"><font face=3D"monospace, monospace" size=
=3D"1">_tag></font></span>;</font></span></p>
<font face=3D"monospace, monospace" size=3D"1"><br>
</font></span><br>
Your language based approach can be applied without changing the
type S, but has no additional advantage and has the same
liabilities: we can not restrict/change the interface, the copy is
restricted to members. Not been able to create an opaque type of a
int is a major drawback IMHO. <br>
<br>
How does your plugin behaves for friend functions? Are these part of
the definition of S?<br>
<br>
What happens if the implementation of the class S makes use of
external functions that take S as parameter?<br>
<br>
<span id=3D"docs-internal-guid-55d2082d-ca8c-b796-9106-e0e279f63258"><s=
pan style=3D"font-size:14.6667px;font-family:Arial;color:rgb(0,0,0);vertica=
l-align:baseline;white-space:pre-wrap;background-color:transparent">Do you =
have some real use cases that are applicable?
</span></span>I like the approach taken in <span
id=3D"docs-internal-guid-55d2082d-ca8c-b796-9106-e0e279f63258"><span =
style=3D"font-size:14.6667px;font-family:Arial;color:rgb(0,0,0);vertical-al=
ign:baseline;white-space:pre-wrap;background-color:transparent">p0109r0. Ho=
w your approach is better for you?
</span></span><br>
Vicente<br>
</body>
</html>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/dd78e76d-23b4-254c-2e58-0790a446c1e6%=
40wanadoo.fr?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/dd78e76d-23b4-254c-2e58-0790a446c1e6=
%40wanadoo.fr</a>.<br />
--------------3FF519DE7AD8D8AEEF220D2D--
.