kripken/emscripten — pull request #2979 by pvandertak (2014-11-07 15:11:54+00:00)
Title: Embind unique ptr fix

Returning a std::unique_ptr to javascript via emscripten causes the destructor to be called immediately. I added a test case showing this (first commit). I also fixed the by passing the raw pointer instead (second commit). This passes all tests and works for me, but I am not sure if this is how you would fix it. The only reason I see to possibly treat a unique_ptr differently from a raw pointer is to add debug-mode checks to make sure that e.g. a unique_ptr is not assigned to another unique_ptr. I don't think the old way of std::move'ing is correct though, as the object may not be movable and even if it is the user might not expect the object to move.

cc @chadaustin