diff --git a/include/boost/mpl/index_if.hpp b/include/boost/mpl/index_if.hpp index aa65e46..9b4ad5d 100644 --- a/include/boost/mpl/index_if.hpp +++ b/include/boost/mpl/index_if.hpp @@ -18,18 +18,16 @@ #define BOOST_MPL_INDEX_IF_HPP_INCLUDED #include "boost/mpl/aux_/config/workaround.hpp" +#include "boost/mpl/aux_/find_if_pred.hpp" #include "boost/mpl/aux_/iter_fold_if_impl.hpp" -#include "boost/mpl/aux_/iter_apply.hpp" #include "boost/mpl/always.hpp" -#include "boost/mpl/apply.hpp" #include "boost/mpl/begin_end.hpp" #include "boost/mpl/bool.hpp" #include "boost/mpl/if.hpp" #include "boost/mpl/int.hpp" #include "boost/mpl/lambda.hpp" #include "boost/mpl/next.hpp" -#include "boost/mpl/not.hpp" -#include "boost/mpl/or.hpp" +#include "boost/mpl/void.hpp" #include "boost/mpl/aux_/void_spec.hpp" #include "boost/mpl/aux_/lambda_support.hpp" #include "boost/type_traits/is_same.hpp" @@ -39,21 +37,6 @@ namespace mpl { namespace aux { -// slight modification of Aleksey Gurtovoy's find_if_pred -// (could replace find_if_pred) -template< typename Predicate, typename LastIterator > -struct index_if_pred -{ - template< typename State, typename Iterator > - struct apply - { - typedef not_< or_< - is_same - , aux::iter_apply1 - > > type; - }; -}; - struct index_if_op { template < typename Index, typename Iterator > @@ -88,7 +71,7 @@ struct index_if first_ , int_<0> , aux::index_if_op - , aux::index_if_pred + , aux::find_if_pred , void , always > @@ -104,7 +87,7 @@ struct index_if public: typedef typename if_< is_same< result_iterator_,last_ > - , int_<-1> + , void_ , result_index_ >::type type; diff --git a/test/index_of.cpp b/test/index_of.cpp index 7dce259..54d2be0 100644 --- a/test/index_of.cpp +++ b/test/index_of.cpp @@ -18,6 +18,7 @@ #include "boost/static_assert.hpp" #include "boost/mpl/list.hpp" +#include "boost/mpl/void.hpp" namespace mpl = boost::mpl; @@ -30,10 +31,11 @@ int test_main(int , char* []) typedef mpl::index_of< types, float >::type index_of_float; typedef mpl::index_of< types, char >::type index_of_char; - BOOST_STATIC_ASSERT( index_of_int::value == 0 ); - BOOST_STATIC_ASSERT( index_of_double::value == 1 ); - BOOST_STATIC_ASSERT( index_of_float::value == 2 ); - BOOST_STATIC_ASSERT( index_of_char::value == -1 ); // 'not found' + BOOST_STATIC_ASSERT(( index_of_int::value == 0 )); + BOOST_STATIC_ASSERT(( index_of_double::value == 1 )); + BOOST_STATIC_ASSERT(( index_of_float::value == 2 )); + + BOOST_STATIC_ASSERT(( mpl::is_void_< index_of_char >::value )); return 0; }