ticc_prettyprint(1)
π NAME π
Okay bestie, welcome to ticc_prettyprint(1) from the General Commands Manual. The vibe? Format C++ containers. Literally that's the whole name drop: ticc_prettyprint β format C++ containers. Periodt.
π¦ SYNOPSIS π¦
#include ticcutils/PrettyPrint.h
using namespace TiCC;
π DESCRIPTION π
TiCC Pretty Print gives you some C++ templates so you can output C++ containers in an orderly fashion. It's not rocket science, nor is it complete. But lowkey for debugging, it is convenient to be able to output containers a bit readably. No cap.
To get usefull output, a well defined output operator is required for the elements in the container too.
TiCC output operators are currenly defined for:
set<T>list<T>vector<T>map<S,T>map<S,T,U>multimap<S,T>
To get usefull output, it is needed that an output operator is defined for the elements S and T in the container too. Like, the container can't carry the whole print job by itself, bestie π«Ά.
β¨ EXAMPLES β¨
Example 1
#include <vector>
#include <string>
#include <iostream>
#include "ticcutils/PrettyPrint.h"
using namespace std;
using namespace TiCC;
int main(){
vector<string> vec;
vec.push_back("one");
vec.push_back("two");
vec.push_back("three");
cout << vec << endl;
}
The output of this simple program will be:
[one,two,three]
Example 2
#include <vector>
#include <string>
#include <iostream>
#include "ticcutils/PrettyPrint.h"
using namespace std;
using namespace TiCC;
class myClass {
friend ostream& operator<< (ostream&, const myClass& );
public:
myClass( int i, const string& s ): _i(i),_s(s){}
private:
int _i;
string _s;
};
ostream& operator<< (ostream& os, const myClass& mc ){
os << "Myclass(" << mc._i << "," << mc._s << ")";
return os;
}
int main(){
vector<myClass> vec;
vec.push_back( myClass(1,"one") );
vec.push_back( myClass(2,"two") );
vec.push_back( myClass(3,"three") );
cout << vec << endl;
}
The output of this example program will be:
[Myclass(1,one),Myclass(2,two),Myclass(3,three)]
Example 3
#include <vector>
#include <string>
#include <iostream>
#include "ticcutils/PrettyPrint.h"
using namespace std;
using namespace TiCC;
class myClass {
friend ostream& operator<< (ostream&, const myClass& );
public:
myClass( int i, const string& s ): _i(i),_s(s){}
private:
int _i;
string _s;
};
ostream& operator<< (ostream& os, const myClass& mc ){
os << "Myclass(" << mc._i << "," << mc._s << ")";
return os;
}
int main(){
vector<*myClass> vec;
vec.push_back( new myClass(1,"one") );
vec.push_back( new myClass(2,"two") );
vec.push_back( new myClass(3,"three") );
cout << vec << endl;
}
The output of this program will be:
[0x2363040,0x23630b0,0x2363060] Or something similar.
Why is this so? Well, we didn't provide an output operator for myClass pointers! It's giving "mystery addresses" energy π.
To fix this we have to change the definition of the output operator for myClass or just add a second definition, e.g. add:
friend ostream& operator<< (ostream&, const myClass* );
to myClass, and also add:
ostream& operator<< (ostream& os, const myClass *mc ){
if ( mc )
os << *mc;
else
os << "zero pointer";
return os;
}
The output now indeed is what we expected:
[Myclass(1,one),Myclass(2,two),Myclass(3,three)]
π AUTHORS π
Ko van der Sloot β Timbl@uvt.nl
And that's the whole page, bestie π. Footer vibes: ticc_prettyprint(1), dated 2012 August 21. Go forth and pretty-print those containers, icon behavior only π
β¨
π¦ where this page comes from
- alpine 3.24: ticcutils-doc 0.36-r2 Β· GPL-3.0-only
- nixos 26.05: ticcutils 0.37
- nixpkgs unstable: ticcutils 0.38
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms