Commit 5a93d99e authored by Dominik Charousset's avatar Dominik Charousset

Enable string conversion of STL duration types

parent 41ec1379
......@@ -19,10 +19,11 @@
#ifndef CAF_DETAIL_STRINGIFICATION_INSPECTOR_HPP
#define CAF_DETAIL_STRINGIFICATION_INSPECTOR_HPP
#include <string>
#include <vector>
#include <chrono>
#include <functional>
#include <string>
#include <type_traits>
#include <vector>
#include "caf/atom.hpp"
#include "caf/none.hpp"
......@@ -186,6 +187,48 @@ public:
}
}
/// Print duration types with nanosecond resolution.
template <class Rep>
void consume(std::chrono::duration<Rep, std::nano>& x) {
result_ += std::to_string(x.count());
result_ += "ns";
}
/// Print duration types with microsecond resolution.
template <class Rep>
void consume(std::chrono::duration<Rep, std::micro>& x) {
result_ += std::to_string(x.count());
result_ += "us";
}
/// Print duration types with millisecond resolution.
template <class Rep>
void consume(std::chrono::duration<Rep, std::milli>& x) {
result_ += std::to_string(x.count());
result_ += "ms";
}
/// Print duration types with second resolution.
template <class Rep>
void consume(std::chrono::duration<Rep, std::ratio<1>>& x) {
result_ += std::to_string(x.count());
result_ += "s";
}
/// Print duration types with minute resolution.
template <class Rep>
void consume(std::chrono::duration<Rep, std::ratio<60>>& x) {
result_ += std::to_string(x.count());
result_ += "min";
}
/// Print duration types with hour resolution.
template <class Rep>
void consume(std::chrono::duration<Rep, std::ratio<3600>>& x) {
result_ += std::to_string(x.count());
result_ += "h";
}
/// Fallback printing `<unprintable>`.
template <class T>
enable_if_t<
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment