Topic: Automatic using for base class types


Author: razvan oprea <razvan.om@gmail.com>
Date: Wed, 12 Nov 2014 03:52:15 -0800 (PST)
Raw View
------=_Part_1710_2127383281.1415793135495
Content-Type: text/plain; charset=UTF-8

Hello,

Consider the following examples:

template<typename A, typename B, typename C>
> class BaseClass
> {
> public:
> virtual void foo()
> {
> /*code*/
> }
> };
> class SomeClass : public BaseClass < int, float, SomeOtherBaseClass >
> {
> public:
> virtual void foo()
> {
> /*code before foo*/
> BaseClass<int, float, SomeOtherBaseClass>::foo();
> }
> };


*Problems:*

For virtual functions if you have to write the base class in order to call
the implementation.
This can be quite a pain if the base class is templated, or the name is
very long.
Also if you change the base class you end up having to change all the
places you used it.

*Proposal:*
Having using *base_t* defined in each class with the type of the base class:

using base_t = BaseClass<int,float,SomeOtherBaseClass>;


This will simplify writing base foo calls and because it's automatic all
the problems described above will disappear.
One remaining problem is with multiple inheritance. For this i propose the
use of *base_t* with a N being the index of the class used.

template <std::size_t N>
> using base_t = typename std::tuple_element<N, std::tuple<BaseClass1,
> BaseClass2, BaseClass3>>::type;


Using base_t<N> is not very intuitive but i don't see how this can solved
at this point.

Here is how it looks:

class SomeClass : public BaseClass<int,float,SomeOtherBaseClass>
> {
> public:
> using base_t = BaseClass<int,float,SomeOtherBaseClass>; //this line could
> be defined automatically by the compiler saving the user the need to write
> redundant code.
> virtual void foo()
> {
> /*code before foo*/
> base_t::foo();//much easier to read and write
> }
> };



*Alternative:*

One alternative is to write it yourself for every class but when you change
the base type you have to change the using definition also.




--

