
On Tue, Jul 14, 2009 at 5:11 PM, JOAQUIN M. LOPEZ MUÑOZ<joaquin@tid.es> wrote:
I'd like to use enable_if/disable_if with a meta-function that determines whether a given multi-index container has a given tagged index. You can use this:
template<typename Index> struct tag_list { typedef typename Index::tag_list type; };
template<typename MultiIndexContainer,typename Tag> struct has_index: boost::mpl::contains< boost::mpl::transform_view< typename MultiIndexContainer::index_type_list, boost::mpl::contains<tag_list<boost::mpl::_>,Tag> >, boost::mpl::true_ > {};
Thanks. This appears to be working for me (i.e. I'm getting to errors past this code, which I'll need to clear before I can fully test it). My own attempt below fails on tag_list precisely, and I don't understand why. Your post came just in time :) Although if someone can point where mine went wrong, I'm still interested. Once again, thank you Joaquín! --DD error C2039: 'tag_list' : is not a member of 'boost::mpl::vector3<T0,T1,T2>' boost\multi_index\detail\has_tag.hpp 31 error C2146: syntax error : missing ',' before identifier 'tag_list' boost\multi_index\detail\has_tag.hpp 31 error C2065: 'tag_list' : undeclared identifier boost\multi_index\detail\has_tag.hpp 31 error C2955: 'boost::mpl::contains' : use of class template requires template argument list boost\multi_index\detail\has_tag.hpp 32 using namespace boost; using boost::multi_index::detail::has_tag; template<typename BMI, typename TAG> struct has_index { typedef typename BMI::index_type_list index_type_list; typedef typename mpl::end<index_type_list>::type index_type_list_end; typedef typename has_tag<TAG>::template apply<index_type_list>::type iter; BOOST_STATIC_CONSTANT(bool, value =!(is_same<iter, index_type_list_end>::value)); };