inline std::string PrettyPrint(const std::forward_list<T, Allocator>& listtoprint, const bool add_delimiters=false, const std::string& separator=", ") { std::ostringstream strm; if (listtoprint.size() > 0) { if (add_delimiters) { strm << "["; typename std::forward_list<T, Allocator>::const_iterator itr; for (itr = listtoprint.begin(); itr != listtoprint.end(); ++itr) { if (itr != listtoprint.begin()) { strm << separator << PrettyPrint(*itr, add_delimiters, separator); } else { strm << PrettyPrint(*itr, add_delimiters, separator); } } strm << "]"; } else { typename std::forward_list<T, Allocator>::const_iterator itr; for (itr = listtoprint.begin(); itr != listtoprint.end(); ++itr) { if (itr != listtoprint.begin()) { strm << separator << PrettyPrint(*itr, add_delimiters, separator); } else { strm << PrettyPrint(*itr, add_delimiters, separator); } } } } return strm.str(); }