---
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_1710_2127383281.1415793135495
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hello,<div><br></div><div>Consider the following examples:=
</div><div><br></div><div><blockquote class=3D"gmail_quote" style=3D"margin=
: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 20=
4, 204); border-left-style: solid; padding-left: 1ex;"><font face=3D"courie=
r new, monospace">template&lt;typename A, typename B, typename C&gt;<br>cla=
ss BaseClass<br>{<br>public:<br><span class=3D"Apple-tab-span" style=3D"whi=
te-space:pre"> </span>virtual void foo()<br><span class=3D"Apple-tab-span" =
style=3D"white-space:pre"> </span>{<br><span class=3D"Apple-tab-span" style=
=3D"white-space:pre">  </span>/*code*/<br><span class=3D"Apple-tab-span" st=
yle=3D"white-space:pre"> </span>}<br>};<br>class SomeClass : public BaseCla=
ss &lt; int, float, SomeOtherBaseClass &gt;<br>{<br>public:<br><span class=
=3D"Apple-tab-span" style=3D"white-space:pre"> </span>virtual void foo()<br=
><span class=3D"Apple-tab-span" style=3D"white-space:pre"> </span>{<br><spa=
n class=3D"Apple-tab-span" style=3D"white-space:pre">  </span>/*code before=
 foo*/<br><span class=3D"Apple-tab-span" style=3D"white-space:pre">  </span=
>BaseClass&lt;int, float, SomeOtherBaseClass&gt;::foo();<br><span class=3D"=
Apple-tab-span" style=3D"white-space:pre"> </span>}<br>};</font></blockquot=
e></div><div><br></div><div><b><font size=3D"4">Problems:</font></b></div><=
div><br></div><div>For virtual functions if you have to write the base clas=
s in order to call the implementation.</div><div>This can be quite a pain i=
f the base class is templated, or the name is very long.</div><div>Also if =
you change the base class you end up having to change all the places you us=
ed it.</div><div><br></div><div><b><font size=3D"4">Proposal:</font></b></d=
iv><div>Having using <b>base_t</b> defined in each class with the type of t=
he base class:</div><div><br></div><blockquote class=3D"gmail_quote" style=
=3D"margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: r=
gb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><font face=
=3D"courier new, monospace">using base_t =3D BaseClass</font><span style=3D=
"font-family: 'courier new', monospace;">&lt;int,float,SomeOtherBaseClass&g=
t;</span><span style=3D"font-family: 'courier new', monospace;">;</span></b=
lockquote><div><br></div><div>This will simplify writing base foo calls and=
 because it's automatic all the problems described above will disappear.</d=
iv><div>One remaining problem is with multiple inheritance. For this i prop=
ose the use of <b>base_t</b> with a N being the index of the class used.</d=
iv><div><br></div><div><blockquote class=3D"gmail_quote" style=3D"margin: 0=
px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, =
204); border-left-style: solid; padding-left: 1ex;"><font face=3D"courier n=
ew, monospace">template &lt;std::size_t N&gt;<br>using base_t =3D typename =
std::tuple_element&lt;N, std::tuple&lt;BaseClass1, BaseClass2, BaseClass3&g=
t;&gt;::type;</font></blockquote></div><div><br></div><div>Using base_t&lt;=
N&gt; is not very intuitive but i don't see how this can solved at this poi=
nt.<br></div><div><br></div><div>Here is how it looks:<br></div><div><br></=
div><div><blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8=
ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-l=
eft-style: solid; padding-left: 1ex;"><font face=3D"courier new, monospace"=
>class SomeClass : public BaseClass&lt;int,float,SomeOtherBaseClass&gt;<br>=
{<br>public:<br><span class=3D"Apple-tab-span" style=3D"white-space:pre"> <=
/span>using base_t =3D&nbsp;BaseClass&lt;int,float,SomeOtherBaseClass&gt;; =
//this line could be defined automatically by the compiler saving the user =
the need to write redundant code.<br><span class=3D"Apple-tab-span" style=
=3D"white-space:pre"> </span>virtual void foo()<br><span class=3D"Apple-tab=
-span" style=3D"white-space:pre"> </span>{<br><span class=3D"Apple-tab-span=
" style=3D"white-space:pre">  </span>/*code before foo*/<br><span class=3D"=
Apple-tab-span" style=3D"white-space:pre">  </span>base_t::foo();//much eas=
ier to read and write<br><span class=3D"Apple-tab-span" style=3D"white-spac=
e:pre"> </span>}<br>};</font></blockquote></div><div><br></div><div><br></d=
iv><div><font size=3D"4"><b>Alternative:</b></font></div><div><br></div><di=
v>One alternative is to write it yourself for every class but when you chan=
ge the base type you have to change the using definition also.</div><div><b=
r></div><div><br></div><div><br></div><div><br></div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_1710_2127383281.1415793135495--

.


Author: Tony V E <tvaneerd@gmail.com>
Date: Wed, 12 Nov 2014 10:16:07 -0500
Raw View
--089e0160b7ce0022730507aae0b2
Content-Type: text/plain; charset=UTF-8

On Wed, Nov 12, 2014 at 6:52 AM, razvan oprea <razvan.om@gmail.com> wrote:

> Hello,
>
> Consider the following examples:
>
> template<typename A, typename B, typename C>
>> class BaseClass
>> {
>> public:
>> virtual void foo()
>> {
>> /*code*/
>> }
>> };
>> class SomeClass : public BaseClass < int, float, SomeOtherBaseClass >
>> {
>> public:
>> virtual void foo()
>> {
>> /*code before foo*/
>> BaseClass<int, float, SomeOtherBaseClass>::foo();
>> }
>> };
>
>
>
I consider needing to call the base foo() an anti-pattern.  See, for
example, http://www.gotw.ca/publications/mill18.htm

Having said that, there are other reasons to want base_t.  The usual
argument against that is multiple inheritance, but you've shown a solution
for that case.

Not sure whether it is worth being part of the language however -
particularly if it required a new keyword or something.
If/When we get better reflection into the language, we could then probably
add a library like std::base_tuple<SomeClass> that is the tuple of the
bases.

Tony

--

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

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

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Wed, Nov 12, 2014 at 6:52 AM, razvan oprea <span dir=3D"ltr">&lt;<a =
href=3D"mailto:razvan.om@gmail.com" target=3D"_blank">razvan.om@gmail.com</=
a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0=
px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><=
div dir=3D"ltr">Hello,<div><br></div><div>Consider the following examples:<=
/div><div><br></div><div><blockquote class=3D"gmail_quote" style=3D"margin:=
0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">=
<font face=3D"courier new, monospace">template&lt;typename A, typename B, t=
ypename C&gt;<br>class BaseClass<br>{<br>public:<br><span style=3D"white-sp=
ace:pre-wrap"> </span>virtual void foo()<br><span style=3D"white-space:pre-=
wrap"> </span>{<br><span style=3D"white-space:pre-wrap">  </span>/*code*/<b=
r><span style=3D"white-space:pre-wrap"> </span>}<br>};<br>class SomeClass :=
 public BaseClass &lt; int, float, SomeOtherBaseClass &gt;<br>{<br>public:<=
br><span style=3D"white-space:pre-wrap"> </span>virtual void foo()<br><span=
 style=3D"white-space:pre-wrap"> </span>{<br><span style=3D"white-space:pre=
-wrap">  </span>/*code before foo*/<br><span style=3D"white-space:pre-wrap"=
>  </span>BaseClass&lt;int, float, SomeOtherBaseClass&gt;::foo();<br><span =
style=3D"white-space:pre-wrap"> </span>}<br>};</font></blockquote></div><di=
v><br></div></div></blockquote><div><br></div></div>I consider needing to c=
all the base foo() an anti-pattern.=C2=A0 See, for example, <a href=3D"http=
://www.gotw.ca/publications/mill18.htm">http://www.gotw.ca/publications/mil=
l18.htm</a><br><br></div><div class=3D"gmail_extra">Having said that, there=
 are other reasons to want base_t.=C2=A0 The usual argument against that is=
 multiple inheritance, but you&#39;ve shown a solution for that case.<br><b=
r></div><div class=3D"gmail_extra">Not sure whether it is worth being part =
of the language however - particularly if it required a new keyword or some=
thing.<br></div><div class=3D"gmail_extra">If/When we get better reflection=
 into the language, we could then probably add a library like std::base_tup=
le&lt;SomeClass&gt; that is the tuple of the bases.<br><br></div><div class=
=3D"gmail_extra">Tony<br><br></div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--089e0160b7ce0022730507aae0b2--

.


Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Wed, 12 Nov 2014 17:20:02 +0200
Raw View
On 12 November 2014 17:16, Tony V E <tvaneerd@gmail.com> wrote:
>
>
> On Wed, Nov 12, 2014 at 6:52 AM, razvan oprea <razvan.om@gmail.com> wrote:
>>
>> Hello,
>>
>> Consider the following examples:
>>
>>> template<typename A, typename B, typename C>
>>> class BaseClass
>>> {
>>> public:
>>> virtual void foo()
>>> {
>>> /*code*/
>>> }
>>> };
>>> class SomeClass : public BaseClass < int, float, SomeOtherBaseClass >
>>> {
>>> public:
>>> virtual void foo()
>>> {
>>> /*code before foo*/
>>> BaseClass<int, float, SomeOtherBaseClass>::foo();
>>> }
>>> };
>>
>>
>
> I consider needing to call the base foo() an anti-pattern.  See, for
> example, http://www.gotw.ca/publications/mill18.htm
>
> Having said that, there are other reasons to want base_t.  The usual
> argument against that is multiple inheritance, but you've shown a solution
> for that case.
>
> Not sure whether it is worth being part of the language however -
> particularly if it required a new keyword or something.
> If/When we get better reflection into the language, we could then probably
> add a library like std::base_tuple<SomeClass> that is the tuple of the
> bases.


See the base class alias proposal referenced in
http://open-std.org/JTC1/SC22/WG21/docs/papers/2014/n4225.html

Note that N4225 was rejected. Whether base class aliases would be accepted
is hard to say.

--

---
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: Bjorn Reese <breese@mail1.stofanet.dk>
Date: Wed, 12 Nov 2014 16:36:13 +0100
Raw View
On 11/12/2014 04:16 PM, Tony V E wrote:

> Having said that, there are other reasons to want base_t.  The usual

For instance in the base-from-member idiom.

--

---
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: razvan oprea <razvan.om@gmail.com>
Date: Wed, 12 Nov 2014 08:01:17 -0800 (PST)
Raw View
------=_Part_543_1003982973.1415808077979
Content-Type: text/plain; charset=UTF-8

Thanks for the feedback,

    I like the std::base_tuple<> idea and i think it would be easier to
implement considering that there already exists std::underlying_type that
relies on compiler extensions to work.

Razvan.

--

---
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_543_1003982973.1415808077979
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Thanks for the feedback,<div><br></div><div>&nbsp; &nbsp; =
I like the <font face=3D"courier new, monospace">std::base_tuple&lt;&gt;</f=
ont>&nbsp;idea and i think it would be easier to implement considering that=
 there already exists <font face=3D"courier new, monospace">std::underlying=
_type</font> that relies on compiler extensions to work.</div><div><br></di=
v><div>Razvan.</div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_543_1003982973.1415808077979--

.


Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Wed, 12 Nov 2014 18:06:03 +0200
Raw View
On 12 November 2014 18:01, razvan oprea <razvan.om@gmail.com> wrote:
> Thanks for the feedback,
>
>     I like the std::base_tuple<> idea and i think it would be easier to
> implement considering that there already exists std::underlying_type that
> relies on compiler extensions to work.


For that sort of things, this proposal is in the pipeline
http://open-std.org/JTC1/SC22/WG21/docs/papers/2014/n4113.pdf

--

---
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: Matthew Woehlke <mw_triad@users.sourceforge.net>
Date: Wed, 12 Nov 2014 11:22:12 -0500
Raw View
On 2014-11-12 06:52, razvan oprea wrote:
> template <std::size_t N>
> using base_t = typename std::tuple_element<N, std::tuple<BaseClass1,
> BaseClass2, BaseClass3>>::type;

I suggested almost exactly this a while back:
https://groups.google.com/a/isocpp.org/d/msg/std-proposals/zNvQQTKvoLQ/theH0edtsr4J

....although I also suggested being able to (optionally) specify what
entity's base type you are asking about.

--
Matthew

--

---
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: Nicola Gigante <nicola.gigante@gmail.com>
Date: Wed, 12 Nov 2014 19:30:39 +0100
Raw View
--Apple-Mail=_D99D0037-C855-4B22-95AF-7947AB3F6D87
Content-Type: text/plain; charset=UTF-8


Il giorno 12/nov/2014, alle ore 16:16, Tony V E <tvaneerd@gmail.com> ha scritto:

>
>
> On Wed, Nov 12, 2014 at 6:52 AM, razvan oprea <razvan.om@gmail.com> wrote:
> Hello,
>
> Consider the following examples:
>
> template<typename A, typename B, typename C>
> class BaseClass
> {
> public:
>  virtual void foo()
>  {
>   /*code*/
>  }
> };
> class SomeClass : public BaseClass < int, float, SomeOtherBaseClass >
> {
> public:
>  virtual void foo()
>  {
>   /*code before foo*/
>   BaseClass<int, float, SomeOtherBaseClass>::foo();
>  }
> };
>
>
> I consider needing to call the base foo() an anti-pattern.  See, for example, http://www.gotw.ca/publications/mill18.htm
>
> Having said that, there are other reasons to want base_t.  The usual argument against that is multiple inheritance, but you've shown a solution for that case.
>
> Not sure whether it is worth being part of the language however - particularly if it required a new keyword or something.
> If/When we get better reflection into the language, we could then probably add a library like std::base_tuple<SomeClass> that is the tuple of the bases.
>

Hi

Another possibility would be to have an injected class name for the base classes.
This solves the problem for long template argument lists. Long class names are not
an issue for me..

Example:

template<typename A, typename B, typename C>
class BaseClass {
 // same as before...
};

class SomeClass : public BaseClase<int, float, SomeOtherClass>
{
public:
  virtual void foo() {
    BaseClass::foo();
  }
};

This breaks if one inherits from the same template instantiated with different types,
but in this convoluted case it might be enough to just complain about the ambiguity
and let the programmer specify the exact one needed.

What do you think about it?

> Tony

Greetings,
Nicola

--

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

--Apple-Mail=_D99D0037-C855-4B22-95AF-7947AB3F6D87
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dus-ascii"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode=
: space; -webkit-line-break: after-white-space;"><br><div><div>Il giorno 12=
/nov/2014, alle ore 16:16, Tony V E &lt;<a href=3D"mailto:tvaneerd@gmail.co=
m">tvaneerd@gmail.com</a>&gt; ha scritto:</div><br class=3D"Apple-interchan=
ge-newline"><blockquote type=3D"cite"><div dir=3D"ltr" style=3D"font-family=
: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; fon=
t-weight: normal; letter-spacing: normal; line-height: normal; orphans: aut=
o; text-align: start; text-indent: 0px; text-transform: none; white-space: =
normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><=
div class=3D"gmail_extra"><br class=3D"Apple-interchange-newline"><br><div =
class=3D"gmail_quote">On Wed, Nov 12, 2014 at 6:52 AM, razvan oprea<span cl=
ass=3D"Apple-converted-space">&nbsp;</span><span dir=3D"ltr">&lt;<a href=3D=
"mailto:razvan.om@gmail.com" target=3D"_blank">razvan.om@gmail.com</a>&gt;<=
/span><span class=3D"Apple-converted-space">&nbsp;</span>wrote:<br><blockqu=
ote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; border-left-w=
idth: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204);=
 padding-left: 1ex;"><div dir=3D"ltr">Hello,<div><br></div><div>Consider th=
