<br><div class="gmail_quote">On Thu, Aug 9, 2012 at 11:48 PM, James Dennett <span dir="ltr"><<a href="mailto:james.dennett@gmail.com" target="_blank">james.dennett@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Thu, Aug 9, 2012 at 9:41 PM, Michael Price<br>
<div><div class="h5"><<a href="mailto:michael.b.price.dev@gmail.com">michael.b.price.dev@gmail.com</a>> wrote:<br>
> On Thu, Aug 9, 2012 at 10:02 PM, James Dennett <<a href="mailto:james.dennett@gmail.com">james.dennett@gmail.com</a>><br>
> wrote:<br>
>><br>
>> On Thu, Aug 9, 2012 at 7:16 PM, Michael Price<br>
>> <<a href="mailto:michael.b.price.dev@gmail.com">michael.b.price.dev@gmail.com</a>> wrote:<br>
>> > On Thu, Aug 9, 2012 at 5:48 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>><br>
>> > wrote:<br><br></div></div></blockquote><div><SNIP> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
>> >><br>
>> >> your values can't be swapped, because MyType is not move constructible,<br>
>> >> because it's an abstract class type. The specification for 'swap' says:<br>
>> >><br>
>> >> Requires: Type T shall be MoveConstructible (Table 20) and<br>
>> >> MoveAssignable<br>
>> >> (Table 22).<br>
>> >><br>
>> > Why does it compile (and it does in fact appear to execute correctly) if<br>
>> > mypair is a pair of reference_wrappers then?<br>
>><br>
>> Because reference_wrapper is CopyConstructible and CopyAssignable<br>
>> (hence MoveConstructible and MoveAssignable), which is why it's a good<br>
>> match for what std::pair needs.<br>
>><br>
>> > I don't think that<br>
>> > reference_wrapper is MoveConstrucible and MoveAssignable.<br>
>><br>
>> Why not?<br>
><br>
> The following web page mentions CopyConstructible and CopyAssignable, but<br>
> not the move equivalents (granted, it is not authoritative).<br>
> <a href="http://en.cppreference.com/w/cpp/utility/functional/reference_wrapper" target="_blank">http://en.cppreference.com/w/cpp/utility/functional/reference_wrapper</a><br>
><br>
> Why would copyable imply movable? You can definitely have types that are<br>
> copyable but not movable as they can be deleted independently.<br>
<br>
</div></div>The standard specifies the requirements for CopyConstructible and<br>
CopyAssignable as refinements of  MoveConstructible and MoveAssignable<br>
respectively (see tables 20-23).<br>
<span class="HOEnZb"><font color="#888888"><br></font></span></blockquote><div>20.8.3 Class template reference_wrapper [refwrap]</div><div><br></div><div>namespace std {</div><div>  template <class T> class reference_wrapper {</div>
<div>  public :</div><div>...</div><div>    // construct/copy/destroy</div><div>    reference_wrapper(T&) noexcept;</div><div>    reference_wrapper(T&&) = delete; // do not bind to temporary objects</div><div>
    reference_wrapper(const reference_wrapper<T>& x) noexcept;</div><div>    // assignment</div><div>    reference_wrapper& operator=(const reference_wrapper<T>& x) noexcept;</div><div>...</div><div>
  };</div><div>}</div><div><br></div><div>Clearly that thing cannot be move constructed.  Maybe we are talking past each other at this point.  I feel that I still don't quite understand how a type could be considered MoveConstructible, yet have a deleted move constructor, but I'm willing to chalk that up to language-lawyer-ese.</div>
<div><br></div><div>Thanks for your help.  I guess it's back to specifying the full type instead of using the shiny 'auto' keyword.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888">
-- James<br>
</font></span></blockquote></div><br>