joboccara / NamedType

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

Add feature to pass named argument in any order #25

Closed Stanley00 closed 4 years ago

Stanley00 commented 5 years ago

I have an idea for named argument feature from your blog here https://www.fluentcpp.com/2018/12/14/named-arguments-cpp/

The interface will look like this:

auto getFullNameImpl(FirstName const& firstName, LastName const& lastName);
const auto getFullName = fluent::make_named_arg_function<FirstName, LastName>(getFullNameImpl);
auto fullName = getFullName(lastName = "Bond", firstName = "James");
auto otherFullName = getFullName(firstName = "James", lastName = "Bond");
pateldhananjay146 commented 4 years ago

Named arguments are available in Swift language, It may clash with initialised arguments during compilation ?? Dhananjay

pateldhananjay146 commented 4 years ago

As I looked into Swift Language it is very strongly type safe it has this feature in Swift naming convention at calling time as well as during defination. Also they have feature that they can drop argument, need to follow overloading function and feature must have naming convention at calling time otherwise there will be ambiguity if type of two argument are same. It might have more load on extern "C" { // code }, I came to know about it while practicing on web portal. Sorry for creating trouble during this stage, I was willing to make you aware about it. I am in touch with you since long time and I am recently looking at repository on git and I came across this feature.

Dhananjay