c++ - LLVM find_if implicitly-deleted copy constructor with unique_ptr<> -


so i'm working through book game development sfml , c++11, , 1 of lines of code used create scene tree giving me trouble little on head @ point. compiler returning error due implicitly deleted copy constructor of unique_ptr in find_if algorithm.

here's function find_if call. ptr typedef std::unique_ptr<scenenode>. place use find_if currently.

scenenode::ptr scenenode::detachchild(const scenenode& node) {     auto found = std::find_if(mchildren.begin(), mchildren.end(), [&] (ptr p) -> bool { return p.get() == &node; });      assert(found != mchildren.end());      ptr result = std::move(*found);     result->mparent = nullptr;     mchildren.erase(found);     return result; } 

the error returned brought within algorithm itself, , "call implicitly-deleted copy constructor of 'ptr'."

there related question located @ call implicitly deleted copy constructor in llvm, answer isn't making sense in case.

as note, i'm using latest xcode 5 release development.

the lambda expression in find_if call takes ptr (aka unique_ptr<scenenode>) argument value, means it's attempting copy unique_ptr; unique_ptrs non copyable, hence error.

change lambda expression following:

[&] (ptr const& p) -> bool { return p.get() == &node; } //       ^^^^^^ // take argument reference , avoid copying 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -