1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
#include <iostream>
#include <iterator>
#include <string>
template < typename ITERATOR >
void dump_data( ITERATOR begin, ITERATOR end, char ofc = 0 )
{
const char prefix[] = { ofc, '\0' } ;
for( ; begin != end ; ++begin ) std::cout << prefix << *begin ;
std::cout << '\n' ;
}
template < typename SEQUENCE >
void dump_data( const SEQUENCE& seq, char ofc = 0 )
{ dump_data( std::begin(seq), std::end(seq), ofc ) ; }
int main()
{
const int a[] { 12, 34, 56, 78, 90, 98, 76, 54, 32 } ;
dump_data(a) ; // 123456789098765432
dump_data( a, '#' ) ; // #12#34#56#78#90#98#76#54#32
const std::string str = "abracadabra" ;
dump_data( str, '.' ) ; // .a.b.r.a.c.a.d.a.b.r.a
}
| |