Topic: Delegates


Author: wkaras@yahoo.com
Date: Thu, 8 Jun 2006 15:12:29 CST
Raw View
Martin Vejn   r wrote:
> I've just read a post in comp.lang.c++.moderated submitted by Niek
> Sanders. There is a link to a very interesting article:
> [http://www.codeproject.com/cpp/FastDelegate.asp]
>
> As explained in the article, native support for delegates (e.g. pointers
> to members bound to an object) would boost performance of code which
> uses delegates heavily.
>
> Is there any reason why C++ doesn't support them? Did C++ committee
> discuss this subject?

In Standard C++, a way to implement "delegates" is illustrated by
this:

struct BaseDelegateSetI
  {
    virtual void setI(int i) = 0;
  };

template<class C>
class DelegateSetI
  {
  private:
    C &c:
  public:
    DelegateSetI(C &cc) : c(cc) { }
    void setI(int i) { c.setI(i); }
  };

So, in deciding whether to add native delegates to the
Standard, the rant against member function pointers
is perhaps a red herring.

This example would seem to indicate that delegates can
be thought of as a shorthand for abstract base classes
with a single member function.  It's true that native
delegates would be little more optimal in both space
and time when evaluated at the level of a single function
call.  But what if the object calling member functions
of the instance of C had to call several different members
of C?  Then the use of delegates would result in
unecessary redundant references to C (in each
delegate).

So I think it's still an open question whether
using builtin delegates would really result in
optimizing the object code generated from
"typical" C++ code.

If it's truely a common case for classes to
have a single virtual function, it might be
possible to optimize for that case
by not having a vtable, and putting the
function pointer in the object in place of
the vpointer.


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: musiphil@bawi.org (Seungbeom Kim)
Date: Tue, 23 May 2006 05:32:34 GMT
Raw View
Martin Vejn=E1r wrote:
> I've just read a post in comp.lang.c++.moderated submitted by Niek
> Sanders. There is a link to a very interesting article:
> [http://www.codeproject.com/cpp/FastDelegate.asp]
>=20
> As explained in the article, native support for delegates (e.g. pointer=
s
> to members bound to an object) would boost performance of code which
> uses delegates heavily.
>=20
> Is there any reason why C++ doesn't support them? Did C++ committee
> discuss this subject?

I cannot give you the answer, but I'd like to add that I also have
always wished that I could use something like Boost.Function without
worrying about the performance overhead. From the article, it seems
that achieving that goal is possible and much easier and better if
supported by the Standard.

--=20
Seungbeom Kim

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: "SuperKoko" <tabkannaz@yahoo.fr>
Date: Tue, 23 May 2006 09:59:46 CST
Raw View
Martin Vejn   r wrote:
> I've just read a post in comp.lang.c++.moderated submitted by Niek
> Sanders. There is a link to a very interesting article:
> [http://www.codeproject.com/cpp/FastDelegate.asp]
>
> As explained in the article, native support for delegates (e.g. pointers
> to members bound to an object) would boost performance of code which
> uses delegates heavily.
>
> Is there any reason why C++ doesn't support them? Did C++ committee
> discuss this subject?
>
If C++0x library supports delegates, it will be possible for the
implementation to write native optimizations. That's why the standard
reserves all names of the standard library.


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]





Author: =?ISO-8859-1?Q?Martin_Vejn=E1r?= <avakar@volny.cz>
Date: Thu, 18 May 2006 14:17:52 CST
Raw View
I've just read a post in comp.lang.c++.moderated submitted by Niek
Sanders. There is a link to a very interesting article:
[http://www.codeproject.com/cpp/FastDelegate.asp]

As explained in the article, native support for delegates (e.g. pointers
to members bound to an object) would boost performance of code which
uses delegates heavily.

Is there any reason why C++ doesn't support them? Did C++ committee
discuss this subject?
--
Martin

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]