Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:23:22

0001 // -*- C++ -*-
0002 
0003 #if !defined(dumpSTL_ICC)
0004 #define dumpSTL_ICC
0005 
0006 #include <iostream>
0007 #include <iterator>
0008 #include <string>
0009 
0010 template <class C>
0011 void dumpSTL(const C &cont, std::ostream &stream = std::cout) {
0012   typedef typename C::value_type T;
0013   std::ostream_iterator<T> output(stream, " ");
0014   std::copy(cont.begin(), cont.end(), output);
0015 }
0016 
0017 template <class C>
0018 void dumpSTLendl(const C &cont, std::ostream &stream = std::cout) {
0019   typedef typename C::value_type T;
0020   std::ostream_iterator<T> output(stream, " ");
0021   std::copy(cont.begin(), cont.end(), output);
0022   stream << std::endl;
0023 }
0024 
0025 template <class C>
0026 void dumpSTLeachEndl(const C &cont, int offset = 0, std::ostream &stream = std::cout) {
0027   typedef typename C::value_type T;
0028   std::string padding = "\n";
0029   if (offset) {
0030     for (int loop = 0; loop < offset; ++loop) {
0031       padding += " ";
0032       stream << " ";
0033     }  // for loop
0034   }
0035   // Try 1
0036   std::ostream_iterator<T> output(stream, padding.c_str());
0037   std::copy(cont.begin(), cont.end(), output);
0038   stream << std::endl;
0039 
0040   // // Try 2
0041   // for (C::const_iterator iter = cont.begin();
0042   //      cont.end() != iter;
0043   //      ++iter)
0044   // {
0045   //    stream << padding << *iter << std::endl;
0046   // }
0047 
0048   // // Try 3
0049   // for (std::vector< T >::const_iterator iter = cont.begin();
0050   //      cont.end() != iter;
0051   //      ++iter)
0052   // {
0053   //    stream << padding << *iter << std::endl;
0054   // }
0055 }
0056 
0057 template <class C>
0058 void dumpNamedSTLendl(const C &cont, const std::string &name, std::ostream &stream = std::cout) {
0059   typedef typename C::value_type T;
0060   stream << name << " ";
0061   std::ostream_iterator<T> output(stream, " ");
0062   std::copy(cont.begin(), cont.end(), output);
0063   stream << std::endl;
0064 }
0065 
0066 #endif  // dumpSTL_ICC