Files
boost_mpl/include/boost/mpl/index_if.hpp
T

60 lines
1.5 KiB
C++
Raw Normal View History

2003-11-04 01:37:24 +00:00
#ifndef BOOST_MPL_INDEX_IF_HPP_INCLUDED
#define BOOST_MPL_INDEX_IF_HPP_INCLUDED
2004-09-02 15:41:37 +00:00
// Copyright Eric Friedman 2003
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/mpl for documentation.
2003-11-04 01:37:24 +00:00
2004-09-02 15:41:37 +00:00
// $Source$
// $Date$
// $Revision$
2003-11-04 01:37:24 +00:00
2004-09-02 15:41:37 +00:00
#include <boost/mpl/aux_/find_if_pred.hpp>
#include <boost/mpl/begin_end.hpp>
#include <boost/mpl/if.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/iter_fold_if.hpp>
#include <boost/mpl/next.hpp>
#include <boost/mpl/void.hpp>
#include <boost/mpl/aux_/na_spec.hpp>
#include <boost/mpl/aux_/lambda_support.hpp>
#include <boost/type_traits/is_same.hpp>
namespace boost { namespace mpl {
2003-11-04 01:37:24 +00:00
template<
2004-09-02 15:41:37 +00:00
typename BOOST_MPL_AUX_NA_PARAM(Sequence)
, typename BOOST_MPL_AUX_NA_PARAM(Predicate)
2003-11-04 01:37:24 +00:00
>
struct index_if
{
2003-11-07 04:30:08 +00:00
typedef typename iter_fold_if<
2003-11-08 11:53:00 +00:00
Sequence
2003-11-04 01:37:24 +00:00
, int_<0>
2004-09-02 15:41:37 +00:00
, next<>
, aux::find_if_pred<Predicate>
2003-11-07 04:30:08 +00:00
>::type result_;
2003-11-04 01:37:24 +00:00
2003-11-08 11:53:00 +00:00
typedef typename end<Sequence>::type not_found_;
2004-09-02 15:41:37 +00:00
typedef typename first<result_>::type result_index_;
typedef typename second<result_>::type result_iterator_;
2003-11-04 01:37:24 +00:00
typedef typename if_<
2003-11-08 11:53:00 +00:00
is_same< result_iterator_,not_found_ >
, void_
2003-11-04 01:37:24 +00:00
, result_index_
>::type type;
BOOST_MPL_AUX_LAMBDA_SUPPORT(2,index_if,(Sequence,Predicate))
};
2004-09-02 15:41:37 +00:00
BOOST_MPL_AUX_NA_SPEC(2, index_if)
2003-11-04 01:37:24 +00:00
2004-09-02 15:41:37 +00:00
}}
2003-11-04 01:37:24 +00:00
#endif // BOOST_MPL_INDEX_IF_HPP_INCLUDED