Topic: So why can't we have a forward-declared entities


Author: vityatheboss@gmail.com
Date: Wed, 1 Jul 2015 07:53:07 -0700 (PDT)
Raw View
------=_Part_2035_2064038697.1435762387800
Content-Type: multipart/alternative;
 boundary="----=_Part_2036_1995030488.1435762387800"

------=_Part_2036_1995030488.1435762387800
Content-Type: text/plain; charset=UTF-8

The problem is known for anyone: nested entities can not be forward
declared. Latest C++14 standard did not make any step in solving this.

Suppose we are writing a program about cars. In code we are creating few
namespaces and other OOP-entities. So, let's see our *car.h* file:

namespace application {
    class Car : public Drawable {
    public:
        struct Tire {
            float pressure;
        };

        void draw() final override;
    }
} // application



Suppose we have some implementation in *car.cpp* file and we are going to
use this Car class in our code:

some *.h*-file:

class Car;
struct Car::Tire; // illegal, won't compile
namespace application {
    class User {
    public:
        void addTire(const Car::Tire& tire);    // wrong, because we did
not forward declare this struct correctly (here are no any methods actually)
    };
} // application


Very-very simple piece of code. It shows how the problem can be reproduced.
So, we can't *Car*'s users operate with nested structure *Tire* we can't
use Tire because it can't be forward declared. I can't think up any reason
for that.

Some people would say: use namespace, unnest the structure. *But this is
not correct!*
Why should I break semantic link between OOP-entities (*Tire* is absolutely
should be in the *Car* but of course it can be changed: by more cars, tire
modifications, a lot of reasons, just I don't want to waste our time to
explain this obvious thing). Yes, you may find exactly this example not
correct or something else but I have a lot of code which should be done
like this. I don't want to make useless tree of namespaces. Also, why do we
have a possibility to use nested classes then? I mean, I do know why but in
cases like this it deprives us from forward declare it.

P.S. Unfortunately, I did not find anything about that here yet.

--

---
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/.

------=_Part_2036_1995030488.1435762387800
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">The problem is known for anyone: nested entities can not b=
e forward declared. Latest C++14 standard did not make any step in solving =
this.<br><br>Suppose we are writing a program about cars. In code we are cr=
eating few namespaces and other OOP-entities. So, let's see our <b>car.h</b=
> file:<br><br><div class=3D"prettyprint" style=3D"background-color: rgb(25=
0, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; border=
-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div class=
=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">namespace</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> application </span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">class</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #606;" class=3D"styled-by-prettify">Car</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">public</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"st=
yled-by-prettify">Drawable</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">public</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nb=
sp; &nbsp; &nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">struct</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify=
">Tire</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbs=
p; &nbsp; &nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled=
-by-prettify">float</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> pressure</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">};</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">void</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> draw</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">()</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">final</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">ove=
rride</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nb=
sp; </span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #800;" class=3D"styled-by-prettify">// application</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br></span></div></code></div><br=
><br><br>Suppose we have some implementation in <b>car.cpp</b> file and we =
are going to use this Car class in our code:<br><br>some <b>.h</b>-file:<br=
><br><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 25=
0); border-color: rgb(187, 187, 187); border-style: solid; border-width: 1p=
x; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subpre=
ttyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">class</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #606;" class=3D"styled-by-prettify">Car</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">struct</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"s=
tyled-by-prettify">Car</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">::</span><span style=3D"color: #606;" class=3D"styled-by-pretti=
fy">Tire</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #800;" class=3D"styled-by-prettify">// illegal, won't co=
mpile</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">namespace</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> application=
 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; =
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">class</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #606;" class=3D"styled-by-prettify">User</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: #000;" =
class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color:=
 #008;" class=3D"styled-by-prettify">public</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">void</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> addTire</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;"=
 class=3D"styled-by-prettify">const</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styl=
ed-by-prettify">Car</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">::</span><span style=3D"color: #606;" class=3D"styled-by-prettify"=
>Tire</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> tire</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> &nbsp; &nbsp;</span><s=
pan style=3D"color: #800;" class=3D"styled-by-prettify">// wrong, because w=
e did not forward declare this struct correctly (here are no any methods ac=
tually)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
>&nbsp; &nbsp; </span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">};</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
></span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #800;" class=3D"styled-by-prettify">// application</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div></code=
></div><br><br>Very-very simple piece of code. It shows how the problem can=
 be reproduced.<br>So, we can't <b>Car</b>'s users operate with nested stru=
cture <b>Tire</b> we can't use Tire because it can't be forward declared. I=
 can't think up any reason for that.<br><br>Some people would say: use name=
