Files
mpl/test/find_if.cpp

47 lines
1.3 KiB
C++
Raw Permalink Normal View History

// Copyright Aleksey Gurtovoy 2000-2004
2002-09-16 19:25:33 +00:00
//
// 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.
2002-09-16 19:25:33 +00:00
2008-10-10 09:21:07 +00:00
// $Id$
// $Date$
// $Revision$
2002-09-16 19:25:33 +00:00
#include <boost/mpl/find_if.hpp>
2002-09-16 19:25:33 +00:00
#include <boost/mpl/vector.hpp>
#include <boost/mpl/distance.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/aux_/test.hpp>
#include <boost/type_traits/is_float.hpp>
#include <boost/type_traits/is_same.hpp>
2002-09-16 19:25:33 +00:00
typedef vector<int,char,long,short,char,long,double,float,char>::type types;
typedef begin<types>::type first_;
2002-09-16 19:25:33 +00:00
MPL_TEST_CASE()
{
typedef find_if< types, boost::is_float<_> >::type iter;
MPL_ASSERT(( is_same< iter::type, double > ));
MPL_ASSERT_RELATION( (mpl::distance<first_,iter>::value), ==, 6 );
}
2002-09-16 19:25:33 +00:00
MPL_TEST_CASE()
{
typedef find_if< types, boost::is_same<_,long> >::type iter;
MPL_ASSERT(( is_same< iter::type, long > ));
MPL_ASSERT_RELATION( (mpl::distance<first_,iter>::value), ==, 2 );
}
2002-09-16 19:25:33 +00:00
MPL_TEST_CASE()
{
typedef find_if< types, boost::is_same<_,void> >::type iter;
MPL_ASSERT(( is_same< iter, end<types>::type > ));
MPL_ASSERT_RELATION( (mpl::distance<first_,iter>::value), ==, size<types>::value );
2002-09-16 19:25:33 +00:00
}