Overlapping functionality: IFTI, templates, is-expressions
Russell Lewis
webmaster at villagersonline.com
Wed Mar 19 17:39:53 PDT 2008
Jason House wrote:
> #2 I know from past discussions that C++ programmers hold this very near and
> dear to their heart. Personally, it seems like a back door to long
> compilation times. I don't have any problem with enforcing criteria for
> templates to be defined up front, but I'm certain others don't agree with
> me. Does the loss of SFINAE make templates too close to generics? I know
> C# will refuse to compile code if the up-front criteria for a generic type
> isn't specific enough.
To put a humorous twist on my SFINAE rant, let's consider this
pseudo-program:
Bag BuyGroceries(SHOPPING_LIST...)
()
{
auto myCar = GetInCar!(CalcCargoSize!(SHOPPING_LIST));
auto home = GetCurLocation();
auto myBank = GetBank();
auto store = GetStore();
DriveTo(myCar, myBank);
auto money = myBank.Withdraw(CalcCost!(SHOPPING_LIST));
DriveTo(myCar, store);
auto ret = Buy!(SHOPPING_LIST)(store);
DriveTo(myCar, home);
return ret;
}
If you didn't have enough money in your bank account, then, because of
SFINAE, the compiler would give you the following error message:
program.d: 12: You do not own a car.
More information about the Digitalmars-d
mailing list