mardi 5 avril 2016

Optional parameter in modern C++ [on hold]

When I make a function that takes an optional parameter, I have often used a pointer. Like this:

void func(const T& mandatoryParam, const U* optionalParam = nullptr);

Is this approach still acceptable and appropriate in the modern C++11, 14, or 17 era? Should the parameter type be std::optional or std::observer_ptr?

Aucun commentaire:

Enregistrer un commentaire