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 | |
---|
24 | typedef vector<int,char,long,short,char,long,double,float,char>::type types; |
---|
25 | typedef begin<types>::type first_; |
---|
26 | |
---|
27 | MPL_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 | |
---|
34 | MPL_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 | |
---|
41 | MPL_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 | } |
---|