space, unnest the structure. <u><b><i>But this is not correct!</i></b></u><=
br>Why should I break semantic link between OOP-entities (<b>Tire</b> is ab=
solutely should be in the <b>Car</b> but of course it can be changed: by mo=
re cars, tire modifications, a lot of reasons, just I don't want to waste o=
ur time to explain this obvious thing). Yes, you may find exactly this exam=
ple not correct or something else but I have a lot of code which should be =
done like this. I don't want to make useless tree of namespaces. Also, why =
do we have a possibility to use nested classes then? I mean, I do know why =
but in cases like this it deprives us from forward declare it.<br><br>P.S. =
Unfortunately, I did not find anything about that here yet.<br></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 />

------=_Part_2036_1995030488.1435762387800--
------=_Part_2035_2064038697.1435762387800--

.


Author: =?UTF-8?Q?David_Rodr=C3=ADguez_Ibeas?= <dibeas@ieee.org>
Date: Wed, 1 Jul 2015 16:07:08 +0100
Raw View
--001a11c2b61639e33d0519d1adac
Content-Type: text/plain; charset=UTF-8

Forward declaring a member is really partially defining the class.  What's
wrong with including the definition of the class if you are going to use
it's internals (typedef)?

    David

On Wed, Jul 1, 2015 at 3:53 PM, <vityatheboss@gmail.com> wrote:

> The problem is known for anyone: nested entities can not be forward
> declared. Latest C++14 standard did not make any step in solving this.
>
> Suppose we are writing a program about cars. In code we are creating few
> namespaces and other OOP-entities. So, let's see our *car.h* file:
>
> namespace application {
>     class Car : public Drawable {
>     public:
>         struct Tire {
>             float pressure;
>         };
>
>         void draw() final override;
>     }
> } // application
>
>
>
> Suppose we have some implementation in *car.cpp* file and we are going to
> use this Car class in our code:
>
> some *.h*-file:
>
> class Car;
> struct Car::Tire; // illegal, won't compile
> namespace application {
>     class User {
>     public:
>         void addTire(const Car::Tire& tire);    // wrong, because we did
> not forward declare this struct correctly (here are no any methods actually)
>     };
> } // application
>
>
> Very-very simple piece of code. It shows how the problem can be reproduced.
> So, we can't *Car*'s users operate with nested structure *Tire* we can't
> use Tire because it can't be forward declared. I can't think up any reason
> for that.
>
> Some people would say: use namespace, unnest the structure. *But this is
> not correct!*
> Why should I break semantic link between OOP-entities (*Tire* is
> absolutely should be in the *Car* but of course it can be changed: by
> more cars, tire modifications, a lot of reasons, just I don't want to waste
> our time to explain this obvious thing). Yes, you may find exactly this
> example not correct or something else but I have a lot of code which should
> be done like this. I don't want to make useless tree of namespaces. Also,
> why do we have a possibility to use nested classes then? I mean, I do know
> why but in cases like this it deprives us from forward declare it.
>
> P.S. Unfortunately, I did not find anything about that here yet.
>
> --
>
> ---
> 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/.
>

--

---
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/.

--001a11c2b61639e33d0519d1adac
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Forward declaring a member is really partially defining th=
e class.=C2=A0 What&#39;s wrong with including the definition of the class =
if you are going to use it&#39;s internals (typedef)?<br><br>=C2=A0 =C2=A0 =
David</div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Wed=
, Jul 1, 2015 at 3:53 PM,  <span dir=3D"ltr">&lt;<a href=3D"mailto:vityathe=
boss@gmail.com" target=3D"_blank">vityatheboss@gmail.com</a>&gt;</span> wro=
te:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-=
left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">The problem is known=
 for anyone: nested entities can not be forward declared. Latest C++14 stan=
dard did not make any step in solving this.<br><br>Suppose we are writing a=
 program about cars. In code we are creating few namespaces and other OOP-e=
ntities. So, let&#39;s see our <b>car.h</b> file:<br><br><div style=3D"back=
ground-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:so=
lid;border-width:1px;word-wrap:break-word"><code><div><span style=3D"color:=
#008">namespace</span><span style=3D"color:#000"> application </span><span =
style=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 <=
/span><span style=3D"color:#008">class</span><span style=3D"color:#000"> </=
span><span style=3D"color:#606">Car</span><span style=3D"color:#000"> </spa=
n><span style=3D"color:#660">:</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#008">public</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#606">Drawable</span><span style=3D"color:#000"> </span><=
span style=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=
=A0 </span><span style=3D"color:#008">public</span><span style=3D"color:#66=
0">:</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </spa=
n><span style=3D"color:#008">struct</span><span style=3D"color:#000"> </spa=
n><span style=3D"color:#606">Tire</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:#008">float<=
/span><span style=3D"color:#000"> pressure</span><span style=3D"color:#660"=
>;</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </span>=
<span style=3D"color:#660">};</span><span style=3D"color:#000"><br><br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 </span><span style=3D"color:#008">void</span><span=
 style=3D"color:#000"> draw</span><span style=3D"color:#660">()</span><span=
 style=3D"color:#000"> </span><span style=3D"color:#008">final</span><span =
