On sexta-feira, 2 de novembro de 2012 09.41.06, Olivier Goffart wrote: > > Why doesn't the code use the number of arguments from the receiver instead > > of the sender? We did that for regular functions and member functions. > > Because for regular functions slot, I can knw that. The arguments are in > the template argument. > > When I do QtPrivate::FunctionPointer<&MyObject::mySlot>::AgumentCount, the > partial template specialisation is chosen (imagine mySlot has two > arguments) > > template<class Obj, typename Ret, typename Arg1, typename Arg2> > struct FunctionPointer<Ret (Obj::*) (Arg1, Arg2)> { > enum {ArgumentCount = 2}; ... } > > Hence, I know I can call the function with just the two first argument of > the signal.
I don't care about C++98 for this functionality. It's provided as a "best effort" basis, with known limitations. Nominally, the new syntax of the connection mechanism is a feature that requires C++11. So please tell me how the above works with variadic templates. > However, in the case of a functor, I have not found a way. > struct MyFunctor{ void operator()(); }; There is a function, it's just MyFunctor::operator(). Why can't we do the same? > QtPrivate::FunctionPointer<&MyFunctor::operator()> will not work in case > there are several operator(). That is a good point, but an acceptable compromise. > With C++11, it would be possible to do something like > > template<typename Functor, typename ... SignalArgs> > test(Functor&f, SignalArgs... &args) -> > enable_if<(sizeof(f(args...))>0),yes>; > > And if it does not exist, try removing the last argument from signal args > and see if that exist. > > Something like that could be done for Qt 5.1 (or even maybe Qt 5.0) But I > don't know how to do it without C++11. Then let's do it, since we don't need C++98 support for this. > And connecting to functor works without C++11 (now, it is probably ok to > say that connecting to functor with less arguments than the signal is only > working with C++11) -- Thiago Macieira - thiago.macieira (AT) intel.com Software Architect - Intel Open Source Technology Center
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development