C++ UFCS update

Ola Fosheim Grøstad via Digitalmars-d digitalmars-d at puremagic.com
Sat Feb 20 00:24:59 PST 2016


On Friday, 19 February 2016 at 16:42:36 UTC, David Nadlinger 
wrote:
> On Friday, 19 February 2016 at 16:18:12 UTC, Dejan Lekic wrote:
>> I have to go through each piece separated by dots to 
>> understand what it is...
>
> Let me play devil's advocate here: How would this be any 
> different if UFCS were not used?

// if a has a process
if( a.process ) …

// if processing a was successful
if( process(a) ) ...

// copy a to b
a.copy_to(b)

// copy b to a
copy_to(a,b)

// print a on stream f
f.print(a)

// print f and a on std out
print(f,a)

// count the number of people, cars and drinks
count(people,cars,drinks)

// count the number of cars and drinks people has
people.count(cars,drinks)

If you have namespace operator "::" in c++ or "'" in Ada (IIRC) 
and extension methods

// access library "as" extension method string
obj1.as'string

etc…





More information about the Digitalmars-d mailing list