Boost logo

Boost Users :

Subject: [Boost-users] [multi-index] Container of polymorphic pointers
From: Daniel Dilts (diltsman_at_[hidden])
Date: 2008-10-29 20:58:52

I'm am using boost::multi_index to hold a set of polymorphic entities. Due
to efficiency concerns, I have to be able sort the container based on actual
type. I was planning on sorting based on the return result of typeid. When
I try this I get errors in <functional>. I am using VC++ 2005 Standard
Edition SP1. What am I doing wrong, or, what is a better way of
accomplishing what I am trying to do?


#include <boost/multi_index_container.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include "Entity.h"

namespace Entities
    struct type{};
    struct extractType
        typedef const type_info& result_type;

        result_type operator()(const Entity * r)const // operator() must be
            return typeid(*r);
    typedef boost::multi_index::multi_index_container<
        Entity *,

> EntityContainer;


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at