2004-09-02 15:41:37 +00:00
|
|
|
|
|
|
|
|
// Copyright Aleksey Gurtovoy 2000-2004
|
2002-09-16 19:25:33 +00:00
|
|
|
//
|
2004-09-02 15:41:37 +00:00
|
|
|
// Distributed under the Boost Software License, Version 1.0.
|
|
|
|
|
// (See accompanying file LICENSE_1_0.txt or copy at
|
2004-07-26 00:32:12 +00:00
|
|
|
// http://www.boost.org/LICENSE_1_0.txt)
|
2004-09-02 15:41:37 +00:00
|
|
|
//
|
|
|
|
|
// See http://www.boost.org/libs/mpl for documentation.
|
|
|
|
|
|
2008-10-10 09:21:07 +00:00
|
|
|
// $Id$
|
2004-09-02 15:41:37 +00:00
|
|
|
// $Date$
|
|
|
|
|
// $Revision$
|
|
|
|
|
|
|
|
|
|
#include <boost/mpl/advance.hpp>
|
|
|
|
|
#include <boost/mpl/iterator_tags.hpp>
|
2014-09-19 18:55:00 -06:00
|
|
|
#include <boost/mpl/aux_/test.hpp>
|
2014-09-04 23:39:44 +04:00
|
|
|
|
2004-09-02 15:41:37 +00:00
|
|
|
template< int pos > struct iter
|
|
|
|
|
{
|
|
|
|
|
typedef mpl::bidirectional_iterator_tag category;
|
|
|
|
|
typedef iter<(pos + 1)> next;
|
|
|
|
|
typedef iter<(pos - 1)> prior;
|
|
|
|
|
typedef int_<pos> type;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#if BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3003))
|
|
|
|
|
namespace boost { namespace mpl {
|
|
|
|
|
template< int pos, typename Default > struct tag< iter<pos>,Default > : void_ {};
|
|
|
|
|
}}
|
|
|
|
|
#endif
|
2002-09-16 19:25:33 +00:00
|
|
|
|
2004-09-02 15:41:37 +00:00
|
|
|
typedef iter<0> first;
|
|
|
|
|
typedef iter<10> last;
|
2002-09-16 19:25:33 +00:00
|
|
|
|
2004-09-02 15:41:37 +00:00
|
|
|
MPL_TEST_CASE()
|
2002-09-16 19:25:33 +00:00
|
|
|
{
|
2004-09-02 15:41:37 +00:00
|
|
|
typedef mpl::advance<first,int_<10> >::type iter1;
|
|
|
|
|
typedef advance_c<first,10>::type iter2;
|
2002-09-16 19:25:33 +00:00
|
|
|
|
2004-09-02 15:41:37 +00:00
|
|
|
MPL_ASSERT(( is_same<iter1, last> ));
|
|
|
|
|
MPL_ASSERT(( is_same<iter2, last> ));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MPL_TEST_CASE()
|
|
|
|
|
{
|
|
|
|
|
typedef mpl::advance<last,int_<-10> >::type iter1;
|
|
|
|
|
typedef advance_c<last,-10>::type iter2;
|
2002-09-16 19:25:33 +00:00
|
|
|
|
2004-09-02 15:41:37 +00:00
|
|
|
MPL_ASSERT(( is_same<iter1, first> ));
|
|
|
|
|
MPL_ASSERT(( is_same<iter2, first> ));
|
2002-09-16 19:25:33 +00:00
|
|
|
}
|