diff options
author | Anas Nashif <anas.nashif@intel.com> | 2012-10-30 12:57:26 -0700 |
---|---|---|
committer | Anas Nashif <anas.nashif@intel.com> | 2012-10-30 12:57:26 -0700 |
commit | 1a78a62555be32868418fe52f8e330c9d0f95d5a (patch) | |
tree | d3765a80e7d3b9640ec2e930743630cd6b9fce2b /libs/utility/shared_iterator_example2.cpp | |
download | boost-1a78a62555be32868418fe52f8e330c9d0f95d5a.tar.gz boost-1a78a62555be32868418fe52f8e330c9d0f95d5a.tar.bz2 boost-1a78a62555be32868418fe52f8e330c9d0f95d5a.zip |
Imported Upstream version 1.49.0upstream/1.49.0
Diffstat (limited to 'libs/utility/shared_iterator_example2.cpp')
-rw-r--r-- | libs/utility/shared_iterator_example2.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/libs/utility/shared_iterator_example2.cpp b/libs/utility/shared_iterator_example2.cpp new file mode 100644 index 0000000000..a9577078c5 --- /dev/null +++ b/libs/utility/shared_iterator_example2.cpp @@ -0,0 +1,43 @@ +// Copyright 2003 The Trustees of Indiana University. + +// Use, modification and distribution is subject to 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) + +#include "boost/shared_container_iterator.hpp" +#include "boost/shared_ptr.hpp" +#include <algorithm> +#include <iterator> +#include <iostream> +#include <vector> + + +template <typename Iterator> +void print_range_nl (Iterator begin, Iterator end) { + typedef typename std::iterator_traits<Iterator>::value_type val; + std::copy(begin,end,std::ostream_iterator<val>(std::cout,",")); + std::cout.put('\n'); +} + + +int main() { + + typedef boost::shared_ptr< std::vector<int> > ints_t; + { + ints_t ints(new std::vector<int>()); + + ints->push_back(0); + ints->push_back(1); + ints->push_back(2); + ints->push_back(3); + ints->push_back(4); + ints->push_back(5); + + print_range_nl(boost::make_shared_container_iterator(ints->begin(),ints), + boost::make_shared_container_iterator(ints->end(),ints)); + } + + + + return 0; +} |