fork(3) download
  1. #include <iostream>
  2. #include <boost/range/iterator_range.hpp>
  3.  
  4. template <typename SequenceT>
  5. void print_sequence(const SequenceT& seq)
  6. {
  7. if (!boost::empty(seq))
  8. {
  9. std::cout << "[" << *std::begin(seq);
  10.  
  11. for (const auto& item : boost::make_iterator_range(seq, 1, 0))
  12. {
  13. std::cout << ", " << item;
  14. }
  15. std::cout << "]"<< std::endl;
  16. }
  17. }
  18.  
  19. int main()
  20. {
  21. const int array[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
  22.  
  23. print_sequence(array);
  24. }
  25.  
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]