forked from boostorg/iterator
merged from trunk
[SVN r21898]
This commit is contained in:
@ -1,13 +1,20 @@
|
|||||||
// Copyright David Abrahams 2003. Permission to copy, use,
|
// Copyright David Abrahams 2003, Jeremy Siek 2004.
|
||||||
// modify, sell and distribute this software is granted provided this
|
|
||||||
// copyright notice appears in all copies. This software is provided
|
// Permission to copy, use, modify, sell and distribute this software
|
||||||
// "as is" without express or implied warranty, and with no claim as
|
// is granted provided this copyright notice appears in all
|
||||||
// to its suitability for any purpose.
|
// copies. This software is provided "as is" without express or
|
||||||
|
// implied warranty, and with no claim as to its suitability for any
|
||||||
|
// purpose.
|
||||||
|
|
||||||
#include <boost/iterator/filter_iterator.hpp>
|
#include <boost/iterator/filter_iterator.hpp>
|
||||||
#include <boost/iterator/reverse_iterator.hpp>
|
#include <boost/iterator/reverse_iterator.hpp>
|
||||||
#include <boost/iterator/new_iterator_tests.hpp>
|
#include <boost/iterator/new_iterator_tests.hpp>
|
||||||
#include <boost/type_traits/is_convertible.hpp>
|
#include <boost/type_traits/is_convertible.hpp>
|
||||||
|
#include <boost/concept_check.hpp>
|
||||||
|
#include <boost/concept_archetype.hpp>
|
||||||
|
#include <boost/iterator/iterator_concepts.hpp>
|
||||||
|
#include <boost/iterator/iterator_archetypes.hpp>
|
||||||
|
#include <boost/cstdlib.hpp>
|
||||||
|
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -24,9 +31,118 @@ struct one_or_four
|
|||||||
|
|
||||||
template <class T> struct undefined;
|
template <class T> struct undefined;
|
||||||
|
|
||||||
|
template <class T> struct see_type;
|
||||||
|
|
||||||
// Test filter iterator
|
// Test filter iterator
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
// Concept checks
|
||||||
|
// Adapting old-style iterators
|
||||||
|
{
|
||||||
|
typedef boost::filter_iterator<one_or_four, boost::input_iterator_archetype<dummyT> > Iter;
|
||||||
|
boost::function_requires< boost::InputIteratorConcept<Iter> >();
|
||||||
|
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
|
||||||
|
boost::function_requires< boost_concepts::SinglePassIteratorConcept<Iter> >();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef boost::filter_iterator<one_or_four, boost::input_output_iterator_archetype<dummyT> > Iter;
|
||||||
|
boost::function_requires< boost::InputIteratorConcept<Iter> >();
|
||||||
|
boost::function_requires< boost::OutputIteratorConcept<Iter, dummyT> >();
|
||||||
|
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
|
||||||
|
boost::function_requires< boost_concepts::WritableIteratorConcept<Iter> >();
|
||||||
|
boost::function_requires< boost_concepts::SinglePassIteratorConcept<Iter> >();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef boost::filter_iterator<one_or_four, boost::forward_iterator_archetype<dummyT> > Iter;
|
||||||
|
boost::function_requires< boost::ForwardIteratorConcept<Iter> >();
|
||||||
|
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
|
||||||
|
boost::function_requires< boost_concepts::ForwardTraversalConcept<Iter> >();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef boost::filter_iterator<one_or_four, boost::mutable_forward_iterator_archetype<dummyT> > Iter;
|
||||||
|
boost::function_requires< boost::Mutable_ForwardIteratorConcept<Iter> >();
|
||||||
|
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
|
||||||
|
boost::function_requires< boost_concepts::WritableIteratorConcept<Iter> >();
|
||||||
|
boost::function_requires< boost_concepts::ForwardTraversalConcept<Iter> >();
|
||||||
|
}
|
||||||
|
// Adapting new-style iterators
|
||||||
|
{
|
||||||
|
typedef boost::iterator_archetype<
|
||||||
|
const dummyT
|
||||||
|
, boost::iterator_archetypes::readable_iterator_t
|
||||||
|
, boost::single_pass_traversal_tag
|
||||||
|
> BaseIter;
|
||||||
|
typedef boost::filter_iterator<one_or_four, BaseIter> Iter;
|
||||||
|
boost::function_requires< boost::InputIteratorConcept<Iter> >();
|
||||||
|
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
|
||||||
|
boost::function_requires< boost_concepts::SinglePassIteratorConcept<Iter> >();
|
||||||
|
}
|
||||||
|
#if !BOOST_WORKAROUND(BOOST_MSVC, == 1200) // Causes Internal Error in linker.
|
||||||
|
{
|
||||||
|
typedef boost::iterator_archetype<
|
||||||
|
dummyT
|
||||||
|
, boost::iterator_archetypes::readable_writable_iterator_t
|
||||||
|
, boost::single_pass_traversal_tag
|
||||||
|
> BaseIter;
|
||||||
|
typedef boost::filter_iterator<one_or_four, BaseIter> Iter;
|
||||||
|
|
||||||
|
boost::function_requires< boost::InputIteratorConcept<Iter> >();
|
||||||
|
boost::function_requires< boost::OutputIteratorConcept<Iter, dummyT> >();
|
||||||
|
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
|
||||||
|
boost::function_requires< boost_concepts::WritableIteratorConcept<Iter> >();
|
||||||
|
boost::function_requires< boost_concepts::SinglePassIteratorConcept<Iter> >();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
typedef boost::iterator_archetype<
|
||||||
|
const dummyT
|
||||||
|
, boost::iterator_archetypes::readable_iterator_t
|
||||||
|
, boost::forward_traversal_tag
|
||||||
|
> BaseIter;
|
||||||
|
typedef boost::filter_iterator<one_or_four, BaseIter> Iter;
|
||||||
|
boost::function_requires< boost::InputIteratorConcept<Iter> >();
|
||||||
|
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
|
||||||
|
boost::function_requires< boost_concepts::ForwardTraversalConcept<Iter> >();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !BOOST_WORKAROUND(BOOST_MSVC, == 1200) // Causes Internal Error in linker.
|
||||||
|
{
|
||||||
|
typedef boost::iterator_archetype<
|
||||||
|
dummyT
|
||||||
|
, boost::iterator_archetypes::readable_writable_iterator_t
|
||||||
|
, boost::forward_traversal_tag
|
||||||
|
> BaseIter;
|
||||||
|
typedef boost::filter_iterator<one_or_four, BaseIter> Iter;
|
||||||
|
boost::function_requires< boost_concepts::ReadableIteratorConcept<Iter> >();
|
||||||
|
boost::function_requires< boost_concepts::WritableIteratorConcept<Iter> >();
|
||||||
|
boost::function_requires< boost_concepts::ForwardTraversalConcept<Iter> >();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef boost::iterator_archetype<
|
||||||
|
const dummyT
|
||||||
|
, boost::iterator_archetypes::readable_lvalue_iterator_t
|
||||||
|
, boost::forward_traversal_tag
|
||||||
|
> BaseIter;
|
||||||
|
typedef boost::filter_iterator<one_or_four, BaseIter> Iter;
|
||||||
|
boost::function_requires< boost::ForwardIteratorConcept<Iter> >();
|
||||||
|
boost::function_requires< boost_concepts::ReadableLvalueIteratorConcept<Iter> >();
|
||||||
|
boost::function_requires< boost_concepts::ForwardTraversalConcept<Iter> >();
|
||||||
|
}
|
||||||
|
{
|
||||||
|
typedef boost::iterator_archetype<
|
||||||
|
dummyT
|
||||||
|
, boost::iterator_archetypes::writable_lvalue_iterator_t
|
||||||
|
, boost::forward_traversal_tag
|
||||||
|
> BaseIter;
|
||||||
|
typedef boost::filter_iterator<one_or_four, BaseIter> Iter;
|
||||||
|
boost::function_requires< boost::Mutable_ForwardIteratorConcept<Iter> >();
|
||||||
|
boost::function_requires< boost_concepts::WritableLvalueIteratorConcept<Iter> >();
|
||||||
|
boost::function_requires< boost_concepts::ForwardTraversalConcept<Iter> >();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Run-time tests
|
||||||
|
|
||||||
dummyT array[] = { dummyT(0), dummyT(1), dummyT(2),
|
dummyT array[] = { dummyT(0), dummyT(1), dummyT(2),
|
||||||
dummyT(3), dummyT(4), dummyT(5) };
|
dummyT(3), dummyT(4), dummyT(5) };
|
||||||
const int N = sizeof(array)/sizeof(dummyT);
|
const int N = sizeof(array)/sizeof(dummyT);
|
||||||
@ -75,6 +191,7 @@ int main()
|
|||||||
filter_iter(one_or_four(), array, array + N),
|
filter_iter(one_or_four(), array, array + N),
|
||||||
dummyT(1), dummyT(4));
|
dummyT(1), dummyT(4));
|
||||||
|
|
||||||
|
|
||||||
std::cout << "test successful " << std::endl;
|
std::cout << "test successful " << std::endl;
|
||||||
return 0;
|
return boost::exit_success;
|
||||||
}
|
}
|
||||||
|
@ -66,6 +66,7 @@ int main()
|
|||||||
boost::function_requires< boost_concepts::BidirectionalTraversalConcept<Iter> >();
|
boost::function_requires< boost_concepts::BidirectionalTraversalConcept<Iter> >();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#if !BOOST_WORKAROUND(BOOST_MSVC, == 1200) // Causes Internal Error in linker.
|
||||||
{
|
{
|
||||||
typedef boost::iterator_archetype<
|
typedef boost::iterator_archetype<
|
||||||
dummyT
|
dummyT
|
||||||
@ -100,6 +101,7 @@ int main()
|
|||||||
boost::function_requires< boost_concepts::WritableLvalueIteratorConcept<Iter> >();
|
boost::function_requires< boost_concepts::WritableLvalueIteratorConcept<Iter> >();
|
||||||
boost::function_requires< boost_concepts::BidirectionalTraversalConcept<Iter> >();
|
boost::function_requires< boost_concepts::BidirectionalTraversalConcept<Iter> >();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Test reverse_iterator
|
// Test reverse_iterator
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user