Отображение steady_clock :: own () с использованием библиотеки FMTC++

Программы на C++. Форум разработчиков
Ответить
Anonymous
 Отображение steady_clock :: own () с использованием библиотеки FMT

Сообщение Anonymous »

Я могу отобразить текущее время, используя библиотеку C ++ FMT с использованием std :: chrono :: system_clock и std :: chrono :: high_resolution_clock , но невозможно отобразить время, используя std :: chrono :: adstey_clock . class = "lang-cpp prettyprint-override">

Код: Выделить всё

#include 
#include 
#include 
#include 
#include 

int main()
{
fmt::print("current time: {:%Y-%m-%d %H:%M:%S.%z}\n", std::chrono::system_clock::now());
fmt::print("current time: {:%Y-%m-%d %H:%M:%S.%z}\n", std::chrono::high_resolution_clock::now());
// fmt::print("current time: {:%Y-%m-%d %H:%M:%S.%z}\n", std::chrono::steady_clock::now());
}
< /code>
output: < /p>
current time: 2023-02-25 11:08:43.+0000
current time: 2023-02-25 11:08:43.+0000
< /code>
Когда я разместил последнюю строку, я получаю следующую ошибку: < /p>
In file included from :12:
/opt/compiler-explorer/libs/fmt/9.1.0/include/fmt/core.h:1756:3: error: static assertion failed due to requirement 'formattable': Cannot format an argument. To make type T formattable provide a formatter specialization: https://fmt.dev/latest/api.html#udt
static_assert(
^
/opt/compiler-explorer/libs/fmt/9.1.0/include/fmt/core.h:1777:10: note: in instantiation of function template specialization 'fmt::detail::make_value' requested here
return make_value(val);
^
/opt/compiler-explorer/libs/fmt/9.1.0/include/fmt/core.h:1899:23: note: in instantiation of function template specialization 'fmt::detail::make_arg' requested here
data_{detail::make_arg<
^
/opt/compiler-explorer/libs/fmt/9.1.0/include/fmt/core.h:1918:10: note: in instantiation of function template specialization 'fmt::format_arg_store::format_arg_store' requested here
return {FMT_FORWARD(args)...};
^
/opt/compiler-explorer/libs/fmt/9.1.0/include/fmt/core.h:3294:28: note: in instantiation of function template specialization 'fmt::make_format_args' requested here
const auto& vargs = fmt::make_format_args(args...);
^
:23:10: note: in instantiation of function template specialization 'fmt::print' requested here
fmt::print("current time: {:%Y-%m-%d %H:%M:%S.%z}\n", std::chrono::steady_clock::now());
^
1 error generated.
Почему fmt библиотека не поддерживает время отображения с использованием std :: chrono :: atever_clock :: now () ?

Подробнее здесь: https://stackoverflow.com/questions/755 ... mt-library
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»