PrevUpHomeNext

utx::print_time, utx::print_time_to


utx::print_time and utx::print_time_to are very simple and convenient c++ functions to print std::chrono::time_point.

template <typename ... type_list>
inline void print_time(const type_list & ... tp_list);

utx::print_time can be used to print many time point values.

The out stream of utx::print_time is std::cout, and the delim (utx::delim) of utx::print_time is a newline character.

template <utx::kspt::ostreamable out_stream, typename ... type_list>
inline void print_time_to(out_stream & os, const utx::delim & deli,
	const type_list & ... tp_list);

Include

#include <utxcpp/core.hpp>

Notice

[Note] Note
  • utx::print_time separates each time point value by a newline character.
  • Only std::chrono::system_clock is accepted by utx::print_time and utx::print_time_to currently.

Example

#include <utxcpp/core.hpp>

int main()
{
	auto start = std::chrono::time_point<std::chrono::system_clock>{};
	auto now = std::chrono::system_clock::now();

	utx::print_time(now, start);
	utx::print_time(now);
	utx::print_time(start);

			// 0:0:0.0 1.1 1970+++10:58:27.109 11.24 2022+++
	utx::print_time_to(std::clog, "+++", start, now);
	std::clog << "\n\n";

			// 0:0:0.0 1.1 1970***
	utx::print_time_to(std::cerr, "***", start);
	std::cerr << "\n\n";

			// 1669287507109014233ns
	std::cout << (now-start) << '\n';

			// -1669287507109014233ns
	utx::print(start-now);
}

Last revised: November 24, 2022 at 11:26:05 GMT


PrevUpHomeNext