19 ss << std::setw(width) << std::setprecision(prec) << std::scientific << d;
26 for (
double elem : v) {
32bool mkpath(std::string path,
int mode)
35 std::string::size_type pos = -1;
38 if (path.back() !=
'/') {
43 pos = path.find(
'/', pos);
44 if (pos != std::string::npos) {
45 cur_dir = path.substr(0, pos);
46 if (mkdir(cur_dir.c_str(), mode) != 0
47 && stat(cur_dir.c_str(), &buf) != 0) {
58std::string
dirname(
const std::string &path)
60 return path.substr(0, path.find_last_of(
"/"));
63std::string
concatpath(
const std::string &left,
const std::string &right)
65 if (left.back() !=
'/' and right.front() !=
'/') {
66 return left +
'/' + right;
Function prototypes and macros that are useful.
bool mkpath(std::string path, int mode=0777)
Make path given.
std::string scientific_format(double d, int width=20, int prec=10)
Turns a double into a string written in scientific format.
std::string concatpath(const std::string &left, const std::string &right)
Take 2 strings and concatenate them and make sure there is a directory separator (/) between them.
std::string dirname(const std::string &path)
Get the directory name of the path.