<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>Towards uniform handling of subobjects</title>

	<style>
	p {text-align:justify}
	li {text-align:justify}
	blockquote.note
	{
		background-color:#E0E0E0;
		padding-left: 15px;
		padding-right: 15px;
		padding-top: 1px;
		padding-bottom: 1px;
	}
	ins {color:#00A000}
	del {color:#A00000}
	</style>
</head>
<body>

<address align=right>
Document number: N4225
<br/>
<br/>
<a href="mailto:ville.voutilainen@gmail.com">Ville Voutilainen</a><br/>
2014-10-10<br/>
</address>
<hr/>
<h1 align=center>Towards uniform handling of subobjects</h1>

<h2>Abstract</h2>

<p>This paper proposes a generic facility that allows base class aliases,
base-from-member idioms, non-static initializers for bases, and more, by
introducing new kinds of <em>access-specifier</em>s.

<h2>Contents</h2>

<ul>
<li><a href="#Introduction">Introduction</a></li>
<li><a href="#Proposed">Proposed facility</a></li>
<li><a href="#Alternative">Slight alternative</a></li>
<li><a href="#Goal">What is the goal of this proposal?</a></li>
</ul>

<a name="Introduction"></a><h2>Introduction</h2>

<p>For background, see</p>
<ul>
<li><a href="http://www.open-std.org/Jtc1/sc22/wg21/docs/papers/2009/n2881.html">N2881 by James Widman and Thorsten Ottosen</a></li>
<li><a href="http://www.boost.org/doc/libs/1_56_0/libs/utility/doc/html/base_from_member.html">boost::base_from_member</a></li>
</ul>
<p>
This paper attempts to explore a way to do what those facilities are or
would be capable of, and more.
</p>

<a name="Proposed"></a><h2>Proposed facility</h2>

<p>
In short, the idea is to allow something like the following:
</p>
<p>
<pre>
<code>
class B 
{
  B(string);
};

class B2 
{
  B2(vector&lt;int&gt;)
};

class NewMagic 
{
members:
  string foo = "nifty tricks";
  vector&lt;int&gt; bar{1,2,3,4};
public bases:
  B{foo};
  B2{bar};
};

</code>
</pre>
</p>
<p>
So, to explain it briefly:
</p>
<ul>
<li>Both member and base subobjects can be defined in the class definition.</li>
<li>Data members can appear before bases, and are in that case initialized before bases.</li>
<li>Data members and bases and data members and bases and so forth can alternate.</li>
<li>Bases can have non-static initializers just like C++11 data members can.</li>
<li>Other kinds of members can also appear before bases, like type aliases,
to cover what the base class alias proposals and forum suggestions strive for.</li>
<li>Existing access-specifiers can be combined with the new specifiers <em>members</em> and <em>bases</em>.</li>
</ul>

<a name="Alternative"></a><h2>Slight alternative</h2>

<p>Don't like the idea that a <em>class-head</em> doesn't show you
the bases? Not to worry, we could just as well do</p>
<p>
<pre>
<code>
class NewMagic : public auto, public auto
{
members:
  string foo = "nifty tricks";
  vector&lt;int&gt; bar{1,2,3,4};
public bases:
  B{foo};
  B2{bar};
};

</code>
</pre>
</p>
<p>and require that the bases defined in the class definition match
the classes in the class-head.</p>

<a name="Goal"></a><h2>What is the goal of this proposal?</h2>

<p>
To put it simply, this is a very preliminary stab at a facility
that would seemingly provide solutions for multiple desired facilities
in a generic fashion. There are most likely parser issues and other
such details to solve, but the first and foremost question is for
guidance:</p>
<ul>
<li>We hate it?</li>
<li>We like it?</li>
</ul>
</p>
</body>
</html>
