joboccara / NamedType

Implementation of strong types in C++
MIT License
772 stars 85 forks source link

Support default values for named arguments #54

Open davidbrochart opened 3 years ago

davidbrochart commented 3 years ago

Is it possible to write something like this?

void displayName(FirstName const& theFirstName = "James", LastName const& theLastName = "Bond");
davidbrochart commented 3 years ago

Oh, I guess simply:

void displayName(FirstName const& theFirstName = "James", LastName const& theLastName = LastName("Bond"));
davidbrochart commented 3 years ago

Actually default values would be interesting when combined with out of order arguments (at the end of this blog post), so that we could write:

displayName(firstName = "John");
displayName(lastName = "Doe");

But I guess this would be very hard to do?