Моя среда — Linux, gcc 14.1 и -std=c++23.
Мои определения:
namespace MyTime {
using clock_t = std::chrono::system_clock;
using duration_t = clock_t::duration;
using time_point_t = std::chrono::zoned_time;
time_point_t now()
{
return std::chrono::zoned_time{std::chrono::current_zone(), clock_t::now()};
}
std::string to_string(time_point_t tp)
{
std::ostringstream oss;
oss > std::chrono::parse("%Y-%m-%dT%T%Z",tp);
return tp;
}
}
MyTime::from_string(std::string_view str) выдает ошибку компиляции.
Как это успешно скомпилировать?
Смотрите на godbolt
https:// godbolt.org/z/Ysoeqe9zz
РЕДАКТИРОВАНИЕ: сообщение об ошибке.
source>: In function 'MyTime::time_point_t MyTime::from_string(std::string_view)':
:27:30: error: no matching function for call to 'parse(const char [14], MyTime::time_point_t&)'
27 | iss >> std::chrono::parse("%Y-%m-%dT%T%Z",tp);
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
In file included from /opt/compiler-explorer/gcc-14.1.0/include/c++/14.1.0/chrono:3360,
from :1:
/opt/compiler-explorer/gcc-14.1.0/include/c++/14.1.0/bits/chrono_io.h
2982 | parse(const _CharT* __fmt, _Parsable& __tp)
| ^~~~~
Подробнее здесь: https://stackoverflow.com/questions/788 ... zoned-time
Мобильная версия