Constructors With Many Arguments
The basic principle is the same as it was with default constructors. The 'in_place' command will come in handy once again.
We'll cover the following
Another use case is a situation where your type has more arguments in a constructor. By default optional
can work with a single argument (r-value ref), and efficiently pass it to the wrapped type. But what if you’d like to initialize Point(x, y)
?
You can always create a temporary copy and then pass it in the construction:
Get hands-on with 1200+ tech skills courses.