#include <memory>

struct base { virtual ~base() {} };
struct derived : public base {};

    std::unique_ptr<base> f() { 
      auto p = std::unique_ptr<derived>(new derived()); // std::make_unique<derived>();
      // p->foo(); 
      // works: return std::move(p); 
      return p;
    }
    
    int main() {
        auto x = f();
        return 0;
    }