
Hi, I am trying to set up a multi_index_container-type with a template argument like this: template <typename event_type> struct mi_container { typedef typename mi::composite_key< event_type, mi::const_mem_fun<fields::field_ts, ts_type, &fields::field_ts::ts>, mi::const_mem_fun<fields::field_addr, addr_type, &fields::field_addr::addr>, mi::const_mem_fun<fields::field_port, port_type, &fields::field_port::port>
self_key_type;
typedef typename mi::composite_key< event_type, mi::const_mem_fun<fields::field_ts, ts_type, &fields::field_ts::ts>, mi::const_mem_fun<fields::field_peer_addr, addr_type, &fields::field_peer_addr::peer_addr>, mi::const_mem_fun<fields::field_peer_port, port_type, &fields::field_peer_port::peer_port>
peer_key_type;
typedef typename mi::multi_index_container< event_type, mi::indexed_by< mi::ordered_non_unique< mi::tag<self_key_tag>, self_key_type>, mi::ordered_non_unique< mi::tag<peer_key_tag>, peer_key_type> >
type; };
mi_container<ev_connect>::type connected; This gives me the following compile-error: main.cpp: In instantiation of mi_container<event::ev_connect>: main.cpp:78: instantiated from here main.cpp:57: error: invalid use of event::fields::field_ts::ts to form a pointer-to-member-function main.cpp:57: note: a qualified-id is required main.cpp:64: error: invalid use of event::fields::field_ts::ts to form a pointer-to-member-function main.cpp:64: note: a qualified-id is required main.cpp:75: error: invalid use of event::fields::field_ts::ts to form a pointer-to-member-function main.cpp:75: note: a qualified-id is required Probably I doing something silly. Note that if I remove the class template and directly specialize it, there is no problem at all. Can anybody help me out? Thanks, Andrej ___________________________________________________________ Yahoo! Mail is the world's favourite email. Don't settle for less, sign up for your free account today http://uk.rd.yahoo.com/evt=44106/*http://uk.docs.yahoo.com/mail/winter07.htm...

Hi again, Andrej van der Zee ha escrito:
Hi,
I am trying to set up a multi_index_container-type with a template argument like this:
template <typename event_type> struct mi_container { typedef typename mi::composite_key< event_type, mi::const_mem_fun<fields::field_ts, ts_type, &fields::field_ts::ts>, mi::const_mem_fun<fields::field_addr, addr_type, &fields::field_addr::addr>, mi::const_mem_fun<fields::field_port, port_type, &fields::field_port::port>
self_key_type; [...] };
mi_container<ev_connect>::type connected;
This gives me the following compile-error:
main.cpp: In instantiation of [...] event::fields::field_ts::ts to form a pointer-to-member-function main.cpp:75: note: a qualified-id is required
Probably I doing something silly. Note that if I remove the class template and directly specialize it, there is no problem at all. Can anybody help me out?
Ummm... Can you provide more context? Where and how is fields defined, and what its relationship is wrt to event_type? Thank you, Joaquín M López Muñoz Telefónica, Investigación y Desarrollo

Hi, Thanks for your fast feedback and sorry for the lack of information I gave you in my last email. I stripped down everything I could and found the problem. There are two overloaded member functions and somehow in a template-context, the compiler gets confused. Is there any way to solve this without renaming one of the methods? Below the stripped down version of main.cpp that doesn't compile. Thanks! Andrej #include <boost/multi_index_container.hpp> #include <boost/multi_index/member.hpp> #include <boost/multi_index/composite_key.hpp> #include <boost/multi_index/mem_fun.hpp> namespace mi = boost::multi_index; struct field_ts { int ts() const { return 10; } void ts(const int &arg) { } };; template <typename T> struct mi_key { typedef typename mi::composite_key< field_ts, mi::const_mem_fun<field_ts, int, &field_ts::ts>
type; };
mi_key<int>::type key; int main (int argc, char **argv) { return 0; } #include <boost/multi_index_container.hpp> #include <boost/multi_index/member.hpp> #include <boost/multi_index/composite_key.hpp> #include <boost/multi_index/mem_fun.hpp> namespace mi = boost::multi_index; typedef unsigned long ts_type; struct field_ts { ts_type ts() const { return 10; } void ts(const ts_type &arg) { } };; template <typename T> struct mi_key { // template argument not used at all, just its // presence makes the compiler fail typedef typename mi::composite_key< field_ts, mi::const_mem_fun<field_ts, ts_type, &field_ts::ts>
type; };
mi_key<int>::type key; int main (int argc, char **argv) { return 0; } --- Joaquín Mª López Muñoz <joaquin@tid.es> wrote:
Hi again,
Andrej van der Zee ha escrito:
Hi,
I am trying to set up a multi_index_container-type with a template argument like this:
template <typename event_type> struct mi_container { typedef typename mi::composite_key< event_type, mi::const_mem_fun<fields::field_ts, ts_type, &fields::field_ts::ts>, mi::const_mem_fun<fields::field_addr, addr_type, &fields::field_addr::addr>, mi::const_mem_fun<fields::field_port, port_type, &fields::field_port::port>
self_key_type; [...] };
mi_container<ev_connect>::type connected;
This gives me the following compile-error:
main.cpp: In instantiation of [...] event::fields::field_ts::ts to form a pointer-to-member-function main.cpp:75: note: a qualified-id is required
Probably I doing something silly. Note that if I remove the class template and directly specialize it, there is no problem at all. Can anybody help me out?
Ummm... Can you provide more context? Where and how is fields defined, and what its relationship is wrt to event_type?
Thank you,
Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
___________________________________________________________ Yahoo! Mail is the world's favourite email. Don't settle for less, sign up for your free account today http://uk.rd.yahoo.com/evt=44106/*http://uk.docs.yahoo.com/mail/winter07.htm...

