PrintSet

Files CCore/inc/PrintSet.h CCore/src/PrintSet.cpp

PrintSet() is a Creator function to build an object of the PrintSetType.


template <class R>
PrintSetType<R> PrintSet(const R &range) { return PrintSetType<R>(range); }

PrintSetType is a Helper Type, it prints some list of objects in "{ ... }" form. The type R must be a Cursor to iterate through the list of objects.


template <class R,class T=Meta::RangeObjType<R> >
class PrintSetType : public PrintOptAdapter<T>
 {
   R range;
   
  public: 
 
   explicit PrintSetType(const R &range_) : range(range_) {}
  
   template <class P>
   void print(P &out) const;
   
   template <class P,class Opt>
   void print(P &out,const Opt &opt) const;
 };

The object type T is derived by default from the R. Options may be provided to control how to print each element. An example:


int data[]={-1,2,-3,4,-5,6,-7,8,-9,10};
   
Printf(Con,"#;\n",PrintSet(Range(data)));   // { -1 , 2 , -3 , 4 , -5 , 6 , -7 , 8 , -9 , 10 }

Printf(Con,"#+3;\n",PrintSet(Range(data))); // {  -1 ,  +2 ,  -3 ,  +4 ,  -5 ,  +6 ,  -7 ,  +8 ,  -9 , +10 }