<div dir="ltr"><div><br></div>This question is a followup from a multi_index discussion at <a href="http://lists.boost.org/boost-users/2015/03/84028.php">http://lists.boost.org/boost-users/2015/03/84028.php</a>.  Joaquin explained the situation very accurately, so I am including his explanation following my summary below for context (I hope this does not constitute top posting :) <div><br></div><div>In summary the problem is:<br><div><div><br></div><div><div>    struct Foo {</div><div>       int i;</div><div>    }</div><div>    </div><div>    struct  GetIntMem { </div><div>       typedef int result_type;</div><div>       const int&amp; operator()(const Foo&amp; f) const { return f.i ; }</div><div>    };</div><div>    </div><div>    aFooRange |  boost::adaptors::transformed( GetIntMem() ); </div></div><div><br></div><div><br></div><div>yields &quot;<span style="color:rgb(0,0,0);font-family:verdana,arial,helvetica;font-size:12px">warning C4172: returning</span><span style="color:rgb(0,0,0);font-family:verdana,arial,helvetica;font-size:12px"> </span><span style="color:rgb(0,0,0);font-family:verdana,arial,helvetica;font-size:12px">address of local variable or temporary&quot; in VS 2012 and 2013, with Boost 1.49.   </span><span style="color:rgb(0,0,0);font-family:verdana,arial,helvetica;font-size:12px">There is no warning with Boost 1.56.  </span></div></div><div><span style="color:rgb(0,0,0);font-family:verdana,arial,helvetica;font-size:12px"><br></span></div><div><span style="color:rgb(0,0,0);font-family:verdana,arial,helvetica;font-size:12px">Is this construct safe with Boost 1.49?</span></div><div><br></div><div>In the context of multi_index, the key extractor type is the &quot;GetIntMem&quot;. Please see below for details.</div><div><br></div><div><br></div><div><div class="gmail_extra"><div class="gmail_quote">On Fri, Mar 20, 2015 at 5:33 AM, Joaquin M Lopez Munoz <span dir="ltr">&lt;<a href="mailto:joaquin@tid.es" target="_blank">joaquin@tid.es</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class=""><br>
</span>Please don&#39;t top-post:<br>
<br>
<a href="http://www.boost.org/community/policy.html#quoting" target="_blank">http://www.boost.org/community/policy.html#quoting</a><br>
<br></blockquote><div><br></div><div>Sure. Sorry. Thanks for the link, useful info.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
So, to sum up the top-posted chain of posts of yours,<br>
boost::multi_index::member&lt;Class,Type,PtrToMember&gt; publicizes its<br>
result type as<br>
<br>
typedef Type result_type;<br>
<br>
yet its call operator overloads return Type&amp; or const Ttype&amp;, and this<br>
results in some warnings in VS 12 / Boost 1.49 when used in combination<br>
with boost::adaptors::transform.<br>
<br>
So, whatever the problem is, it does not belong in Boost.MultiIndex,<br>
since member merely defines result_type in accordance with the<br>
requirements of the Key Extractor model:<br>
<br>
<a href="http://www.boost.org/libs/multi_index/doc/reference/" target="_blank">http://www.boost.org/libs/multi_index/doc/reference/</a><br>
key_extraction.html#key_extractors<br>
<br>
I mean, defining result_type in whatever way (or not defining it<br>
at all) is not an error per se; it is Boost.Range assumptions on<br>
this typedef that might be problematic. Unfortunately, the documentation<br>
for boost::adaptors::tranform(rng,fun)<br>
<br>
<a href="http://www.boost.org/libs/range/doc/html/range/reference/" target="_blank">http://www.boost.org/libs/range/doc/html/range/reference/</a><br>
adaptors/reference/transformed.html<br>
<br>
do not mention what the requirements on fun are, whether it is<br>
mandatory that a result_type be present and how this is handled by<br>
Boost.Range. I suggest you initiate a new discussion with [range]<br>
in the subject line showing the problem you found. I suspect this<br>
is related to boost:result_of<br>
<br>
<a href="http://www.boost.org/libs/utility/utility.htm#result_of" target="_blank">http://www.boost.org/libs/utility/utility.htm#result_of</a><br>
<br>
which Boost.Range seems to use internally, but only the author can<br>
tell. Also, if the problem does not show in Boost 1.56 you might be<br>
encouraged to simply upgrade and move on.<br>
<div class=""><div class="h5"><br></div></div></blockquote><div><br></div><div><br></div><div><div>Thanks Joaquin.  I could not describe the problem any better  than what you have above, so I hope you don&#39;t mind that I re-purposed this thread.</div><div><br></div><div>The question is possibly is rather moot at this point, as the issue does not manifest in Boost 1.56 (possibly earlier).   However, it&#39;d be interesting to understand why, and at least make sure using 1.49 this way is safe (I am stuck with that version for the time being). </div><div><br></div><div>Thanks very much if you followed along this far, and sorry as I fear this post ended up more convoluted that it needs to be :P</div><div><br></div><div>Nick</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div><div><br></div><div> </div></div></div></div></div></div>