Gokulakannan Somasundaram escribió:
Hi,
In boost multi-index, can i verify whether a particular index type is
ordered/not or not through meta programming? There are the ordered
indexes, hash indexes, sequence indexes etc. Can i find them out
through meta programming?
You can if you're given the multi_index_containr type and the position
of the index:
#include
#include
#include
template<typename IndexSpecifier>
struct is_ordered_index_impl:boost::mpl::false_{};
template
struct is_ordered_index_impl<
boost::multi_index::ordered_unique
:boost::mpl::true_{};
template
struct is_ordered_index_impl<
boost::multi_index::ordered_non_unique
:boost::mpl::true_{};
template
struct is_ordered_index:
is_ordered_index_impl<
typename boost::mpl::at_c<
typename MultiIndexContainer::index_specifier_type_list,
N
>::type
>
{};
/* testing */
#include
#include
#include
#include
#include
using namespace boost::multi_index;
typedef multi_index_container<
int,
indexed_by<
ordered_unique,
ordered_non_unique,
hashed_unique,
hashed_non_unique,
sequenced<>
>
multi_t;
BOOST_MPL_ASSERT ((is_ordered_index));
BOOST_MPL_ASSERT ((is_ordered_index));
BOOST_MPL_ASSERT_NOT((is_ordered_index));
BOOST_MPL_ASSERT_NOT((is_ordered_index));
BOOST_MPL_ASSERT_NOT((is_ordered_index));
int main(){}
HTH,
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo