diff options
-rw-r--r-- | libbutl/path.cxx | 4 | ||||
-rw-r--r-- | libbutl/process.cxx | 2 | ||||
-rw-r--r-- | libbutl/process.hxx | 4 | ||||
-rw-r--r-- | libbutl/timestamp.cxx | 13 | ||||
-rw-r--r-- | libbutl/timestamp.hxx | 9 |
5 files changed, 28 insertions, 4 deletions
diff --git a/libbutl/path.cxx b/libbutl/path.cxx index 61088bf..be8bd61 100644 --- a/libbutl/path.cxx +++ b/libbutl/path.cxx @@ -174,6 +174,10 @@ namespace butl LIBBUTL_EXPORT path_traits<char>::string_type path_traits<char>:: temp_name (string_type const& prefix) { + // Otherwise compiler get confused with butl::to_string(timestamp). + // + using std::to_string; + return prefix + "-" + to_string (process::current_id ()) + "-" + to_string (temp_name_count++); diff --git a/libbutl/process.cxx b/libbutl/process.cxx index af5cc73..53dd282 100644 --- a/libbutl/process.cxx +++ b/libbutl/process.cxx @@ -577,7 +577,7 @@ namespace butl case SIGXFSZ: return "file size limit exceeded (SIGXFSZ)"; case 0: return "status unknown"; - default: return "unknown signal " + to_string (signal ()); + default: return "unknown signal " + std::to_string (signal ()); } } diff --git a/libbutl/process.hxx b/libbutl/process.hxx index 799313e..1f82af0 100644 --- a/libbutl/process.hxx +++ b/libbutl/process.hxx @@ -9,6 +9,7 @@ # include <sys/types.h> // pid_t #endif +#include <string> #include <vector> #include <iosfwd> #include <cassert> @@ -477,8 +478,7 @@ namespace butl inline const char* process_arg_as (const T& x, std::string& storage) { - using namespace std; - return (storage = to_string (x)).c_str (); + return (storage = std::to_string (x)).c_str (); } inline const char* diff --git a/libbutl/timestamp.cxx b/libbutl/timestamp.cxx index 1f12f41..cf84dd5 100644 --- a/libbutl/timestamp.cxx +++ b/libbutl/timestamp.cxx @@ -10,6 +10,7 @@ #include <ctime> // tm, time_t, mktime() #include <cstdlib> // strtoull() #include <cassert> +#include <sstream> #include <iomanip> // put_time(), setw(), dec, right #include <cstring> // strlen(), memcpy() #include <ostream> @@ -219,6 +220,17 @@ namespace butl return os; } + string + to_string (const timestamp& ts, + const char* format, + bool special, + bool local) + { + ostringstream o; + to_stream (o, ts, format, special, local); + return o.str (); + } + ostream& operator<< (ostream& os, const duration& d) { @@ -338,7 +350,6 @@ extern "C" #include <ctime> // tm #include <locale> #include <clocale> -#include <sstream> #include <iomanip> #include <cstring> // strlen() diff --git a/libbutl/timestamp.hxx b/libbutl/timestamp.hxx index 1a960b7..9fb0f59 100644 --- a/libbutl/timestamp.hxx +++ b/libbutl/timestamp.hxx @@ -88,6 +88,15 @@ namespace butl bool special, bool local); + // Same as above, but provide the result as string. Note that it is + // implemented via to_stream() and std::ostringstream. + // + LIBBUTL_EXPORT std::string + to_string (const timestamp&, + const char* format, + bool special, + bool local); + inline std::ostream& operator<< (std::ostream& os, const timestamp& ts) { |