8 #ifndef UTILS_UTILITIES_HH_ 9 #define UTILS_UTILITIES_HH_ 17 enum class alignment {
18 LEFTJUST, RIGHTJUST, CENTERED
24 static int compare(
const vector<T>& v1,
const vector<T>& v2);
27 static string widthify(
const T& x,
const ushort& width = 0,
28 const alignment& c = alignment::CENTERED,
const char& fill =
' ');
48 if (v1.size() != v2.size()) {
59 auto iv1 = v1.cbegin();
60 auto iv2 = v2.cbegin();
61 while (iv1 != v1.cend()) {
72 string algs::widthify(
const T& x,
const ushort& width,
const alignment& c,
74 std::ostringstream os;
81 ushort addlength = width - n;
84 case alignment::LEFTJUST:
85 result = s + string(addlength, fill);
87 case alignment::RIGHTJUST:
88 result = string(addlength, fill) + s;
90 case alignment::CENTERED:
93 string(addlength / 2, fill) + s
94 + string(addlength / 2, fill) :
95 string((addlength - 1) / 2, fill) + s
96 + string((addlength + 1) / 2, fill));
customized runtime error class
Definition: excep.hh:24
Definition: utilities.hh:21
static int compare(const vector< T > &v1, const vector< T > &v2)
Definition: utilities.hh:47