The heap-allocated version is so much worse! Not only do you have to pay for allocating and freeing it, every time you reference it, you're gonna have to chase a pointer. Imagine if you had 1000 of these in a vector: the stack allocated ones would be right there next to each other, incredibly cache friendly. The heap-allocated ones are gonna cache miss constantly, and there's ZERO chance the loop is going to auto-vectorize. Show this to a data-oriented design person and watch their eyes start bleeding.
And for what? So you can return null? Just return a std::optional from the factory method if you care so much (or boost::optional if you're on pre-C++17). Or use exceptions. Or just accept the fact that it might return the default value. All of those options are better than the final one. If you're choosing to program in C++, it means you should care about performance. If you don't care about performance for this kind of stuff, just use a higher-level language.