style=3D"color:#000"> </span><span style=3D"color:#008">override</span><spa=
n style=3D"color:#660">;</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0=
 </span><span style=3D"color:#660">}</span><span style=3D"color:#000"><br><=
/span><span style=3D"color:#660">}</span><span style=3D"color:#000"> </span=
><span style=3D"color:#800">// application</span><span style=3D"color:#000"=
><br></span></div></code></div><br><br><br>Suppose we have some implementat=
ion in <b>car.cpp</b> file and we are going to use this Car class in our co=
de:<br><br>some <b>.h</b>-file:<br><br><div style=3D"background-color:rgb(2=
50,250,250);border-color:rgb(187,187,187);border-style:solid;border-width:1=
px;word-wrap:break-word"><code><div><span style=3D"color:#008">class</span>=
<span style=3D"color:#000"> </span><span style=3D"color:#606">Car</span><sp=
an style=3D"color:#660">;</span><span style=3D"color:#000"><br></span><span=
 style=3D"color:#008">struct</span><span style=3D"color:#000"> </span><span=
 style=3D"color:#606">Car</span><span style=3D"color:#660">::</span><span s=
tyle=3D"color:#606">Tire</span><span style=3D"color:#660">;</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#800">// illegal, won&#39;t =
compile</span><span style=3D"color:#000"><br></span><span style=3D"color:#0=
08">namespace</span><span style=3D"color:#000"> application </span><span st=
yle=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </s=
pan><span style=3D"color:#008">class</span><span style=3D"color:#000"> </sp=
an><span style=3D"color:#606">User</span><span style=3D"color:#000"> </span=
><span style=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =
=C2=A0 </span><span style=3D"color:#008">public</span><span style=3D"color:=
#660">:</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 </=
span><span style=3D"color:#008">void</span><span style=3D"color:#000"> addT=
ire</span><span style=3D"color:#660">(</span><span style=3D"color:#008">con=
st</span><span style=3D"color:#000"> </span><span style=3D"color:#606">Car<=
/span><span style=3D"color:#660">::</span><span style=3D"color:#606">Tire</=
span><span style=3D"color:#660">&amp;</span><span style=3D"color:#000"> tir=
e</span><span style=3D"color:#660">);</span><span style=3D"color:#000"> =C2=
=A0 =C2=A0</span><span style=3D"color:#800">// wrong, because we did not fo=
rward declare this struct correctly (here are no any methods actually)</spa=
n><span style=3D"color:#000"><br>=C2=A0 =C2=A0 </span><span style=3D"color:=
#660">};</span><span style=3D"color:#000"><br></span><span style=3D"color:#=
660">}</span><span style=3D"color:#000"> </span><span style=3D"color:#800">=
// application</span><span style=3D"color:#000"><br></span></div></code></d=
iv><br><br>Very-very simple piece of code. It shows how the problem can be =
reproduced.<br>So, we can&#39;t <b>Car</b>&#39;s users operate with nested =
structure <b>Tire</b> we can&#39;t use Tire because it can&#39;t be forward=
 declared. I can&#39;t think up any reason for that.<br><br>Some people wou=
ld say: use namespace, unnest the structure. <u><b><i>But this is not corre=
ct!</i></b></u><br>Why should I break semantic link between OOP-entities (<=
b>Tire</b> is absolutely should be in the <b>Car</b> but of course it can b=
e changed: by more cars, tire modifications, a lot of reasons, just I don&#=
39;t want to waste our time to explain this obvious thing). Yes, you may fi=
nd exactly this example not correct or something else but I have a lot of c=
ode which should be done like this. I don&#39;t want to make useless tree o=
f namespaces. Also, why do we have a possibility to use nested classes then=
? I mean, I do know why but in cases like this it deprives us from forward =
declare it.<br><br>P.S. Unfortunately, I did not find anything about that h=
ere yet.<span class=3D"HOEnZb"><font color=3D"#888888"><br></font></span></=
div><span class=3D"HOEnZb"><font color=3D"#888888">

<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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</font></span></blockquote></div><br></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 />

--001a11c2b61639e33d0519d1adac--

.


Author: vityatheboss@gmail.com
Date: Wed, 1 Jul 2015 08:13:16 -0700 (PDT)
Raw View
------=_Part_1971_1347558012.1435763596919
Content-Type: multipart/alternative;
 boundary="----=_Part_1972_1044966422.1435763596920"

