|
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?
#ifndef ENTITIES_ENTITYCONTAINER_H_
#define ENTITIES_ENTITYCONTAINER_H_
#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
const
{
return typeid(*r);
}
};
typedef boost::multi_index::multi_index_container<
Entity *,
boost::multi_index::indexed_by<
boost::multi_index::ordered_non_unique<boost::multi_index::tag<type>,
extractType>
>
> EntityContainer;
};
#endif
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