220 4340 <97b8bfb8-53e8-46a5-81b1-64d68b2ca54b@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Nicol Bolas <jmckesson@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Please implement more rules about memory
 layout of the non-virtual classes.
Date: Wed, 8 May 2013 19:01:42 -0700 (PDT)
Lines: 465
Approved: news@gmane.org
Message-ID: <97b8bfb8-53e8-46a5-81b1-64d68b2ca54b@isocpp.org>
References: <e02dc1d0-2829-43c1-87a6-e88664e4e215@isocpp.org>
 <53cf1f05-734a-4cfa-86f0-f7e112f69d14@isocpp.org>
 <f5950d86-f249-4514-81b2-5e212158b7fc@isocpp.org>
 <caf64599-9f9f-4a66-805e-f5fa66fbca84@isocpp.org>
 <10ea67e2-61cb-4e14-8d22-111c1321dac0@isocpp.org>
 <cb6e381f-c6ef-48ae-9703-6ca38af7e4bf@isocpp.org>
 <CAFk2RUZS1t63W_aNa=EWgmjgHx2UVha9rUbAzSg+y-ctRPKq4w@mail.gmail.com>
 <aff96b77-1bc4-4453-ac9a-d5309c055cf4@isocpp.org>
 <0037922f-5a94-4865-9599-61b49fd4e60a@isocpp.org>
 <fcc6a728-e9c2-490d-b220-5488d6ae6677@isocpp.org>
 <b90308f8-4ff5-4289-af19-e63767d8084c@isocpp.org>
 <d5d58e31-5cfd-4983-becb-2bce2e03d6d9@isocpp.org>
 <6335d08d-3ae5-41dc-b128-6b2c49b3d51b@isocpp.org>
 <85781912-423b-4ee3-9710-79e69370924b@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_4353_29143114.1368064902805"
X-Trace: ger.gmane.org 1368064912 2199 80.91.229.3 (9 May 2013 02:01:52 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 9 May 2013 02:01:52 +0000 (UTC)
Cc: unituniverse.1@gmail.com, unituniverse.1@gmail.com, unituniverse.1@gmail.com, 
	unituniverse.1@gmail.com, unituniverse.1@gmail.com, 
	unituniverse.1@gmail.com
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCEKFTV6ZUMBBCUHVSGAKGQENFZPTKY@isocpp.org Thu May 09 04:01:50 2013
Return-path: <std-proposals+bncBCEKFTV6ZUMBBCUHVSGAKGQENFZPTKY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ie0-f200.google.com ([209.85.223.200])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCEKFTV6ZUMBBCUHVSGAKGQENFZPTKY@isocpp.org>)
	id 1UaGB1-0002SB-TR
	for gclcip-std-proposals@m.gmane.org; Thu, 09 May 2013 04:01:48 +0200
Original-Received: by mail-ie0-f200.google.com with SMTP id 10sf8778382ied.7
        for <gclcip-std-proposals@m.gmane.org>; Wed, 08 May 2013 19:01:47 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=x-received:x-beenthere:x-received:date:from:to:cc:message-id
         :in-reply-to:references:subject:mime-version:x-original-sender
         :reply-to:precedence:mailing-list:list-id:x-google-group-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe
         :content-type;
        bh=1YXxtyZsSdzNHMmhqkcYjbp2KRHjuu24dVSDCKwxzeY=;
        b=v5dnzILjRl9E02MgfgCREK4OPaRLSJcGLdnWGJ7dbMtv29WxCANw/6Lp+9L6uXgHdP
         IfvYk7urlXmFrZYEXNrCoeQxpbxMxB3jWa5XHezcfhe+OSHCnHo4+T571RuxeyOjYJKp
         IimbAFcSIMcDvzHvPISquhyBzeJemVKcD/MGBL1qVXf8fJL2/F/GuMKHUFJA2k/cUE56
         V6SgckBS2kP74hq9TNh/9BiXHxRx6WjYLLrcstAwmWgswixTyudBqKel7oPn/xf+M/S1
         ylZvcR/nCUF17+j8+AYD7z21Ahilmhas+p1uPTg/hkC3qZJSzLs8PDAjHMT/qdBBmEXy
         hKyg==
