Boost logo

Boost Users :

From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-03-26 17:53:37


AMDG

James Sutherland wrote:
> Fellow boost enthusiasts,
>
> I want to be able to store a set of information that contains types.
> For example:
>
> template<typename T>
> void register_field( const FieldID id )
> {
> // need to keep a record of (T,id)
> }
>
>
> Later on, I need to recover the type and id (T,id) for use. Any
> thoughts on a way to accomplish this?
>
> Thanks for any advice,
>
> James

How are you using T when you recover it? I assume that
std::vector<std::pair<const std::type_info*, FieldID> >
doesn't do what you need?

If you need to recover T at compile time to do some template instantiations
or something, then you can't use an ordinary container because you
lose the static type information.

If the set of possible types is known up front you can use Boost.Fusion.
Otherwise, you can use some kind of type erasure to capture all the
information about T that you need.

In Christ,
Steven Watanabe


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