Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/mpl/test/find_if.cpp @ 28

Last change on this file since 28 was 12, checked in by landauf, 17 years ago

added boost

File size: 1.3 KB
Line 
1
2// Copyright Aleksey Gurtovoy 2000-2004
3//
4// Distributed under the Boost Software License,Version 1.0.
5// (See accompanying file LICENSE_1_0.txt or copy at
6// http://www.boost.org/LICENSE_1_0.txt)
7//
8// See http://www.boost.org/libs/mpl for documentation.
9
10// $Source: /cvsroot/boost/boost/libs/mpl/test/find_if.cpp,v $
11// $Date: 2004/09/02 15:41:35 $
12// $Revision: 1.5 $
13
14#include <boost/mpl/find_if.hpp>
15
16#include <boost/mpl/vector.hpp>
17#include <boost/mpl/distance.hpp>
18#include <boost/mpl/size.hpp>
19#include <boost/mpl/aux_/test.hpp>
20
21#include <boost/type_traits/is_float.hpp>
22#include <boost/type_traits/is_same.hpp>
23
24typedef vector<int,char,long,short,char,long,double,float,char>::type types;
25typedef begin<types>::type first_;
26
27MPL_TEST_CASE()
28{
29    typedef find_if< types, boost::is_float<_> >::type iter;
30    MPL_ASSERT(( is_same< iter::type, double > ));
31    MPL_ASSERT_RELATION( (mpl::distance<first_,iter>::value), ==, 6 );
32}
33
34MPL_TEST_CASE()
35{
36    typedef find_if< types, boost::is_same<_,long> >::type iter;
37    MPL_ASSERT(( is_same< iter::type, long > ));
38    MPL_ASSERT_RELATION( (mpl::distance<first_,iter>::value), ==, 2 );
39}
40
41MPL_TEST_CASE()
42{
43    typedef find_if< types, boost::is_same<_,void> >::type iter;
44    MPL_ASSERT(( is_same< iter, end<types>::type > ));
45    MPL_ASSERT_RELATION( (mpl::distance<first_,iter>::value), ==, size<types>::value );
46}
Note: See TracBrowser for help on using the repository browser.