X-Received: by 10.43.155.200 with SMTP id lj8mr6698328icc.23.1368064906992;
        Wed, 08 May 2013 19:01:46 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.50.112.71 with SMTP id io7ls1736561igb.3.gmail; Wed, 08 May
 2013 19:01:45 -0700 (PDT)
X-Received: by 10.50.109.228 with SMTP id hv4mr1535758igb.2.1368064905256;
        Wed, 08 May 2013 19:01:45 -0700 (PDT)
In-Reply-To: <85781912-423b-4ee3-9710-79e69370924b@isocpp.org>
X-Original-Sender: jmckesson@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?hl=en>,
 <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?hl=en&topic=25838>,
 <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe?hl=en>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe?hl=en>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:4340
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/4340>

------=_Part_4353_29143114.1368064902805
Content-Type: text/plain; charset=ISO-8859-1

On Wednesday, May 8, 2013 10:04:04 AM UTC-7, unituni...@gmail.com wrote:
>
> Because it can be used at many places to enhance both the performance and 
> readability.
>
> 1.Assuming we have a class C1:
> class C1
> {
> private:
>     int a;
>
> public:
>     C1(void);
>     C1(int var1, float var2);
>
> private:
>     C1(const C1 &);               // disabled copy-construct.
>     C1 & operator = (const C1 &); // disabled copy-assignment.
>     static void * operator new (size_t);
>     static void operator delete (void *);// deleting C1 with pointer of 
> C1 or the inheritance is not allowed.
>     static void * operator new [] (size_t);
>     static void operator delete [] (void *);// deleting C1 with pointer 
> of C1 or the inheritance is not allowed.
>     template < typename _ty >
>     operator _ty & (void) const;  // disabled generic (means without 
> using 'reinterpret_case') convertions.
>     C1 * operator & (void) const; // Get the address of C1 object is not 
> allowed.
> };
>

This is some of the worst C++ code I've ever seen. That's an impressive 
feat, since it's just a class declaration.

I could imagine that there's a reason why you need to forbid heap 
allocation for some type. I can't think of one off the top of my head, but 
I'm sure there's a reason. But there is *absolutely no reason* to forbid 
implicit conversions. Unless you specify a specific implicit conversion... 
you can't do any implicit conversions. They're already forbidden; *double*forbidding them is just silly.

And there is *absolutely no reason* to forbid getting the address of the 
object. If I want to get the address of a type, that's my business, not 
yours. Not to mention, I can undo all of this effort just by using 
`std::address_of`.

It seems to me that your problem is not with C++. It's that you're writing 
garbage C++ code and want it to work.
 

> Now we need a class to let it begin handled by a container and, however, 
> the container only allowed to provided at most one, at least none argument 
> to initialize the object. Finally let the object can be work in this way:
>
>
> struct Packer // It should have been a template, for explanation i used a 
> non-template class instead.
> {
>     C1 mydata;
>
>     Packer(void) {}; // Calling the default-constuctor of object mydata.
>
>     Packer(ArgLists<int,float> args) // The container support at most one 
> argument. So we use ArgLists.
>         : mydata(args.get<0>(), args.get<1>())
>     {};
> };
>
> Here is the request: The Packer will be put as a inner class of that 
> container, which requires that the start address of it equals to the start 
> address of the mydata, as a result many things can be written in pithy 
> style.
>

That doesn't explain why the container needs to have `mydata` and `Packer` 
be at the same address. Indeed, I don't understand why the container *cares 
at all* about the binary layout of this object. But even if it did, you 
said it yourself: `Packer` is an inner class of the container. It's an 
implementation detail of the container. So it knows good and well what it 
contains.

If you have some "Allocated_C1_ptr" and you want a pointer to `mydata`, you 
should use the obvious:

C1 *ptr_mydata = &Allocated_C1_ptr->mydata;

Oh right, you expressly forbid getting a pointer to the object in the *normal 
C++ way*. So:

C1 *ptr_mydata = std::address_of(Allocated_C1_ptr->mydata);