------=_Part_1972_1044966422.1435763596920
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Yes, and I guess, that is why we can "forward declare" something inside=20
namespaces - because they are be extensible.
And, I am not going to use the forward declared types fully: with forward=
=20
declarations we may operate only references and pointers. So, in this case,=
=20
we should have an ability at least to have a pointer of type *Car::Tire*=20
somewhere without including the file. But we can not do that.

=D1=81=D1=80=D0=B5=D0=B4=D0=B0, 1 =D0=B8=D1=8E=D0=BB=D1=8F 2015 =D0=B3., 18=
:07:11 UTC+3 =D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=
=D0=BB=D1=8C David Rodr=C3=ADguez Ibeas=20
=D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:
>
> Forward declaring a member is really partially defining the class.  What'=
s=20
> wrong with including the definition of the class if you are going to use=
=20
> it's internals (typedef)?
>
>     David
>
> On Wed, Jul 1, 2015 at 3:53 PM, <vityat...@gmail.com <javascript:>> wrote=
:
>
>> The problem is known for anyone: nested entities can not be forward=20
>> declared. Latest C++14 standard did not make any step in solving this.
>>
>> Suppose we are writing a program about cars. In code we are creating few=
=20
>> namespaces and other OOP-entities. So, let's see our *car.h* file:
>>
>> namespace application {
>>     class Car : public Drawable {
>>     public:
>>         struct Tire {
>>             float pressure;
>>         };
>>
>>         void draw() final override;
>>     }
>> } // application
>>
>>
>>
>> Suppose we have some implementation in *car.cpp* file and we are going=
=20
>> to use this Car class in our code:
>>
>> some *.h*-file:
>>
>> class Car;
>> struct Car::Tire; // illegal, won't compile
>> namespace application {
>>     class User {
>>     public:
>>         void addTire(const Car::Tire& tire);    // wrong, because we did=
=20
>> not forward declare this struct correctly (here are no any methods actua=
lly)
>>     };
>> } // application
>>
>>
>> Very-very simple piece of code. It shows how the problem can be=20
>> reproduced.
>> So, we can't *Car*'s users operate with nested structure *Tire* we can't=
=20
>> use Tire because it can't be forward declared. I can't think up any reas=
on=20
>> for that.
>>
>> Some people would say: use namespace, unnest the structure. *But this is=
=20
>> not correct!*
>> Why should I break semantic link between OOP-entities (*Tire* is=20
>> absolutely should be in the *Car* but of course it can be changed: by=20
>> more cars, tire modifications, a lot of reasons, just I don't want to wa=
ste=20
>> our time to explain this obvious thing). Yes, you may find exactly this=
=20
>> example not correct or something else but I have a lot of code which sho=
uld=20
>> be done like this. I don't want to make useless tree of namespaces. Also=
,=20
>> why do we have a possibility to use nested classes then? I mean, I do kn=
ow=20
>> why but in cases like this it deprives us from forward declare it.
>>
>> P.S. Unfortunately, I did not find anything about that here yet.
>>
>> --=20
>>
>> ---=20
>> You received this message because you are subscribed to the Google Group=
s=20
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n=20
>> email to std-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> Visit this group at=20
>> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>>
>
>

--=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/.

------=_Part_1972_1044966422.1435763596920
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Yes, and I guess, that is why we can "forward declare" som=
ething inside namespaces - because they are be extensible.<br>And, I am not=
 going to use the forward declared types fully: with forward declarations w=
