Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

added boost

File size: 1.4 KB
Line 
1
2// Copyright Aleksey Gurtovoy 2001-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/single_view.cpp,v $
11// $Date: 2004/11/28 03:35:12 $
12// $Revision: 1.4 $
13
14#include <boost/mpl/single_view.hpp>
15#include <boost/mpl/advance.hpp>
16#include <boost/mpl/size.hpp>
17#include <boost/mpl/begin_end.hpp>
18#include <boost/mpl/aux_/test.hpp>
19
20MPL_TEST_CASE()
21{
22    typedef single_view<int> view;
23    typedef begin<view>::type first;
24    typedef end<view>::type last;
25
26    MPL_ASSERT(( is_same< deref<first>::type, int > ));
27    MPL_ASSERT(( is_same< next<first>::type, last > ));
28    MPL_ASSERT(( is_same< prior<last>::type, first > ));
29
30    MPL_ASSERT(( is_same< mpl::advance<first, int_<0> >::type, first > ));
31    MPL_ASSERT(( is_same< mpl::advance<first, int_<1> >::type, last > ));
32    MPL_ASSERT(( is_same< mpl::advance<last, int_<0> >::type, last > ));
33    MPL_ASSERT(( is_same< mpl::advance<last, int_<-1> >::type, first > ));
34
35    MPL_ASSERT_RELATION( (mpl::distance<first,first>::value), ==, 0 );
36    MPL_ASSERT_RELATION( (mpl::distance<first,last>::value), ==, 1 );
37    MPL_ASSERT_RELATION( (mpl::distance<last,last>::value), ==, 0 );
38
39    MPL_ASSERT_RELATION( size<view>::value, ==, 1 );
40}
Note: See TracBrowser for help on using the repository browser.