On Wed, Mar 26, 2008 at 1:36 PM, Steven Watanabe &lt;<a href="mailto:watanabesj@gmail.com">watanabesj@gmail.com</a>&gt; wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
AMDG<br>
<div class="Ih2E3d"><br>
Robert Dailey wrote:<br>
&gt; The term &#39;inherit&#39; here does not refer to class inheritance obviously.<br>
&gt; It&#39;s an unusual usage of the term to me. When you do<br>
&gt; inherit&lt;empty_base, WalkPacket&gt; what exactly is that doing?<br>
<br>
</div>template&lt;class T1, class T2&gt;<br>
struct inherit : T1, T2 {};<br>
<div class="Ih2E3d"><br>
&gt; Is it joining them in a list container or something? What is the<br>
&gt; resulting type of mpl::inherit_linearly::type? Is the result of<br>
&gt; mpl::inherit_linearly::type implicitly constructible from an<br>
&gt; mpl::transform::type?<br>
<br>
</div>The result of the inherit_linearly call inherits using multiple<br>
inheritence from<br>
all the types in the sequence.<br>
<div class="Ih2E3d"><br>
&gt; I&#39;m going to read over the docs a few more times in the meantime to<br>
&gt; see if I can grasp this concept. Also, I&#39;m not seeing how you&#39;re<br>
&gt; filling in the 2 placeholders in the signal_holder typedef.<br>
<br>
</div>mpl::inherit_linearly treats the second argument as a binary lambda<br>
expression.<br>
It is very similar to the runtime std::accumulate. &nbsp;Think of inherit&lt;_,<br>
_&gt; as<br>
the MPL equivalent of a function object that returns inherit&lt;T1, T2&gt; for<br>
arguments T1 and T2.<br>
<div class="Ih2E3d"><br>
&gt; Also, mpl::vector has a max size limit I&#39;m sure. Right now we have a<br>
&gt; very minimal set of packet types, but in the future we have to<br>
&gt; consider the possibility that 100+ packet types will exist (the final<br>
&gt; number is ultimately unknown). If this is true, I doubt mpl::vector<br>
&gt; would be usable anymore since 100 seems too large for it. This makes<br>
&gt; me feel like I&#39;m going to have to resort to a completely template-less<br>
&gt; approach. I might have to send a generic Packet object to all<br>
&gt; subscribers, which has a ::Get() method that performs a<br>
&gt; static_cast&lt;&gt;() to the concrete type based on an ID.<br>
<br>
</div>MPL allows configuration to make vector able to hold larger numbers of<br>
types.<br>
If you need such a large number of Packets, compilation may be very slow<br>
with metaprogramming.</blockquote></div><br>It&#39;s good to know that mpl::vector can be configured, however the slow compilation time will require me to ensure that the mpl::vector remains in an implementation file as to not affect the compile time of other files (I&#39;m assuming this is the solution).<br>
<br>At this point I think the very last thing I need is to understand the inherit concepts. I&#39;m still really confused about how they work. In both the doxygen documentation for inherit_linearly and in your examples, I do not see anyone explicitly filling in the &#39;_&#39; arguments. However, the boost examples use _1 and _2 which makes it even more confusing. I&#39;ll outline the very specific questions I have:<br>
<br>1) I&#39;ve never used the _ placeholder, so I&#39;m not really sure how it works. How is it different from _1, _2, etc. Right now I&#39;m familiar with using Boost.Bind with the _1 concepts, how would _ be used in boost.bind (just as an example so I can see the differences).<br>
<br>2) What is the purpose in how mpl::inherit forms its classes? You say it does &quot;class inherit : T1, T2&quot;, however I do not see the benefit in this.<br><br>3) I understand that mpl::inherit_linearly treats the second template parameter as a binary lambda as you explained, however I was expecting to see that we explicitly fill in the placeholders, and that&#39;s the part that&#39;s throwing me off. I don&#39;t see how the placeholders are being filled.<br>
<br>4) So mpl::inherit_linearly::type is the very base type in the inheritance chain? Does this allow us to access any type simply by performing up-casts? It looks like from the boost docs that the up-cast is performed by assigning the mpl::inherit_linearly::type directly to the type you want, is this correct?<br>
<br>5) Can you give an example of what this inheritance tree looks like generated by mpl::inherit_linearly?<br><br>6) Can you give me a small [pseudo]code example of what mpl::inherit_linearly does for each object in the list specified at the first template parameter? The way it internally works conceptually is unknown to me.<br>
<br>7) The explanation you provided (quoted below) makes no sense to me. Could you be so kind as to emphasize a little more? Keep in mind that I have no experience with std::accumulate.<br><br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
mpl::inherit_linearly treats the second argument as a binary lambda<br>
expression.<br>
It is very similar to the runtime std::accumulate. &nbsp;Think of inherit&lt;_,<br>
_&gt; as<br>
the MPL equivalent of a function object that returns inherit&lt;T1, T2&gt; for<br>
arguments T1 and T2.<br></blockquote><div><br>Again, thanks for your help and I&#39;m sorry for being so slow. The MPL library has always proven to be frustrating for me to learn. I do appreciate you helping me out with it though. Perhaps my inexperience with MPL is why I have such a difficult time figuring out designs for some of these issues on my own.<br>
</div>