Equivalent to Java/C# implementation.
Simple copy of current auto_ptr support (just suppport for functions returning std::unique_ptr). Closes #1722