<div dir="ltr">I believe that will break the (admittedly rare) case where the user wants the formatter to modify the value.  Anyway, let's just stick with the move for now, iot's not a big deal.</div><br><div class="gmail_quote"><div dir="ltr">On Wed, Dec 14, 2016 at 10:40 AM Pavel Labath <<a href="mailto:labath@google.com">labath@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">If you mean the FooAdapter constructor, that will not help. No matter<br class="gmail_msg">
how you declare it, it is going to get treated as a value, which has<br class="gmail_msg">
to be explicitly moved.<br class="gmail_msg">
<br class="gmail_msg">
On the other hand, having FormatAdapter take `const T &` seems to do<br class="gmail_msg">
the trick. I have a feeling doing that will break the universal<br class="gmail_msg">
reference forwarding in some way, but I was not actually able to come<br class="gmail_msg">
up with an example that demonstrates it. So that could be a possible<br class="gmail_msg">
middle ground that could work until someone actually needs the<br class="gmail_msg">
universal forwarding behaviour.<br class="gmail_msg">
<br class="gmail_msg">
On 14 December 2016 at 18:13, Zachary Turner <<a href="mailto:zturner@google.com" class="gmail_msg" target="_blank">zturner@google.com</a>> wrote:<br class="gmail_msg">
> What if constructor takes a const int &<br class="gmail_msg">
><br class="gmail_msg">
> On Wed, Dec 14, 2016 at 10:08 AM Pavel Labath <<a href="mailto:labath@google.com" class="gmail_msg" target="_blank">labath@google.com</a>> wrote:<br class="gmail_msg">
>><br class="gmail_msg">
>> On 14 December 2016 at 18:02, Zachary Turner <<a href="mailto:zturner@google.com" class="gmail_msg" target="_blank">zturner@google.com</a>> wrote:<br class="gmail_msg">
>> > Can you give me an example of a trivial adapter with "broken" code and<br class="gmail_msg">
>> > then<br class="gmail_msg">
>> > how to fix it?  Doesn't this work?<br class="gmail_msg">
>> ><br class="gmail_msg">
>> > class FooAdapter : public FormatAdapter<int> {<br class="gmail_msg">
>> > public:<br class="gmail_msg">
>> >   explicit FooAdapter(int n) : FormatAdapter<int>(n) {}<br class="gmail_msg">
>> > };<br class="gmail_msg">
>><br class="gmail_msg">
>> That will not work because the base constructor accepts a rvalue<br class="gmail_msg">
>> reference, which will not bind to "n". To make it compile you need to<br class="gmail_msg">
>> do a std::move(n). There's nothing truly broken there, it's just<br class="gmail_msg">
>> moderately annoying.<br class="gmail_msg">
</blockquote></div>