r175580 - Allow llvm::Optional to work with types without default constructors.

David Blaikie dblaikie at gmail.com
Wed Feb 20 23:59:27 PST 2013


On Wed, Feb 20, 2013 at 11:23 AM, Jordan Rose <jordan_rose at apple.com> wrote:

>
> On Feb 19, 2013, at 18:20 , David Blaikie <dblaikie at gmail.com> wrote:
>
>
>
>
> On Tue, Feb 19, 2013 at 6:15 PM, Jordan Rose <jordan_rose at apple.com>wrote:
>
>> This is awesome. I think you need to write a move constructor now too,
>> though—otherwise you'll end up with two complete objects being destructed.
>> (Consider Optional<std::string>.)
>>
>
> I don't think I /need/ to write a move ctor, in the sense that the type
> won't get one for free (the conditions under which an implicit move ctor is
> provided are vanishingly rare) but it'd certainly be nice to have one.
>
>
> Ah, whoops, forgot about the "no user-declared copy-constructors"
> requirement. Downgrade this to a Nice to Have, then. :-)
>

Implemented in r175729. Not quite perfect for C++98 (a "pass by value +
swap" implementation could be used if the type was default
constructible/cheaply swappable) but C++98 perf isn't critical (just a
purist/perfectionist issue) - I've left a FIXME about that. I /think/ this
is about perfect for C++11.

- David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130220/a862304e/attachment.html>


More information about the llvm-commits mailing list