e may operate only references and pointers. So, in this case, we should hav=
e an ability at least to have a pointer of type <b>Car::Tire</b> somewhere =
without including the file. But we can not do that.<br><br>=D1=81=D1=80=D0=
=B5=D0=B4=D0=B0, 1 =D0=B8=D1=8E=D0=BB=D1=8F 2015 =D0=B3., 18:07:11 UTC+3 =
=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5=D0=BB=D1=8C Da=
vid Rodr=C3=ADguez Ibeas =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB:<blockq=
uote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-lef=
t: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">Forward declaring a =
member is really partially defining the class.&nbsp; What's wrong with incl=
uding the definition of the class if you are going to use it's internals (t=
ypedef)?<br><br>&nbsp; &nbsp; David</div><div><br><div class=3D"gmail_quote=
">On Wed, Jul 1, 2015 at 3:53 PM,  <span dir=3D"ltr">&lt;<a href=3D"javascr=
ipt:" target=3D"_blank" gdf-obfuscated-mailto=3D"rRW90xBaszQJ" rel=3D"nofol=
low" onmousedown=3D"this.href=3D'javascript:';return true;" onclick=3D"this=
..href=3D'javascript:';return true;">vityat...@gmail.com</a>&gt;</span> wrot=
e:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-l=
eft:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">The problem is known =
for anyone: nested entities can not be forward declared. Latest C++14 stand=
ard did not make any step in solving this.<br><br>Suppose we are writing a =
program about cars. In code we are creating few namespaces and other OOP-en=
tities. So, let's see our <b>car.h</b> file:<br><br><div style=3D"backgroun=
d-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;b=
order-width:1px;word-wrap:break-word"><code><div><span style=3D"color:#008"=
>namespace</span><span style=3D"color:#000"> application </span><span style=
=3D"color:#660">{</span><span style=3D"color:#000"><br>&nbsp; &nbsp; </span=
><span style=3D"color:#008">class</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#606">Car</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#660">:</span><span style=3D"color:#000"> </span><span st=
yle=3D"color:#008">public</span><span style=3D"color:#000"> </span><span st=
yle=3D"color:#606">Drawable</span><span style=3D"color:#000"> </span><span =
style=3D"color:#660">{</span><span style=3D"color:#000"><br>&nbsp; &nbsp; <=
/span><span style=3D"color:#008">public</span><span style=3D"color:#660">:<=
/span><span style=3D"color:#000"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><sp=
an style=3D"color:#008">struct</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#606">Tire</span><span style=3D"color:#000"> </span><span=
 style=3D"color:#660">{</span><span style=3D"color:#000"><br>&nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; </span><span style=3D"color:#008">float</span><=
span style=3D"color:#000"> pressure</span><span style=3D"color:#660">;</spa=
n><span style=3D"color:#000"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span s=
tyle=3D"color:#660">};</span><span style=3D"color:#000"><br><br>&nbsp; &nbs=
p; &nbsp; &nbsp; </span><span style=3D"color:#008">void</span><span style=
=3D"color:#000"> draw</span><span style=3D"color:#660">()</span><span style=
=3D"color:#000"> </span><span style=3D"color:#008">final</span><span style=
=3D"color:#000"> </span><span style=3D"color:#008">override</span><span sty=
le=3D"color:#660">;</span><span style=3D"color:#000"><br>&nbsp; &nbsp; </sp=
an><span style=3D"color:#660">}</span><span style=3D"color:#000"><br></span=
><span style=3D"color:#660">}</span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#800">// application</span><span style=3D"color:#000"><br>=
</span></div></code></div><br><br><br>Suppose we have some implementation i=
n <b>car.cpp</b> file and we are going to use this Car class in our code:<b=
r><br>some <b>.h</b>-file:<br><br><div style=3D"background-color:rgb(250,25=
0,250);border-color:rgb(187,187,187);border-style:solid;border-width:1px;wo=
rd-wrap:break-word"><code><div><span style=3D"color:#008">class</span><span=
 style=3D"color:#000"> </span><span style=3D"color:#606">Car</span><span st=
yle=3D"color:#660">;</span><span style=3D"color:#000"><br></span><span styl=
e=3D"color:#008">struct</span><span style=3D"color:#000"> </span><span styl=
e=3D"color:#606">Car</span><span style=3D"color:#660">::</span><span style=
=3D"color:#606">Tire</span><span style=3D"color:#660">;</span><span style=
=3D"color:#000"> </span><span style=3D"color:#800">// illegal, won't compil=
e</span><span style=3D"color:#000"><br></span><span style=3D"color:#008">na=
mespace</span><span style=3D"color:#000"> application </span><span style=3D=
"color:#660">{</span><span style=3D"color:#000"><br>&nbsp; &nbsp; </span><s=
pan style=3D"color:#008">class</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#606">User</span><span style=3D"color:#000"> </span><span=
 style=3D"color:#660">{</span><span style=3D"color:#000"><br>&nbsp; &nbsp; =
</span><span style=3D"color:#008">public</span><span style=3D"color:#660">:=
</span><span style=3D"color:#000"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><s=
pan style=3D"color:#008">void</span><span style=3D"color:#000"> addTire</sp=
an><span style=3D"color:#660">(</span><span style=3D"color:#008">const</spa=
n><span style=3D"color:#000"> </span><span style=3D"color:#606">Car</span><=
span style=3D"color:#660">::</span><span style=3D"color:#606">Tire</span><s=
pan style=3D"color:#660">&amp;</span><span style=3D"color:#000"> tire</span=
><span style=3D"color:#660">);</span><span style=3D"color:#000"> &nbsp; &nb=
sp;</span><span style=3D"color:#800">// wrong, because we did not forward d=
eclare this struct correctly (here are no any methods actually)</span><span=
 style=3D"color:#000"><br>&nbsp; &nbsp; </span><span style=3D"color:#660">}=
;</span><span style=3D"color:#000"><br></span><span style=3D"color:#660">}<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#800">// appl=
ication</span><span style=3D"color:#000"><br></span></div></code></div><br>=
<br>Very-very simple piece of code. It shows how the problem can be reprodu=
ced.<br>So, we can't <b>Car</b>'s users operate with nested structure <b>Ti=
re</b> we can't use Tire because it can't be forward declared. I can't thin=
k up any reason for that.<br><br>Some people would say: use namespace, unne=
st the structure. <u><b><i>But this is not correct!</i></b></u><br>Why shou=
ld I break semantic link between OOP-entities (<b>Tire</b> is absolutely sh=
ould be in the <b>Car</b> but of course it can be changed: by more cars, ti=
re modifications, a lot of reasons, just I don't want to waste our time to =
explain this obvious thing). Yes, you may find exactly this example not cor=
rect or something else but I have a lot of code which should be done like t=
his. I don't want to make useless tree of namespaces. Also, why do we have =
a possibility to use nested classes then? I mean, I do know why but in case=
s like this it deprives us from forward declare it.<br><br>P.S. Unfortunate=
ly, I did not find anything about that here yet.<span><font color=3D"#88888=
8"><br></font></span></div><span><font color=3D"#888888">

<p></p>

-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups "=
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"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
rRW90xBaszQJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:';ret=
urn true;" onclick=3D"this.href=3D'javascript:';return true;">std-proposal.=
...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"rRW90xBaszQJ" rel=3D"nofollow" onmousedown=3D"=
this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'javascript:=
';return true;">std-pr...@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=
=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';return true=
;" onclick=3D"this.href=3D'http://groups.google.com/a/isocpp.org/group/std-=
proposals/';return true;">http://groups.google.com/a/<wbr>isocpp.org/group/=
std-<wbr>proposals/</a>.<br>
</font></span></blockquote></div><br></div>
</blockquote></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 />

------=_Part_1972_1044966422.1435763596920--
------=_Part_1971_1347558012.1435763596919--

.


Author: Thiago Macieira <thiago@macieira.org>
Date: Wed, 01 Jul 2015 09:45:09 -0700
Raw View
On Wednesday 01 July 2015 07:53:07 vityatheboss@gmail.com wrote:
> some *.h*-file:
>
> class Car;
> struct Car::Tire; // illegal, won't compile
> namespace application {
>     class User {
>     public:
>         void addTire(const Car::Tire& tire);    // wrong, because we did
> not forward declare this struct correctly (here are no any methods actually)
> };
> } // application

That would allow you to access a private nested class. Suppose the Car class
of your example were:

class Car
{
 struct Tire { float pressure; };
 Tire tires[5];
public:
 void setTirePressure(int idx, float p) { tires[idx].pressure = p; }
};

--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

--

---
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/.

.


Author: hun.nemethpeter@gmail.com
Date: Wed, 1 Jul 2015 13:40:04 -0700 (PDT)
Raw View
------=_Part_2530_1137207498.1435783204702
Content-Type: multipart/alternative;
 boundary="----=_Part_2531_441960586.1435783204702"

------=_Part_2531_441960586.1435783204702
Content-Type: text/plain; charset=UTF-8



At least you can forward declare it inside the class, so the following is
working:


namespace application {
    class Drawable {
      virtual void draw();
    };
    class Car : public Drawable {
    public:
        struct Tire; // forward declare

        void draw() final override;
    };

    // declare it outside of Car
    struct Car::Tire {
      float pressure;
    };
} // application



Maybe you can make an almost empty CarBase with

    class CarBase {
    public:
        struct Tire;
    };


and later


class Car : public Drawable,
            public CarBase {
....


But why do you want forward declare it instead of include the Car itself
before User?

Peter


On Wednesday, July 1, 2015 at 4:53:07 PM UTC+2, vityat...@gmail.com wrote:
>
> The problem is known for anyone: nested entities can not be forward
> declared. Latest C++14 standard did not make any step in solving this.
>
> Suppose we are writing a program about cars. In code we are creating few
> namespaces and other OOP-entities. So, let's see our *car.h* file:
>
> namespace application {
>     class Car : public Drawable {
>     public:
>         struct Tire {
>             float pressure;
>         };
>
>         void draw() final override;
>     }
> } // application
>
>
>
> Suppose we have some implementation in *car.cpp* file and we are going to
> use this Car class in our code:
>
> some *.h*-file:
>
> class Car;
> struct Car::Tire; // illegal, won't compile
> namespace application {
>     class User {
>     public:
>         void addTire(const Car::Tire& tire);    // wrong, because we did
> not forward declare this struct correctly (here are no any methods actually)
>     };
> } // application
>
>
> Very-very simple piece of code. It shows how the problem can be reproduced.
> So, we can't *Car*'s users operate with nested structure *Tire* we can't
> use Tire because it can't be forward declared. I can't think up any reason
> for that.
>
> Some people would say: use namespace, unnest the structure. *But this is
> not correct!*
> Why should I break semantic link between OOP-entities (*Tire* is
> absolutely should be in the *Car* but of course it can be changed: by
> more cars, tire modifications, a lot of reasons, just I don't want to waste
> our time to explain this obvious thing). Yes, you may find exactly this
> example not correct or something else but I have a lot of code which should
> be done like this. I don't want to make useless tree of namespaces. Also,
> why do we have a possibility to use nested classes then? I mean, I do know
> why but in cases like this it deprives us from forward declare it.
>
> P.S. Unfortunately, I did not find anything about that here yet.
>

--

---
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/.

------=_Part_2531_441960586.1435783204702
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>At least you can forward declare it inside the cla=
ss, so the following is working:<br><br><br><div class=3D"prettyprint" styl=
e=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187)=
; border-style: solid; border-width: 1px; word-wrap: break-word;"><code cla=
ss=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008=
;" class=3D"styled-by-prettify">namespace</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> application </span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">class</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"s=
tyled-by-prettify">Drawable</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br>&nbsp; &nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled=
-by-prettify">virtual</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">void</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> dra=
w</span><span style=3D"color: #660;" class=3D"styled-by-prettify">();</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp=
; </span><span style=3D"color: #660;" class=3D"styled-by-prettify">};</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp=
; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">class</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
 style=3D"color: #606;" class=3D"styled-by-prettify">Car</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: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">public</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-pre=
