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/advance.cpp,v $ |
---|
11 | // $Date: 2004/09/02 15:41:35 $ |
---|
12 | // $Revision: 1.4 $ |
---|
13 | |
---|
14 | #include <boost/mpl/advance.hpp> |
---|
15 | #include <boost/mpl/iterator_tags.hpp> |
---|
16 | #include <boost/mpl/aux_/test.hpp> |
---|
17 | |
---|
18 | template< int pos > struct iter |
---|
19 | { |
---|
20 | typedef mpl::bidirectional_iterator_tag category; |
---|
21 | typedef iter<(pos + 1)> next; |
---|
22 | typedef iter<(pos - 1)> prior; |
---|
23 | typedef int_<pos> type; |
---|
24 | }; |
---|
25 | |
---|
26 | #if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003)) |
---|
27 | namespace boost { namespace mpl { |
---|
28 | template< int pos, typename Default > struct tag< iter<pos>,Default > : void_ {}; |
---|
29 | }} |
---|
30 | #endif |
---|
31 | |
---|
32 | typedef iter<0> first; |
---|
33 | typedef iter<10> last; |
---|
34 | |
---|
35 | MPL_TEST_CASE() |
---|
36 | { |
---|
37 | typedef mpl::advance<first,int_<10> >::type iter1; |
---|
38 | typedef advance_c<first,10>::type iter2; |
---|
39 | |
---|
40 | MPL_ASSERT(( is_same<iter1, last> )); |
---|
41 | MPL_ASSERT(( is_same<iter2, last> )); |
---|
42 | } |
---|
43 | |
---|
44 | MPL_TEST_CASE() |
---|
45 | { |
---|
46 | typedef mpl::advance<last,int_<-10> >::type iter1; |
---|
47 | typedef advance_c<last,-10>::type iter2; |
---|
48 | |
---|
49 | MPL_ASSERT(( is_same<iter1, first> )); |
---|
50 | MPL_ASSERT(( is_same<iter2, first> )); |
---|
51 | } |
---|