Boost logo

Boost Users :

From: Andrej van der Zee (mavdzee_at_[hidden])
Date: 2007-06-13 10:02:18


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_at_[hidden]> 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_at_[hidden]
>
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.html


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net