Re: [sigc] C++0x lambdas



2012-07-16 07:04, Chow Loong Jin skrev:
On 16/07/2012 02:11, Kjell Ahlstedt wrote:

Thanks.
I haven't tested it (and will probably not do it) but it seems quite reasonable.
I suppose it will also require some calls to BOOST_TYPEOF_REGISTER_TEMPLATE.
No it doesn't. Here's my full test-case:

Boost.Typeof is smart, perhaps too smart.

I found the following info in its documentation.

//--------------------------
Many compilers support typeof already, most noticeable GCC and Metrowerks.
....
The emulation mode seems to be important even if a better option is present on
some particular compiler. If a library author wants to develop portable code
using typeof, she needs to use emulation mode and register her types and templates. Those users who have a better option can still take advantage of it, since the registration macros are defined as no-op on such compilers, while the users for
whom emulation is the only option will use it.
....
The emulation mode can be forced on the compilers that don't use it by default
by defining the BOOST_TYPEOF_COMPLIANT symbol:

g++ -D BOOST_TYPEOF_COMPLIANT -I \boost\boost_1_32_0 main.cpp
//--------------------------

The gcc compiler understands the keyword __typeof__, even if not compiling in C++11 mode. Boost.Typeof takes advantage of that, unless BOOST_TYPEOF_COMPLIANT is defined.

When I defined BOOST_TYPEOF_COMPLIANT, your test case did not compile, unless I added

#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()
BOOST_TYPEOF_REGISTER_TEMPLATE(sigc::bound_mem_functor0, 2)
BOOST_TYPEOF_REGISTER_TYPE(Foo)

When I changed Foo::operator() to return a user-defined type, MyStruct, I also had to add

BOOST_TYPEOF_REGISTER_TYPE(MyStruct)

This is hardly any better than the existing libsigc++ macro SIGC_FUNCTOR_TRAIT(T_functor,T_return). In this case

namespace sigc { SIGC_FUNCTOR_TRAIT(Foo, bool) }
or
namespace sigc { SIGC_FUNCTOR_TRAIT(Foo, MyStruct) }

Kjell



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]