ttify">Drawable</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &n=
bsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">publi=
c</span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; =
&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">struct</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Tire</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"c=
olor: #800;" class=3D"styled-by-prettify">// forward declare</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br><br>&nbsp; &nbsp; &nb=
sp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>void</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> draw=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">final</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">override</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">};</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br><br>&nbsp; &nbsp; </span><span style=3D"color: =
#800;" class=3D"styled-by-prettify">// declare it outside of Car</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">struct</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #606;" class=3D"styled-by-prettify">Car</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: #6=
06;" class=3D"styled-by-prettify">Tire</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: #000;" class=3D"styled-by-=
prettify"><br>&nbsp; &nbsp; &nbsp; </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">float</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> pressure</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">};</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #800;" class=3D"styled-by-prettify">// application=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></=
span></div></code></div><br><br>Maybe you can make an almost empty CarBase =
with<br><br><div class=3D"prettyprint" style=3D"background-color: rgb(250, =
250, 250); border-color: rgb(187, 187, 187); border-style: solid; border-wi=
dth: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D=
"subprettyprint"><span style=3D"color: #000;" class=3D"styled-by-prettify">=
&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">class</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #606;" class=3D"styled-by-prettify">CarBase</s=
pan><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: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span =
style=3D"color: #008;" class=3D"styled-by-prettify">public</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp; &nbsp; </sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">struct</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #606;" class=3D"styled-by-prettify">Tire</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">};</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br><br></span></div></code></div><br>and =
later<br><br><br><div class=3D"prettyprint" style=3D"background-color: rgb(=
250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; bord=
er-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div cla=
ss=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">class</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Car</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">:</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">public</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"s=
tyled-by-prettify">Drawable</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">public</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #606;=
" class=3D"styled-by-prettify">CarBase</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: #000;" class=3D"styled-by-=
prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">...</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
><br></span></div></code></div><br>But why do you want forward declare it i=
nstead of include the Car itself before User?<br><br>Peter<br><br><br>On We=
dnesday, July 1, 2015 at 4:53:07 PM UTC+2, vityat...@gmail.com wrote:<block=
quote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-le=
ft: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">The problem is know=
n for anyone: nested entities can not be forward declared. Latest C++14 sta=
ndard did not make any step in solving this.<br><br>Suppose we are writing =
a program about cars. In code we are creating few namespaces and other OOP-=
entities. So, let's see our <b>car.h</b> file:<br><br><div style=3D"backgro=
und-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid=
;border-width:1px;word-wrap:break-word"><code><div><span style=3D"color:#00=
8">namespace</span><span style=3D"color:#000"> application </span><span sty=
le=3D"color:#660">{</span><span style=3D"color:#000"><br>&nbsp; &nbsp; </sp=
an><span style=3D"color:#008">class</span><span style=3D"color:#000"> </spa=
n><span style=3D"color:#606">Car</span><span style=3D"color:#000"> </span><=
span style=3D"color:#660">:</span><span style=3D"color:#000"> </span><span =
style=3D"color:#008">public</span><span style=3D"color:#000"> </span><span =
style=3D"color:#606">Drawable</span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#660">{</span><span style=3D"color:#000"><br>&nbsp; &nbsp;=
 </span><span style=3D"color:#008">public</span><span style=3D"color:#660">=
:</span><span style=3D"color:#000"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><=
span style=3D"color:#008">struct</span><span style=3D"color:#000"> </span><=
span style=3D"color:#606">Tire</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#660">{</span><span style=3D"color:#000"><br>&nbsp; &nbsp=
; &nbsp; &nbsp; &nbsp; &nbsp; </span><span style=3D"color:#008">float</span=
><span style=3D"color:#000"> pressure</span><span style=3D"color:#660">;</s=
pan><span style=3D"color:#000"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><span=
 style=3D"color:#660">};</span><span style=3D"color:#000"><br><br>&nbsp; &n=
