+ // some helper functions for opt::print()
+
+ std::string* descr_str;
+ std::string* val_or_string_str;
+
+ void print_helper_init()
+ {
+ descr_str = new std::string;
+ val_or_string_str = new std::string;
+ }
+
+ void print_helper_destroy()
+ {
+ delete val_or_string_str;
+ delete descr_str;
+ }
+
+ const char* descr(const char* str)
+ {
+ const int descr_width = 35;
+ std::string* res = descr_str;
+ *res = str;
+ res->resize(descr_width, '.');
+ return res->c_str();
+ }
+
+ const char* on_off(bool b)
+ {
+ return b ? "on" : "off";
+ }
+
+ template <typename T>
+ const char* val_or_string(const T& val, const char* str, const T& deflt = 0)
+ {
+ std::string* res = val_or_string_str;
+ if (val != deflt) {
+ std::ostringstream oss;
+ oss << val;
+ *res = oss.str();
+ } else {
+ *res = str;
+ }
+ return res->c_str();
+ }
+
+ // helper function for opt::parse_args()
+