$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-users] [MultiIndex] Indexing integers
From: Sensei (senseiwa_at_[hidden])
Date: 2014-07-09 06:06:08
Dear all,
I am experimenting with MultiIndex, and I am happy with my custom classes.
Now I am wondering, can I index integers without a custom class?
For instance, say we have a 32 bit unsigned integer, how can I index
these with respect to the MSB or LSB? My first guess is using a union,
something like
union uint32_u
{
uint32_t data;
uint16_t bits[2];
};
// define a multiply indexed set with indices by id and name
typedef boost::multi_index::multi_index_container<
uint32_u,
boost::multi_index::indexed_by<
// sort by MSB
boost::multi_index::ordered_non_unique<boost::multi_index::member<employee,
uint16_t, uint32_u.bits[0]>>,
// sort by LSB
boost::multi_index::ordered_non_unique<boost::multi_index::member<employee,
uint16_t, uint32_u.bits[1]>>,
>
> integer_set;
But I cannot obviously compile it.
Is there a way I can do this?
Thanks!