bsp; &nbsp; &nbsp; </span><span style=3D"color:#008">void</span><span style=
=3D"color:#000"> draw</span><span style=3D"color:#660">()</span><span style=
=3D"color:#000"> </span><span style=3D"color:#008">final</span><span style=
=3D"color:#000"> </span><span style=3D"color:#008">override</span><span sty=
le=3D"color:#660">;</span><span style=3D"color:#000"><br>&nbsp; &nbsp; </sp=
an><span style=3D"color:#660">}</span><span style=3D"color:#000"><br></span=
><span style=3D"color:#660">}</span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#800">// application</span><span style=3D"color:#000"><br>=
</span></div></code></div><br><br><br>Suppose we have some implementation i=
n <b>car.cpp</b> file and we are going to use this Car class in our code:<b=
r><br>some <b>.h</b>-file:<br><br><div style=3D"background-color:rgb(250,25=
0,250);border-color:rgb(187,187,187);border-style:solid;border-width:1px;wo=
rd-wrap:break-word"><code><div><span style=3D"color:#008">class</span><span=
 style=3D"color:#000"> </span><span style=3D"color:#606">Car</span><span st=
yle=3D"color:#660">;</span><span style=3D"color:#000"><br></span><span styl=
e=3D"color:#008">struct</span><span style=3D"color:#000"> </span><span styl=
e=3D"color:#606">Car</span><span style=3D"color:#660">::</span><span style=
=3D"color:#606">Tire</span><span style=3D"color:#660">;</span><span style=
=3D"color:#000"> </span><span style=3D"color:#800">// illegal, won't compil=
e</span><span style=3D"color:#000"><br></span><span style=3D"color:#008">na=
mespace</span><span style=3D"color:#000"> application </span><span style=3D=
"color:#660">{</span><span style=3D"color:#000"><br>&nbsp; &nbsp; </span><s=
pan style=3D"color:#008">class</span><span style=3D"color:#000"> </span><sp=
an style=3D"color:#606">User</span><span style=3D"color:#000"> </span><span=
 style=3D"color:#660">{</span><span style=3D"color:#000"><br>&nbsp; &nbsp; =
</span><span style=3D"color:#008">public</span><span style=3D"color:#660">:=
</span><span style=3D"color:#000"><br>&nbsp; &nbsp; &nbsp; &nbsp; </span><s=
pan style=3D"color:#008">void</span><span style=3D"color:#000"> addTire</sp=
an><span style=3D"color:#660">(</span><span style=3D"color:#008">const</spa=
n><span style=3D"color:#000"> </span><span style=3D"color:#606">Car</span><=
span style=3D"color:#660">::</span><span style=3D"color:#606">Tire</span><s=
pan style=3D"color:#660">&amp;</span><span style=3D"color:#000"> tire</span=
><span style=3D"color:#660">);</span><span style=3D"color:#000"> &nbsp; &nb=
sp;</span><span style=3D"color:#800">// wrong, because we did not forward d=
eclare this struct correctly (here are no any methods actually)</span><span=
 style=3D"color:#000"><br>&nbsp; &nbsp; </span><span style=3D"color:#660">}=
;</span><span style=3D"color:#000"><br></span><span style=3D"color:#660">}<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#800">// appl=
ication</span><span style=3D"color:#000"><br></span></div></code></div><br>=
<br>Very-very simple piece of code. It shows how the problem can be reprodu=
ced.<br>So, we can't <b>Car</b>'s users operate with nested structure <b>Ti=
re</b> we can't use Tire because it can't be forward declared. I can't thin=
k up any reason for that.<br><br>Some people would say: use namespace, unne=
st the structure. <u><b><i>But this is not correct!</i></b></u><br>Why shou=
ld I break semantic link between OOP-entities (<b>Tire</b> is absolutely sh=
ould be in the <b>Car</b> but of course it can be changed: by more cars, ti=
re modifications, a lot of reasons, just I don't want to waste our time to =
explain this obvious thing). Yes, you may find exactly this example not cor=
rect or something else but I have a lot of code which should be done like t=
his. I don't want to make useless tree of namespaces. Also, why do we have =
a possibility to use nested classes then? I mean, I do know why but in case=
s like this it deprives us from forward declare it.<br><br>P.S. Unfortunate=
ly, I did not find anything about that here yet.<br></div></blockquote></di=
v>

<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 />

------=_Part_2531_441960586.1435783204702--
------=_Part_2530_1137207498.1435783204702--

.