Re: [sigc] C++0x lambdas
- From: Kjell Ahlstedt <kjell ahlstedt bredband net>
- To: Chow Loong Jin <hyperair gmail com>
- Cc: libsigc-list gnome org
- Subject: Re: [sigc] C++0x lambdas
- Date: Fri, 13 Jul 2012 16:53:39 +0200
From a post to libsigc-list 2012-01-06
That said, C++98 code could also benefit from this addition since it allows the
use of out-of-sigc++ functors. I have managed to amend the implementation to
compile with -std=c++98, but it requires BOOST_TYPEOF. Perhaps we could isolate
the BOOST_TYPEOF implementation for inclusion into sigc++?
Kind regards,
Loong Jin
Hi Loong Jin and others,
This is a late continuation of a discussion on libsigc-list in January
2012 (it started in August 2011).
Some time ago I filed bug
https://bugzilla.gnome.org/show_bug.cgi?id=672555, suggesting that
libsigc's lambda functions shall be deprecated, when they can be
replaced by C++11's lambda functions.
It's probably too early to deprecate them now, but I want to make it
easier to use C++11 lambda functions.
The specialization of sigc::functor_trait that you presented in
https://mail.gnome.org/archives/libsigc-list/2012-January/msg00000.html
is interesting.
I'm also interested in the amendment you mention that compiles with
-std=c++98. Are you willing to show it? It's not very attractive to
include BOOST_TYPEOF in libsigc++, but still I'm interested, to see if
it's something that I should consider for my bug report.
I managed to simplify your code a bit:
//-----------------------------------
#include <sigc++/functors/functor_trait.h>
namespace sigc
{
template <typename Functor>
struct functor_trait<Functor, false>
{
typedef typename functor_trait<decltype(&Functor::operator()),
false>::result_type result_type;
typedef Functor functor_type;
};
}
//-----------------------------------
It still doesn't work if the functor contains an overloaded operator().
It can't. Then "&Functor::operator()" is ambiguous.
I've found another solution for that case. It's only slightly less easy
to use, compiles with -std=c++98, and requires only a moderate amount of
new code in libsigc++. Used like so:
class MyFunctor { ..... };
sigc::slot<bool, int> slot1 = sigc::oper_fun<bool>(MyFunctor()); // One
or more operator(), C++98 or C++11
Regards
Kjell
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]