Is there a standard way to indicate that a function returns a new pointer?
No, there is no "standard way" (but there is an API design policy currently considered "best practice").
Because of this ambiguity ("what does a function returning a pointer want me to do with it?"), it is currently considered best practice to impose the lifetime and ownership policy, through the return type:
<vertex pointer type> new_vertex(const Options& options);
<vertex pointer type> can be std::unique_ptr ("new_vertex doesn't own the pointer"), or std::shared_ptr ("client code doesn't own the pointer"), or something else, that has clearly defined ownership semantics (for example, Vertex const * const would indicate to client code "read the address and values, but change neither/don't delete the pointer").
Generally, you should not return a raw pointer (but in some cases, "practicality beats purity").
TLDR: there is a best practice (yes), but not a standard way (in the language).
Edit:
where the function is only intended to be used to within a class that owns the Vertex
If the class owns the Vertex, I would write it like this:
class SomeClass // owns the vertex { void do_stuff() // uses the vertex internally { init_vertex(); // see below assert(vertex.get()); // use vertex as needed } private: // "class owns the Vertex" std::unique_ptr<Vertex> vertex; // sets the internal vertex // function doesn't return a pointer of any kind void init_vertex(const Options& options); // or "reset_", "refresh_", // or "make_" vertex, // if the pointer can change // throughout the lifetime // of a SomeClass instance };
// TODO: Fix allocation of raw pointer.unique_ptrby calling itsrelease()function, and use the raw pointers like the old ways.// FIXME: Allocation of raw pointer?new_vertexso I know the object is newly minted. You could call itCreate_new_vertexto be extra clear. As for the idea that you shouldn't manage heap memory without smart pointers, never seen the truth in that - in fact if you can't manage heap memory without them, you've got no business managing heap memory with them either!