|
Boost Users : |
From: fungos (fungos_at_[hidden])
Date: 2006-12-08 08:12:18
Well, I still having trouble to get mem_fun working. multi_index accept
boost mem_fn?
Joaquin, the const still wont work. I stripped down the sample to this code:
[code]
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/mem_fun.hpp>
#include <boost/multi_index/ordered_index.hpp>
using boost::multi_index_container;
using namespace ::boost::multi_index;
class Entry
{
private:
int size;
public:
Entry(int s) : size(s) {}
int getSize() const { return size; }
};
typedef multi_index_container<
Entry,
indexed_by<
ordered_non_unique<BOOST_MULTI_INDEX_MEM_FUN(Entry,
int, getSize) > // line 23
>
> EntryCollection;
void main() {
EntryCollection entries;
Entry a(3);
entries.insert(a); // line 33
}
[/code]
With getSize() const; I get this error:
main.cpp:23: error: could not convert template argument `&Entry::getSize' to
`int (Entry::*)()'
main.cpp:24: error: template argument 1 is invalid
main.cpp:25: error: template argument 1 is invalid
main.cpp:25: error: template argument 2 is invalid
main.cpp:25: error: ISO C++ forbids declaration of `EntryCollection' with no
type
main.cpp: In function `int main(int, char**)':
main.cpp:33: error: `insert' has not been declared
main.cpp:33: error: request for member of non-aggregate type before '('
token
make.exe: *** [main.o] Error 1
On 12/7/06, "JOAQUIN LOPEZ MU?Z" <joaquin_at_[hidden]> wrote:
>
> ----- Mensaje original -----
> De: fungos <fungos_at_[hidden]>
> Fecha: Viernes, Diciembre 8, 2006 1:02 am
> Asunto: [Boost-users] Newbie to boost
> Para: boost-users_at_[hidden]
>
> > Hi, I need help to get started with boost, Im trying about some
> > time to get a little project mine converted to use boost libs.
> > My current project uses raw pointers and std::map. But I want to use
> > shared_ptr and multi_index_container.
> [...]
> > See the sample here: http://rafb.net/paste/results/hfHOx934.html ,
> > I have done this little sample to start understunding
> > multi_index_container with classes using methods (mem_fun) as
> > "selectors?". What is wrong with it?
>
> Hello,
>
> I can only give a cursory look to your code right now
> (hope to have more stable Internet access in a couple of days),
> but looks to me the problem with it is that the memfuns you're
> using for key selection must be const, i.e.
>
> int getSize() const { return size; }
> etc.
>
> HTH,
>
> 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
>
-- Animal Frontline Liberation
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