<div dir="ltr"><div dir="ltr">I think you are looking for something like this:<div><br></div><div><div>std::transform(</div><div> v.begin(),</div><div> v.end(),</div><div> std::inserter(s, s.end()),</div><div> std::mem_fn(&S::i)</div><div>);</div></div><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Oct 18, 2018 at 11:02 AM Robert Jones via Boost-users <<a href="mailto:boost-users@lists.boost.org">boost-users@lists.boost.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><font face="monospace, monospace">Given</font></div><div><font face="monospace, monospace"><br class="m_-5636887737200327353gmail-Apple-interchange-newline">struct S { int i( ) const; };</font></div><div><font face="monospace, monospace">vector<S> v;</font></div><div><font face="monospace, monospace">set<int> s;</font></div><div><br></div><div>I want to write (approximately)</div><div><br></div><div><font face="monospace, monospace">for_each( v | transform( []( const S & s ){ return s.i( ); } ), s.emplace );</font></div><div><br></div><div>With the <span class="m_-5636887737200327353gmail-gr_ m_-5636887737200327353gmail-gr_24 m_-5636887737200327353gmail-gr-alert m_-5636887737200327353gmail-gr_gramm m_-5636887737200327353gmail-gr_inline_cards m_-5636887737200327353gmail-gr_run_anim m_-5636887737200327353gmail-Grammar m_-5636887737200327353gmail-only-ins m_-5636887737200327353gmail-replaceWithoutSep" id="m_-5636887737200327353gmail-24" style="display:inline;border-bottom:2px solid transparent;background-repeat:no-repeat;color:inherit;font-size:inherit">intention</span> putting all <span class="m_-5636887737200327353gmail-gr_ m_-5636887737200327353gmail-gr_23 m_-5636887737200327353gmail-gr-alert m_-5636887737200327353gmail-gr_gramm m_-5636887737200327353gmail-gr_inline_cards m_-5636887737200327353gmail-gr_run_anim m_-5636887737200327353gmail-Grammar m_-5636887737200327353gmail-only-del m_-5636887737200327353gmail-replaceWithoutSep" id="m_-5636887737200327353gmail-23" style="display:inline;border-bottom:2px solid transparent;background-repeat:no-repeat;color:inherit;font-size:inherit">the <span class="m_-5636887737200327353gmail-gr_ m_-5636887737200327353gmail-gr_25 m_-5636887737200327353gmail-gr-alert m_-5636887737200327353gmail-gr_spell m_-5636887737200327353gmail-gr_inline_cards m_-5636887737200327353gmail-gr_run_anim m_-5636887737200327353gmail-ContextualSpelling m_-5636887737200327353gmail-multiReplace" id="m_-5636887737200327353gmail-25" style="display:inline;border-bottom:2px solid transparent;background-repeat:no-repeat;color:inherit;font-size:inherit">i's</span></span> extracted from v into the set s. My syntax</div><div>is all over the place, and I'm not sure how to express the s.emplace bit.</div><div><br></div><div>Also is there a better way to say the whole thing? If I were doing push_back instead</div><div>of emplace there's a facility especially for that, but I guess Boost:<span class="m_-5636887737200327353gmail-gr_ m_-5636887737200327353gmail-gr_27 m_-5636887737200327353gmail-gr-alert m_-5636887737200327353gmail-gr_gramm m_-5636887737200327353gmail-gr_inline_cards m_-5636887737200327353gmail-gr_run_anim m_-5636887737200327353gmail-Style m_-5636887737200327353gmail-replaceWithoutSep" id="m_-5636887737200327353gmail-27" style="display:inline;border-bottom:2px solid transparent;background-repeat:no-repeat;color:inherit;font-size:inherit">:Range</span> hasn't</div><div>embraced emplace because range-v3 is around now.</div><div><br></div><div>I'm sure some of you are fluent in this stuff!<br clear="all"><br class="m_-5636887737200327353gmail-Apple-interchange-newline"></div><div><div dir="ltr" class="m_-5636887737200327353gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Kind Regards</div><div><br></div><div>Rob.</div><div><br></div></div></div></div></div> _______________________________________________<br> Boost-users mailing list<br> <a href="mailto:Boost-users@lists.boost.org" target="_blank">Boost-users@lists.boost.org</a><br> <a href="https://lists.boost.org/mailman/listinfo.cgi/boost-users" rel="noreferrer" target="_blank">https://lists.boost.org/mailman/listinfo.cgi/boost-users</a><br> </blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Juan</div><div>:wq</div><div><br></div></div></div>