Wasn't forbidding the use of `operator&` so useful? It kept me from getting 
an address for *the entire second* that it took me to type 
`std::address_of`. That was time well spent. </sarcasm>

My point is that your pointer fiddling here seems to serve no purpose. Your 
example is exceedingly contrived. It relies on pointlessly forbidding me 
from getting a pointer to an object. It also falls apart the moment someone 
remembers that `std::address_of` exists.

Please find an example that looks like reasonable C++ code.

Without the standarized supporting it can still be applied but also 
> complicated with unnecessary performance losts, Something like:
>  ptr_Packer = (Packer *)((byte *)Allocated_C1_ptr - offsetof(Packer, 
> mydata)); 
>
realy?? no, there is strong reason that the offsetof(Packer, mydata) be 
> zero. and much worse, once a compiler decided to use the hidden extended 
> bytes betweens the entry of Packer and address of mydata to do something, 
> that formal won't work correctly. But since the Packer itself is not a 
> polymorphism class: no base, no virtual function, and a class' 
> local-resources (not including static and global res.) shall never expand 
> outside of itself (or the sizeof operator would yield a ill result), It 
> seems no reason to do that by any compiler(the hidden bytes for alignment 
> both between two data members and after the last data member is still 
> allowed)? Or you can tell me more about if there is ...
>
> Another sample:
>
> class C2
> {
> private:
>     SomeClass data;
>
> public:
>     C2(void);
>
>     operator ExpandedInterf & (void);
>     operator const ExpandedInterf & (void) const;
>
>     // ... // some extended functions to handle data at here.
>
> private:
>     C2(const C2 &);               // disabled copy-construct.
>     C2 & operator = (const C2 &); // disabled copy-assignment.
>     static void * operator new (size_t);
>     static void operator delete (void *);// deleting C1 with pointer of 
> C1 or the inheritance is not allowed.
>     static void * operator new [] (size_t);
>     static void operator delete [] (void *);// deleting C1 with pointer 
> of C1 or the inheritance is not allowed.
>     template < typename _ty >
>     operator _ty & (void) const;  // disabled generic (means without 
> using 'reinterpret_case') convertions.
>     C2 * operator & (void) const; // Get the address of C1 object is not 
> allowed.
> };
>
> Here is the 'ExpandedInterf' looks like:
>
> class ExpandedInterf
> {
> private:
>     SomeClass mappeddata;
>
> public:
>     // ... // Constructors & destructors & some extended functions to 
> handle mappeddata at here.
> };
>
> You may tell 'you can use the pointer/pointer class in ExpandedInterf 
> ...'. First, it's slower than direct-mapping; Second, using those kind of 
> way will lead the lifetime of the ExpandedInterf and C2 being different. 
> It's also not pithy enough.
>

It's not clear at all what the relationship between these two classes are, 
besides the fact that you have this incredibly dubious notion of returning 
a *reference* from a conversion operator rather than a value. What exactly 
are these conversion operators doing? And how does it make sense to return 
a reference rather than a value? Are you trying to do some nonsense like 
this:

operator ExpandedInterf & (void)
{
  return *reinterpret_cast<ExpandedInterf*>(std::address_of(this->data));
}

Because that's seriously horrible code. If you want `ExpandedInterf` to 
share ownership of `SomeClass`, you use a *pointer*, not a horrible 
`reinterpret_cast`. At least there, the ownership semantics and 
relationships are explicit rather than implicit (and terribly broken, mind 
you).

Give me an example of using this functionality that *isn't* laden with 
`reinterpret_cast` usage. Remember: `reinterpret_cast` is something you, 
generally, speaking, *shouldn't be using*. Indeed, it seems to me that 
everything you want this for are things you shouldn't be doing in the first 
place. Low-level, horrible, and fundamentally bad ideas.

Also, this is the second time you've used the word "pithy". I don't know 
what you mean by this, and Google isn't helping.

-- 

--- 
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/?hl=en.



