Я использую изображение Docker GCC 15.1.0. Я запускал свой код C ++, но я столкнулся с очень странной проблемой, которую я не могу решить. Прикрепление минимального воспроизведения (я не могу удалить импорт внутри main.cpp файл внутри моей кодовой базы, воспроизведение - это разделенный код из моей кодовой базы):
root@b92b45f832fe:~# g++ --version
g++ (GCC) 15.1.0
Copyright (C) 2025 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
root@b92b45f832fe:~# ls -l
total 8
-rw-r--r-- 1 root root 452 May 11 20:53 format.ixx
-rw-r--r-- 1 root root 109 May 11 20:53 main.cpp
root@b92b45f832fe:~# cat format.ixx
module;
#include
#include
export module utils.format;
export template
struct std::formatter : std::formatter {
constexpr auto format(const auto& opt, auto& ctx) const {
if (opt.has_value())
return std::formatter::format(std::format("{0}", opt.value()), ctx);
return std::formatter::format("Optional[null]", ctx);
}
};
root@b92b45f832fe:~# cat main.cpp
#include
import utils.format;
int main() {
const auto x = std::format("{:*>4}", 2);
}
root@b92b45f832fe:~# g++ format.ixx main.cpp -fmodules -std=c++23
root@b92b45f832fe:~# ./a.out
terminate called after throwing an instance of 'std::format_error'
what(): format error: invalid width or precision in format-spec
Aborted
root@b92b45f832fe:~#
< /code>
Кто -то знает, как это решить? Строка формата должна работать здесь. // N.B. std::from_chars is not constexpr in C++20.
if (__detail::__from_chars_alnum(__first, __last, __val, 10)
Подробнее здесь: [url]https://stackoverflow.com/questions/79616922/unable-to-use-stdformat-for-integer-formatting-gcc-15-1-0[/url]
Я использую изображение Docker GCC 15.1.0. Я запускал свой код C ++, но я столкнулся с очень странной проблемой, которую я не могу решить. Прикрепление минимального воспроизведения (я не могу удалить импорт внутри main.cpp файл внутри моей кодовой базы, воспроизведение - это разделенный код из моей кодовой базы): [code]root@b92b45f832fe:~# g++ --version g++ (GCC) 15.1.0 Copyright (C) 2025 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
root@b92b45f832fe:~# ls -l total 8 -rw-r--r-- 1 root root 452 May 11 20:53 format.ixx -rw-r--r-- 1 root root 109 May 11 20:53 main.cpp root@b92b45f832fe:~# cat format.ixx module; #include #include
int main() { const auto x = std::format("{:*>4}", 2); }
root@b92b45f832fe:~# g++ format.ixx main.cpp -fmodules -std=c++23 root@b92b45f832fe:~# ./a.out terminate called after throwing an instance of 'std::format_error' what(): format error: invalid width or precision in format-spec Aborted root@b92b45f832fe:~# < /code> Кто -то знает, как это решить? Строка формата должна работать здесь. // N.B. std::from_chars is not constexpr in C++20. if (__detail::__from_chars_alnum(__first, __last, __val, 10)