[LLVMdev] ErrorOr<> conflicts with unique_ptr<>
Shankar Easwaran
shankare at codeaurora.org
Thu Nov 21 16:06:46 PST 2013
On 11/21/2013 5:57 PM, Nick Kledzik wrote:
> std::unique_ptr<Foo> factoryU() {
> std::unique_ptr<Foo> f(new Foo);
> return f; // works as expected
> }
>
> ErrorOr<Foo*> factoryE() {
> ErrorOr<Foo*> f = new Foo;
> return f; // works as expected
> }
>
> ErrorOr<std::unique_ptr<Foo>> factoryEU() {
> std::unique_ptr<Foo> f(new Foo);
> return f; // ERROR: call to implicitly-deleted copy constructor of 'std::__1::unique_ptr<Foo, std::__1::default_delete<Foo> >’
> }
I think return std::move(f) would fix this, isnt it ?
>
> void sinkU(std::unique_ptr<Foo> f) {
> f->doit(); // works as expected
> }
>
> void sinkE(ErrorOr<Foo*> f) {
> f->doit(); // ERROR: member reference base type 'typename remove_reference<Foo *>::type' (aka 'Foo *') is not a structure or union'
> }
>
> void sinkEU(ErrorOr<std::unique_ptr<Foo>> f) {
> f->doit(); // ERROR: no member named 'doit' in 'std::__1::unique_ptr<Foo, std::__1::default_delete<Foo> >'
> }
if (error_code(f))
return;
(*f)->doit()
Thanks
Shankar Easwaran
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation
More information about the llvm-dev
mailing list