e following examples:</div><div><br></div><div><blockquote class=3D"gmail_q=
uote" style=3D"margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-le=
ft-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"=
><font face=3D"courier new, monospace">template&lt;typename A, typename B, =
typename C&gt;<br>class BaseClass<br>{<br>public:<br><span style=3D"white-s=
pace: pre-wrap;"> </span>virtual void foo()<br><span style=3D"white-space: =
pre-wrap;"> </span>{<br><span style=3D"white-space: pre-wrap;">  </span>/*c=
ode*/<br><span style=3D"white-space: pre-wrap;"> </span>}<br>};<br>class So=
meClass : public BaseClass &lt; int, float, SomeOtherBaseClass &gt;<br>{<br=
>public:<br><span style=3D"white-space: pre-wrap;"> </span>virtual void foo=
()<br><span style=3D"white-space: pre-wrap;"> </span>{<br><span style=3D"wh=
ite-space: pre-wrap;">  </span>/*code before foo*/<br><span style=3D"white-=
space: pre-wrap;">  </span>BaseClass&lt;int, float, SomeOtherBaseClass&gt;:=
:foo();<br><span style=3D"white-space: pre-wrap;"> </span>}<br>};</font></b=
lockquote></div><div><br></div></div></blockquote><div><br></div></div>I co=
nsider needing to call the base foo() an anti-pattern.&nbsp; See, for examp=
le,<span class=3D"Apple-converted-space">&nbsp;</span><a href=3D"http://www=
..gotw.ca/publications/mill18.htm">http://www.gotw.ca/publications/mill18.ht=
m</a><br><br></div><div class=3D"gmail_extra">Having said that, there are o=
ther reasons to want base_t.&nbsp; The usual argument against that is multi=
ple inheritance, but you've shown a solution for that case.<br><br></div><d=
iv class=3D"gmail_extra">Not sure whether it is worth being part of the lan=
guage however - particularly if it required a new keyword or something.<br>=
</div><div class=3D"gmail_extra">If/When we get better reflection into the =
language, we could then probably add a library like std::base_tuple&lt;Some=
Class&gt; that is the tuple of the bases.<br><br></div></div></blockquote><=
div><br></div><div>Hi</div><div><br></div><div>Another possibility would be=
 to have an injected class name for the base classes.</div><div>This solves=
 the problem for long template argument lists. Long class names are not</di=
