The work is inspired by r215176 and comment to r217791.
unique_ptr_deferred_release is intended for use in cases when conditional releases are mixed with raw pointer access, e.g:
unique_ptr_deferred_release<Type> P(new P); if (cond) { P.deferred_release(); } assert(P.get()); // 'true' regardless of whether deferred_release() was called or not. NonOwningFunction(P.get());
Please review!
I'm sorry to go around on this a bit - but it'd be really good to just discuss this design for a bit (maybe no llvm-dev for increased visibility) as I believe we do have a need for a generic "sometimes owns" pointer abstraction and I'm hesitant to build a partial or awkward solution here. Some specific concerns (beyond the vague one above) are:
I appreciate the work, and sorry to sort of cast doubt on it - and I don't mean to dissuade you from prototyping as you see fit, but I don't want to waste your time churning API possibilities if you'd rather wait a bit, have a chat about what we're trying to solve here, etc and then have a go at implementing (if you prefer to have that discussion and iterate on the API design in-code, that's fine too - but I don't want to annoy you by making you keep reworking your code).