empty_sequence checkin

[SVN r26201]
This commit is contained in:
Aleksey Gurtovoy
2004-11-13 20:19:44 +00:00
parent 3271fd328a
commit a447303946
2 changed files with 78 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
#ifndef BOOST_MPL_EMPTY_SEQUENCE_HPP_INCLUDED
#define BOOST_MPL_EMPTY_SEQUENCE_HPP_INCLUDED
// Copyright Aleksey Gurtovoy 2004
// Copyright Alexander Nasonov 2004
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/mpl for documentation.
// $Source$
// $Date$
// $Revision$
#include <boost/mpl/size_fwd.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/iterator_tags.hpp>
namespace boost { namespace mpl {
struct empty_sequence
{
struct tag;
struct begin { typedef random_access_iterator_tag category; };
typedef begin end;
};
template<>
struct size_impl<empty_sequence::tag>
{
template< typename Sequence > struct apply
: int_<0>
{
};
};
}}
#endif // #ifndef BOOST_MPL_EMPTY_SEQUENCE_HPP_INCLUDED

36
test/empty_sequence.cpp Normal file
View File

@@ -0,0 +1,36 @@
// Copyright Aleksey Gurtovoy 2004
// Copyright Alexander Nasonov 2004
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/mpl for documentation.
// $Source$
// $Date$
// $Revision$
#include <boost/mpl/empty_sequence.hpp>
#include <boost/mpl/size.hpp>
#include <boost/mpl/distance.hpp>
#include <boost/mpl/advance.hpp>
#include <boost/mpl/begin_end.hpp>
#include <boost/mpl/aux_/test.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/add_pointer.hpp>
MPL_TEST_CASE()
{
typedef begin<empty_sequence>::type begin;
typedef end<empty_sequence>::type end;
MPL_ASSERT(( is_same<begin,end> ));
MPL_ASSERT_RELATION( (mpl::distance<begin,end>::value), ==, 0 );
MPL_ASSERT_RELATION( size<empty_sequence>::value, ==, 0 );
typedef advance_c<begin,0>::type advanced;
MPL_ASSERT(( is_same<advanced,end> ));
}