|
Boost Users : |
Subject: [Boost-users] [MPL] How to use a mpl::map
From: Daniele Barzotti (daniele.barzotti_at_[hidden])
Date: 2013-03-15 03:52:49
Hi,
I'm new to MPL and I have difficulties to use the map container.
I need to map (and then retrieve) some types based on they ID:
I try the following code but it does not work..
sturct MSG_METHOD_CONNECT {
....
}
template<class MESSAGE>
class PBMessage
{
public:
PBMessage() {};
/* ... other methods ... */
private:
MESSAGE m_Msg;
};
// Map of types. The key is the Message opCode
typedef typename mpl::map< mpl::pair<mpl::int_[100],
PBMessage<MSG_METHOD_CONNECT> >,
mpl::pair<mpl::int_[101],
PBMessage<MSG_EVENT_CONNECT> >,
> TMessageMap;
// The Message type
template < typename MessageMap, int opCode >
typedef typename mpl::at<MessageMap, mpl::int_<opCode> >::type::value
TMessage;
And to retrieve the type:
TMessage<TMessageMap, opCode> msg;
Could someone give me some suggestions?
Regards,
Daniele.
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