[Dbus-cxx-users] MessageAppendIterator::operator<< begin called instead of overload defined in glob
Status: Beta
Brought to you by:
rvinyard
From: <emm...@or...> - 2013-11-18 14:21:44
|
Hello, Lately, I have been playing around with DBus-cxx and user-defiend types. When working with custom types in DBus-cxx, I found that MethodProxy::operator() will call the template member operator<< in MessageAppendIterator instead of the user-defined overload in the global namespace *starting*with*the*second*method*parameter*. MessageAppendIterator::operator<< in turn attempts to call the MessageAppendIterator::append overload which does not exist and raises a compiler error. This happens at least with GCC 4.6.3 The bug can be reproduced by slightly modifying the time client/server example in examples/basics/types. Just add *two* dummy parameters of type struct timeval to the now() method to trigger this. As a fix, I propose that MessageAppendIterator::operator<< be modified to delegate its implementation to a template struct with a static append() method. The user would then have to specialize this struct instead of defining his/her own operator<< for custom types. Lazy instantiation of operator<< would ensure that the appropriate specialization is used. This would also have the benefit of allowing one partial specialization to be used for a broad range of types. As an example, I'm using this to automatically serialize introspectable types (e.g. through boost::enable_if<is_introspectable<T>>::type). Please see attached patch for the proposed solution. This is a patch against dbus-cxx 0.8.0. By the way, it would also be nice if deserialization also worked that way. Maybe serialization, deserialization and signature could all rely on a single traits structure as a default? Regards, -- Emmanuel _________________________________________________________________________________________________________________________ Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration, Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci. This message and its attachments may contain confidential or privileged information that may be protected by law; they should not be distributed, used or copied without authorisation. If you have received this email in error, please notify the sender and delete this message and its attachments. As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified. Thank you. |