Andrej van der Zee ha escrito:
Hi,
Thanks for your fast feedback and sorry for the lack of information I gave you in my last email.
I stripped down everything I could and found the problem. There are two overloaded member functions and somehow in a template-context, the compiler gets confused. Is there any way to solve this without renaming one of the methods?
The compiler should do this automatically without you having to disambiguate the overload, see 14.3.2/5: "For a non-type template-parameter of type pointer to member function, no conversions apply. If the template-argument represents a set of overloaded member functions, the matching member function is selected from the set (13.4)."
Below the stripped down version of main.cpp that doesn't compile.[...]
This program compiles fine with GCC 3.2 and Comeau C++ 4.3.9. I think you've got a compiler bug, you might want to report it to http://gcc.gnu.org/bugzilla/ Anyway, the following might be a workaround (I don't have your GCC version to try myself): mi::const_mem_fun< field_ts, ts_type, (ts_type (field_ts::*)()const)&field_ts::ts> HTH, Joaquín M López Muñoz Telefónica, Inevstigación y Desarrollo

Hi, Yes you are right. I compiled it with gcc-3.4 and everything fine. Version gcc-4.1 gives me the error. I will send a bug-report. Thanks alot for your help! Andrej --- Joaquín Mª López Muñoz <joaquin@tid.es> wrote:
Andrej van der Zee ha escrito:
Hi,
Thanks for your fast feedback and sorry for the lack of information I gave you in my last email.
I stripped down everything I could and found the problem. There are two overloaded member functions and somehow in a template-context, the compiler gets confused. Is there any way to solve this without renaming one of the methods?
The compiler should do this automatically without you having to disambiguate the overload, see 14.3.2/5:
"For a non-type template-parameter of type pointer to member function, no conversions apply. If the template-argument represents a set of overloaded member functions, the matching member function is selected from the set (13.4)."
Below the stripped down version of main.cpp that doesn't compile.[...]
This program compiles fine with GCC 3.2 and Comeau C++ 4.3.9. I think you've got a compiler bug, you might want to report it to
Anyway, the following might be a workaround (I don't have your GCC version to try myself):
mi::const_mem_fun< field_ts, ts_type, (ts_type (field_ts::*)()const)&field_ts::ts>
HTH,
Joaquín M López Muñoz Telefónica, Inevstigación y Desarrollo
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
___________________________________________________________ To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com

BTW, I tried the workaround, but the compiler doesn't accept this (invalid template arguments). Doesn't matter, I solved it with another method invoking the former until Debian decides to ship a new compiler... Cheers, Andrej --- Joaquín Mª López Muñoz <joaquin@tid.es> wrote:
Andrej van der Zee ha escrito:
Hi,
Thanks for your fast feedback and sorry for the lack of information I gave you in my last email.
I stripped down everything I could and found the problem. There are two overloaded member functions and somehow in a template-context, the compiler gets confused. Is there any way to solve this without renaming one of the methods?
The compiler should do this automatically without you having to disambiguate the overload, see 14.3.2/5:
"For a non-type template-parameter of type pointer to member function, no conversions apply. If the template-argument represents a set of overloaded member functions, the matching member function is selected from the set (13.4)."
Below the stripped down version of main.cpp that doesn't compile.[...]
This program compiles fine with GCC 3.2 and Comeau C++ 4.3.9. I think you've got a compiler bug, you might want to report it to
Anyway, the following might be a workaround (I don't have your GCC version to try myself):
mi::const_mem_fun< field_ts, ts_type, (ts_type (field_ts::*)()const)&field_ts::ts>
HTH,
Joaquín M López Muñoz Telefónica, Inevstigación y Desarrollo
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users
___________________________________________________________ Yahoo! Mail is the world's favourite email. Don't settle for less, sign up for your free account today http://uk.rd.yahoo.com/evt=44106/*http://uk.docs.yahoo.com/mail/winter07.htm...
participants (2)
-
Andrej van der Zee
-
Joaquín Mª López Muñoz