------=_Part_4353_29143114.1368064902805
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On Wednesday, May 8, 2013 10:04:04 AM UTC-7, unituni...@gmail.com wrote:<bl=
ockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border=
-left: 1px #ccc solid;padding-left: 1ex;"><div>Because it can be used at ma=
ny places to enhance both the performance and readability.</div><div><br></=
div><div>1.Assuming we have a class C1:</div><div><font color=3D"#0000ff">c=
lass</font> <font color=3D"#3d85c6">C1</font></div><div>{</div><div><font c=
olor=3D"#0000ff">private</font>:</div><div>&nbsp; &nbsp; <font color=3D"#00=
00ff">int</font> <font color=3D"#666666">a</font>;</div><div><br></div><div=
><font color=3D"#0000ff">public</font>:</div><div>&nbsp; &nbsp; C1(<font co=
lor=3D"#0000ff">void</font>);</div><div>&nbsp; &nbsp; C1(<font color=3D"#00=
00ff">int </font><font color=3D"#666666">var1</font>, <font color=3D"#0000f=
f">float </font><font color=3D"#666666">var2</font>);</div><div><br></div><=
div><font color=3D"#0000ff">private</font>:</div><div>&nbsp; &nbsp; C1(<fon=
t color=3D"#0000ff">const </font><font color=3D"#3d85c6">C1 </font>&amp;); =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <font color=3D"#6aa84f">//=
 disabled copy-construct.</font></div><div>&nbsp; &nbsp; <font color=3D"#3d=
85c6">C1 </font>&amp; <font color=3D"#0000ff">operator </font>=3D (<font co=
lor=3D"#0000ff">const </font><font color=3D"#3d85c6">C1 </font>&amp;); <fon=
t color=3D"#6aa84f">// disabled copy-assignment.</font></div><div>&nbsp; &n=
bsp; <font color=3D"#0000ff">static void </font><font color=3D"#000000">*</=
font><font color=3D"#0000ff"> operator new</font> (<font color=3D"#0000ff">=
size_t</font>);</div><div>&nbsp; &nbsp; <font color=3D"#0000ff">static void=
 operator delete</font> (<font color=3D"#0000ff">void </font>*);<font color=
=3D"#6aa84f">// deleting C1 with pointer of C1 or the inheritance is not al=
lowed.</font></div><div>&nbsp; &nbsp; <font color=3D"#0000ff">static void</=
font> * <font color=3D"#0000ff">operator new</font> [] (<font color=3D"#000=
0ff">size_t</font>);</div><div>&nbsp; &nbsp; <font color=3D"#0000ff">static=
 void operator delete</font> [] (<font color=3D"#0000ff">void </font>*);<fo=
nt color=3D"#6aa84f">// deleting C1 with pointer of C1 or the inheritance i=
s not allowed.</font></div><div>&nbsp; &nbsp; <font color=3D"#0000ff">templ=
ate </font>&lt; <font color=3D"#0000ff">typename </font><font color=3D"#3d8=
5c6">_ty </font>&gt;</div><div>&nbsp; &nbsp; <font color=3D"#0000ff">operat=
or </font><font color=3D"#3d85c6">_ty </font>&amp; (<font color=3D"#0000ff"=
>void</font>) <font color=3D"#0000ff">const</font>; &nbsp;<font color=3D"#6=
aa84f">// disabled generic (means without using 'reinterpret_case') convert=
ions.</font></div><div>&nbsp; &nbsp; <font color=3D"#3d85c6">C1 </font>* <f=
ont color=3D"#0000ff">operator </font>&amp; (<font color=3D"#0000ff">void</=
font>) <font color=3D"#0000ff">const</font>; <font color=3D"#6aa84f">// Get=
 the address of C1 object is not allowed.</font></div><div>};<br></div></bl=
ockquote><div><br>This is some of the worst C++ code I've ever seen. That's=
 an impressive feat, since it's just a class declaration.<br><br>I could im=
agine that there's a reason why you need to forbid heap allocation for some=
 type. I can't think of one off the top of my head, but I'm sure there's a =
reason. But there is <i>absolutely no reason</i> to forbid implicit convers=
ions. Unless you specify a specific implicit conversion... you can't do any=
 implicit conversions. They're already forbidden; <i>double</i> forbidding =
them is just silly.<br><br>And there is <i>absolutely no reason</i> to forb=
id getting the address of the object. If I want to get the address of a typ=
e, that's my business, not yours. Not to mention, I can undo all of this ef=
fort just by using `std::address_of`.<br><br>It seems to me that your probl=
em is not with C++. It's that you're writing garbage C++ code and want it t=
o work.<br>&nbsp;</div><blockquote class=3D"gmail_quote" style=3D"margin: 0=
;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div></=
div><div>Now we need a class to let it begin handled by a container and, ho=
wever, the container only allowed to provided at most one, at least none ar=
gument to initialize the object. Finally let the object can be work in this=
 way:</div><div><br></div><div><br></div><div><font color=3D"#0000ff">struc=
t </font><font color=3D"#3d85c6">Packer </font><font color=3D"#6aa84f">// I=
t should have been a template, for explanation i used a non-template class =
instead.</font></div><div>{</div><div>&nbsp; &nbsp; <font color=3D"#3d85c6"=
>C1 </font><font color=3D"#666666">mydata</font>;</div><div><br></div><div>=
&nbsp; &nbsp; Packer(<span style=3D"background-color:rgb(255,255,255)"><fon=
t color=3D"#0000ff">void</font></span>) {}; <font color=3D"#6aa84f">// Call=
ing the default-constuctor of object mydata.</font></div><div><br></div><di=
v>&nbsp; &nbsp; Packer(<font color=3D"#3d85c6">ArgLists</font>&lt;<font col=
or=3D"#0000ff">int</font>,<font color=3D"#0000ff">float</font>&gt; <font co=
lor=3D"#666666">args</font>) <font color=3D"#6aa84f">// The container suppo=
rt at most one argument. So we use ArgLists.</font></div><div>&nbsp; &nbsp;=
 &nbsp; &nbsp; : <font color=3D"#666666">mydata</font>(<font color=3D"#6666=
66">args</font>.get&lt;<font color=3D"#666666">0</font>&gt;(), <font color=
=3D"#666666">args</font>.get&lt;<font color=3D"#666666">1</font>&gt;())</di=
v><div>&nbsp; &nbsp; {};</div><div>};</div><div><br></div><div>Here is the =
request: The Packer will be put as a inner class of that container, which r=
equires that the start address of it equals to the start address of the myd=
ata, as a result many things can be written in pithy style.</div></blockquo=
te><div><br>That doesn't explain why the container needs to have `mydata` a=
nd `Packer` be at the same address. Indeed, I don't understand why the cont=
ainer <i>cares at all</i> about the binary layout of this object. But even =
if it did, you said it yourself: `Packer` is an inner class of the containe=
r. It's an implementation detail of the container. So it knows good and wel=
l what it contains.<br><br>If you have some "Allocated_C1_ptr" and you want=
 a pointer to `mydata`, you should use the obvious:<br><br><div class=3D"pr=
ettyprint" style=3D"background-color: rgb(250, 250, 250); border-color: rgb=
(187, 187, 187); border-style: solid; border-width: 1px; word-wrap: break-w=
ord;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=
=3D"color: #000;" class=3D"styled-by-prettify">C1 </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">*</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">ptr_mydata </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">&amp;</span><span style=3D"color: #606;" class=3D"styled-by=
-prettify">Allocated_C1_ptr</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">-&gt;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">mydata</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br></span></div></code></div><br>Oh right, you expressly forbid getting a p=
ointer to the object in the <b><i>normal C++ way</i></b>. So:<br><br><div c=
lass=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border-=
color: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wra=
p: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><=
span style=3D"color: #000;" class=3D"styled-by-prettify">C1 </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">*</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">ptr_mydata </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">address_of</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">(</span><span style=3D"color: #606;" class=3D"styled-b=
y-prettify">Allocated_C1_ptr</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">-&gt;</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify">mydata</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">);</span></div></code></div><br>Wasn't forbidding the use of `oper=
ator&amp;` so useful? It kept me from getting an address for <i>the entire =
second</i> that it took me to type `std::address_of`. That was time well sp=
ent. &lt;/sarcasm&gt;<br><br>My point is that your pointer fiddling here se=
ems to serve no purpose. Your example is exceedingly contrived. It relies o=
n pointlessly forbidding me from getting a pointer to an object. It also fa=
lls apart the moment someone remembers that `std::address_of` exists.<br><b=
r>Please find an example that looks like reasonable C++ code.<br><br></div>=
<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bor=
der-left: 1px #ccc solid;padding-left: 1ex;"><div> Without the standarized =
supporting it can still be applied but also complicated with unnecessary pe=
rformance losts, Something like:</div><div>&nbsp;ptr_Packer =3D (Packer *)(=
(byte *)Allocated_C1_ptr - offsetof(Packer, mydata));&nbsp;</div></blockquo=
te><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;=
border-left: 1px #ccc solid;padding-left: 1ex;"><div>realy?? no, there is s=
trong reason that the offsetof(Packer, mydata) be zero. and much worse, onc=
e a compiler decided to use the hidden extended bytes betweens the entry of=
 Packer and address of mydata to do something, that formal won't work corre=
ctly. But since the Packer itself is not a polymorphism class: no base, no =
virtual function, and a class' local-resources (not including static and gl=
obal res.) shall never expand outside of itself (or the sizeof operator wou=
ld yield a ill result), It seems no reason to do that by any compiler(the h=
idden bytes for alignment both between two data members and after the last =
data member is still allowed)? Or you can tell me more about if there is ..=
..</div><div><br></div><div>Another sample:</div><div><br></div><div><font c=
olor=3D"#0000ff">class </font><font color=3D"#3d85c6">C2</font></div><div>{=
</div><div><font color=3D"#0000ff">private</font>:</div><div>&nbsp; &nbsp; =
<font color=3D"#3d85c6">SomeClass </font><font color=3D"#666666">data</font=
>;</div><div><br></div><div><font color=3D"#0000ff">public</font>:</div><di=
v>&nbsp; &nbsp; C2(<font color=3D"#0000ff">void</font>);</div><div><br></di=
v><div>&nbsp; &nbsp; <font color=3D"#0000ff">operator </font><font color=3D=
"#3d85c6">ExpandedInterf </font>&amp; (<font color=3D"#0000ff">void</font>)=
;</div><div>&nbsp; &nbsp; <font color=3D"#0000ff">operator const</font> <fo=
nt color=3D"#3d85c6">ExpandedInterf </font>&amp; (<font color=3D"#0000ff">v=
oid</font>) <font color=3D"#0000ff">const</font>;</div><div><br></div><div>=
<span style=3D"color:rgb(106,168,79)">&nbsp; &nbsp; // ... // some extended=
 functions to handle data at here.</span><br></div><div><br></div><div><fon=
t color=3D"#0000ff">private</font>:</div><div>&nbsp; &nbsp; C2(<font color=
=3D"#0000ff">const </font><font color=3D"#3d85c6">C2 </font>&amp;); &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <font color=3D"#6aa84f">// disabl=
ed copy-construct.</font></div><div>&nbsp; &nbsp; <font color=3D"#3d85c6">C=
2 </font>&amp; <font color=3D"#0000ff">operator </font>=3D (<font color=3D"=
#0000ff">const </font><font color=3D"#3d85c6">C2 </font>&amp;); <font color=
=3D"#6aa84f">// disabled copy-assignment.</font></div><div>&nbsp; &nbsp; <f=
ont color=3D"#0000ff">static void </font><font color=3D"#000000">* </font><=
font color=3D"#0000ff">operator new</font> (<font color=3D"#0000ff">size_t<=
/font>);</div><div>&nbsp; &nbsp; <font color=3D"#0000ff">static void operat=
or delete</font> (<font color=3D"#0000ff">void </font>*);<font color=3D"#6a=
a84f">// deleting C1 with pointer of C1 or the inheritance is not allowed.<=
/font></div><div>&nbsp; &nbsp; <font color=3D"#0000ff">static void </font><=
font color=3D"#000000">* </font><font color=3D"#0000ff">operator new</font>=
 [] (<font color=3D"#0000ff">size_t</font>);</div><div>&nbsp; &nbsp; <font =
color=3D"#0000ff">static void operator delete</font> [] (<font color=3D"#00=
00ff">void </font>*);<font color=3D"#6aa84f">// deleting C1 with pointer of=
 C1 or the inheritance is not allowed.</font></div><div>&nbsp; &nbsp; <font=
 color=3D"#0000ff">template </font>&lt; <font color=3D"#0000ff">typename </=
font><font color=3D"#3d85c6">_ty </font>&gt;</div><div>&nbsp; &nbsp; <font =
color=3D"#0000ff">operator </font><font color=3D"#3d85c6">_ty </font>&amp; =
(<font color=3D"#0000ff">void</font>) <font color=3D"#0000ff">const</font>;=
 <font color=3D"#6aa84f">&nbsp;// disabled generic (means without using 're=
interpret_case') convertions.</font></div><div>&nbsp; &nbsp; <font color=3D=
"#3d85c6">C2 </font>* <font color=3D"#0000ff">operator </font>&amp; (<font =
color=3D"#0000ff">void</font>) <font color=3D"#0000ff">const</font>; <font =
color=3D"#6aa84f">// Get the address of C1 object is not allowed.</font></d=
iv><div>};</div><div><br></div><div>Here is the 'ExpandedInterf' looks like=
:</div><div><br></div><div><font color=3D"#0000ff">class </font><font color=
=3D"#3d85c6">ExpandedInterf</font></div><div>{</div><div><span style=3D"bac=
kground-color:rgb(255,255,255)"><font color=3D"#0000ff">private</font></spa=
n>:</div><div>&nbsp; &nbsp; <font color=3D"#3d85c6">SomeClass </font><font =
color=3D"#666666">mappeddata</font>;</div><div><br></div><div><font color=
=3D"#0000ff">public</font>:</div><div>&nbsp; &nbsp; <font color=3D"#6aa84f"=
>// ... // Constructors &amp; destructors &amp; some extended functions to =
handle mappeddata at here.</font></div><div>};</div><div><br></div><div>You=
 may tell 'you can use the pointer/pointer class in ExpandedInterf ...'. Fi=
rst, it's slower than direct-mapping; Second, using those kind of way will =
lead the lifetime of the ExpandedInterf and C2 being different. It's also n=
ot pithy enough.</div></blockquote><div><br>It's not clear at all what the =
relationship between these two classes are, besides the fact that you have =
this incredibly dubious notion of returning a <i>reference</i> from a conve=
rsion operator rather than a value. What exactly are these conversion opera=
tors doing? And how does it make sense to return a reference rather than a =
value? Are you trying to do some nonsense like this:<br><br><div class=3D"p=
rettyprint" style=3D"background-color: rgb(250, 250, 250); border-color: rg=
b(187, 187, 187); border-style: solid; border-width: 1px; word-wrap: break-=
word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">operator</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #606;" class=3D"styled-by-prettify">ExpandedInterf</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">&amp;</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">void</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; </span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">return</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">*</span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">reinterpret_cast</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #6=
06;" class=3D"styled-by-prettify">ExpandedInterf</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">*&gt;(</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify">std</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">address_of</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">this</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">-&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify">d=
ata</span><span style=3D"color: #660;" class=3D"styled-by-prettify">));</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div></code></di=
v><br>Because that's seriously horrible code. If you want `ExpandedInterf` =
to share ownership of `SomeClass`, you use a <i>pointer</i>, not a horrible=
 `reinterpret_cast`. At least there, the ownership semantics and relationsh=
ips are explicit rather than implicit (and terribly broken, mind you).<br><=
br>Give me an example of using this functionality that <i>isn't</i> laden w=
ith `reinterpret_cast` usage. Remember: `reinterpret_cast` is something you=
, generally, speaking, <i>shouldn't be using</i>. Indeed, it seems to me th=
at everything you want this for are things you shouldn't be doing in the fi=
rst place. Low-level, horrible, and fundamentally bad ideas.<br><br>Also, t=
his is the second time you've used the word "pithy". I don't know what you =
mean by this, and Google isn't helping.<br></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_4353_29143114.1368064902805--

.
