Is there a way to encapsulate return value into scoped?

Say I have a function that returns a new object:

X new_x(T t...) {
    //Super complex input processing
    return new X(something);
}

And I want to encapsulate the result using scoped, is that possible? Can I just do:
    return scoped!X(something).
?

If I understand correctly, the data will be blitted, but the destructor will be called, so the returned object will be in invalid state.

Reply via email to