Re: How to determine when a C++11 move is synthesized?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6 January 2016 at 23:33, Jonathan Wakely wrote:
> On 6 January 2016 at 21:37, Jeffrey Walton wrote:
>> We have a library that's C++03, and its moving towards full support
>> for C++11. We are supplementing classes with:
>>
>>     class Foo
>>     {
>>         public:
>>             Foo();
>>             Foo(const Foo&);
>>             Foo& operator=(const Foo&);
>>
>> #if defined(CXX11_AVAILABLE)
>>             Foo(const Foo&&);
>> #endif
>
> I hope that const is just a typo.

P.S. That example perfectly demonstrates why you should leave the
compiler to do its job.

That move constructor is useless because you've declared the parameter
type as const, and even if you fixed that is probably imperfect
because you didn't declare it noexcept. The compiler would not make
either of those mistakes.


>>     };
>>
>> We have a lot of classes (1500 or so), and its going to take some time
>> to evaluate all of them. As a starting point, we would like to
>> identify where the compiler is synthesizing a move and then provide it
>> (especially for some fundamental/critical base classes).

It occurs to me that I might have misunderstood what you mean by
"synthesizing a move". I interpreted it to mean you're trying to find
out where implicitly-defined move constructors are used, which is
pointless, as those are the cases where the right thing is already
happening.

Are you actually asking where rvalues are copied instead of moved?
Those are the places where providing a move constructor would be
useful, because it would turn a copy into a move, and so those are the
places you should be interested in. But I don't see how that could be
described as "synthesizing a move".



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux