Get examples working, mostly. Some interface expansion for a few of

the adaptors, allowing default construction of UnaryFunction and
Predicate arguments when they are class types.


[SVN r19081]
This commit is contained in:
Dave Abrahams
2003-07-12 04:15:13 +00:00
parent c4b7aaf281
commit 074007ab8c
14 changed files with 135 additions and 1108 deletions

View File

@@ -8,14 +8,30 @@
#include <iostream>
#include <iterator>
#include <vector>
#include <boost/counting_iterator.hpp>
#include <boost/iterator_adaptors.hpp>
#include <boost/iterator/counting_iterator.hpp>
#include <boost/iterator/indirect_iterator.hpp>
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
namespace boost { namespace detail
{
template <>
struct iterator_traits<int*>
: ptr_iter_traits<int>
{
};
template <>
struct iterator_traits<int**>
: ptr_iter_traits<int*>
{
};
}}
#endif
int main(int, char*[])
{
// Example of using counting_iterator_generator
std::cout << "counting from 0 to 4:" << std::endl;
boost::counting_iterator_generator<int>::type first(0), last(4);
boost::counting_iterator<int> first(0), last(4);
std::copy(first, last, std::ostream_iterator<int>(std::cout, " "));
std::cout << std::endl;
@@ -37,13 +53,10 @@ int main(int, char*[])
// Use counting iterator to fill in the array of pointers.
// causes an ICE with MSVC6
#if !defined(BOOST_MSVC) || (BOOST_MSVC > 1200)
std::copy(boost::make_counting_iterator(numbers.begin()),
boost::make_counting_iterator(numbers.end()),
std::back_inserter(pointers));
#endif
#if !defined(BOOST_MSVC) || (BOOST_MSVC > 1300)
// Use indirect iterator to print out numbers by accessing
// them through the array of pointers.
std::cout << "indirectly printing out the numbers from 0 to "
@@ -52,6 +65,6 @@ int main(int, char*[])
boost::make_indirect_iterator(pointers.end()),
std::ostream_iterator<int>(std::cout, " "));
std::cout << std::endl;
#endif
return 0;
}