Topic: Have "extension methods" been proposed for C++1y? (or


Author: Michal Mocny <little3lue@gmail.com>
Date: Tue, 19 Mar 2013 13:17:04 -0700 (PDT)
Raw View
------=_Part_529_14734003.1363724224355
Content-Type: text/plain; charset=ISO-8859-1

I haven't been able to find any proposal on this group for "extension
methods".  What I mean is to allow using the "object-dot-method" sytax to
call "global-function-with-object-as-first-argument".

i.e.

using std::sort;
my_vector.sort();
// or
my_vector.std::sort();

// especially powerful with chaining, if globals return the target object
my_vector.sort().tail(10).copy(ostream_iterator...)
//or
my_vector.sort(std::greater()).head(10).inverted().copy(ostream_iterator...)

etc etc


I figure this must have been discussed at some point, given how many
amazing benefits this would have combined with ranges, concepts, modules
etc etc.  Perhaps there are some serious drawbacks that have already been
discussed, but I would love to read about them.

Thanks.

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.



------=_Part_529_14734003.1363724224355
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

I haven't been able to find any proposal on this group for "extension metho=
ds". &nbsp;What I mean is to allow using the "object-dot-method" sytax to c=
all "global-function-with-object-as-first-argument".<div><br></div><div>i.e=
..</div><div><br></div><div>using std::sort;</div><div>my_vector.sort();</di=
v><div>// or<br></div><div>my_vector.std::sort();</div><div><br></div><div>=
// especially powerful with chaining, if globals return the target object</=
div><div>my_vector.sort().tail(10).copy(ostream_iterator...)</div><div>//or=
</div><div>my_vector.sort(std::greater()).head(10).inverted().copy(ostream_=
iterator...)</div><div><br></div><div>etc etc</div><div><br></div><div><br>=
</div><div>I figure this must have been discussed at some point, given how =
many amazing benefits this would have combined with ranges, concepts, modul=
es etc etc. &nbsp;Perhaps there are some serious drawbacks that have alread=
y been discussed, but I would love to read about them.</div><div><br>Thanks=
..</div>

<p></p>

-- <br />
&nbsp;<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_529_14734003.1363724224355--

.