v><div>an issue for me..</div><div><br></div><div>Example:</div><div><br></=
div><div>template&lt;typename A, typename B, typename C&gt;</div><div>class=
 BaseClass {</div><div>&nbsp;// same as before...</div><div>};</div><div><b=
r></div><div>class SomeClass : public BaseClase&lt;int, float, SomeOtherCla=
ss&gt;</div><div>{</div><div>public:</div><div>&nbsp; virtual void foo() {<=
/div><div>&nbsp; &nbsp; BaseClass::foo();</div><div>&nbsp; }</div><div>};</=
div><div><br></div><div>This breaks if one inherits from the same template =
instantiated with different types,</div><div>but in this convoluted case it=
 might be enough to just complain about the ambiguity</div><div>and let the=
 programmer specify the exact one needed.</div><div><br></div><div>What do =
you think about it?</div><br><blockquote type=3D"cite"><div dir=3D"ltr" sty=
le=3D"font-family: Helvetica; font-size: 12px; font-style: normal; font-var=
iant: normal; font-weight: normal; letter-spacing: normal; line-height: nor=
mal; orphans: auto; text-align: start; text-indent: 0px; text-transform: no=
ne; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stro=
ke-width: 0px;"><div class=3D"gmail_extra">Tony<br></div></div></blockquote=
></div><br><div>Greetings,</div><div>Nicola</div></body></html>

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

--Apple-Mail=_D99D0037-C855-4B22-95AF-7947AB3F6D87--

.


Author: Matthew Greenwood <matthew.i.greenwood@gmail.com>
Date: Fri, 14 Nov 2014 04:31:58 -0800 (PST)
Raw View
------=_Part_526_1605453810.1415968318905
Content-Type: text/plain; charset=UTF-8

I am new to this group so I may be completely off topic here.

Where I work we have created a pre-compel step that does something similar
to what you want here.

How we currently define our inheritance chain for a class is something like
this:

public Derived : public BaseClass1<int, char...> = _mybase1, private
BaseClass2<std::string, double> = _mybase2
{
public:
    virtual void foo()
    {
        _mybase1::foo();
        _mybase2::foo();
    }
}



this then gets converted to:

public Derived : public BaseClass1<int, char...>, private BaseClass2<std::
string, double>
{
    using _mybase1 = BaseClass1<int, char...>;
    using _mybase2 = BaseClass2<std::string, double>;


public:
    virtual void foo()
    {
        _mybase1::foo();
        _mybase2::foo();
    }
}


this gives us the simplicity of not having to make edits when we change a
base class type.

I do agree having the compiler be able to support this would be very handy
and reduce our dependancy on an external parser from the compiler.

--

---
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_526_1605453810.1415968318905
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I am new to this group so I may be completely off topic he=
re.<div><br></div><div>Where I work we have created a pre-compel step that =
does something similar to what you want here.</div><div><br></div><div>How =
we currently define our inheritance chain for a class is something like thi=
s:</div><div><br></div><div class=3D"prettyprint" style=3D"background-color=
: rgb(250, 250, 250); border: 1px solid rgb(187, 187, 187); word-wrap: brea=
k-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">public</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #606;" class=3D"styled-by-prettify">Derived</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">:</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">public</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">BaseC=
lass1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;<=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">char</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">...&gt;</span><span style=3D"color: #000;"=
 class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> _mybase1</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">priva=
te</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span>=
<span style=3D"color: #606;" class=3D"styled-by-prettify">BaseClass2</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</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"colo=
r: #008;" class=3D"styled-by-prettify">string</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">double</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> _mybas=
e2<br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">public</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 s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">virtual</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </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"> foo</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">()</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br>&nbsp; &nbsp; </span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br>&nbsp; &nbsp; &nbsp; &nbsp; _mybase1</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify">foo</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">();</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br>&nbsp; &nbsp; &nbsp; &nbsp; _mybase2</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">foo</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">();</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; </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></span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">}</span></div></code></div><div><br><br><br></di=
v><div>this then gets converted to:</div><div><br></div><div><div class=3D"=
prettyprint" style=3D"background-color: rgb(250, 250, 250); border: 1px sol=
id rgb(187, 187, 187); word-wrap: break-word;"><code class=3D"prettyprint">=
<div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-=
by-prettify">public</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">=
Derived</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><spa=
n 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"styled-by-prettify"> </span><span style=3D"color: #6=
06;" class=3D"styled-by-prettify">BaseClass1</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">int</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">char</span><span style=3D"color: #660;" class=3D"styled-by-prettify">...=
&gt;,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">private</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #606;" class=3D"styled-by-prettify">BaseClass2</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">&lt;</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: #008;" c=
lass=3D"styled-by-prettify">string</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">double</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">&gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; <=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">using</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> _mybase1 </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"=
color: #606;" class=3D"styled-by-prettify">BaseClass1</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color:=
 #008;" class=3D"styled-by-prettify">int</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-b=
y-prettify">char</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">...&gt;;</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br>&nbsp; &nbsp; </span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">using</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> _mybase2 </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 </span><span style=3D"color: #606;" class=3D"styled-by-prettify">BaseClass=
2</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</spa=
n><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: #008;" class=3D"styled-by-prettify">string</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" clas=
s=3D"styled-by-prettify">double</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">&gt;;</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br><br><br></span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">public</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br>&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"> foo<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">()</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; &nbsp; <=
/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; &nbsp; &n=
bsp; &nbsp; _mybase1</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">foo</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; _mybase2</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">foo</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">();</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
&nbsp; &nbsp; </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></d=
iv></code></div><div><br></div></div><div><br></div><div>this gives us the =
simplicity of not having to make edits when we change a base class type.</d=
iv><div><br></div><div>I do agree having the compiler be able to support th=
is would be very handy and reduce our dependancy on an external parser from=
 the compiler.</div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_526_1605453810.1415968318905--

.