make_format_args error: cannot bind non-const lvalue reference to an rvalue
uchenily opened this issue · 3 comments
/root/zedio/zedio/log/logger.hpp: In instantiation of ‘void zedio::log::detail::BaseLogger::format(const zedio::log::detail::FmtWithSourceLocation&, Args&& ...) [with zedio::log::detail::LogLevel LEVEL = zedio::log::detail::LogLevel::Error; Args = {std::basic_string_view<char, std::char_traits >}; DeriverLogger = zedio::log::detail::ConsoleLogger]’:
/root/zedio/zedio/log/logger.hpp:88:32: required from ‘void zedio::log::detail::BaseLogger::error(zedio::log::detail::FmtWithSourceLocation, Args&& ...) [with Args = {std::basic_string_view<char, std::char_traits >}; DeriverLogger = zedio::log::detail::ConsoleLogger]’
/root/zedio/tests/tcp_socket_test.cpp:37:5: required from here
/root/zedio/zedio/log/logger.hpp:125:62: error: cannot bind non-const lvalue reference of type ‘std::basic_string_view&’ to an rvalue of type ‘std::basic_string_view’
125 | std::vformat(fmt, std::make_format_args(std::forward(args)...))});
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13.2.1/format:3411:28: note: initializing argument 1 of ‘auto std::make_format_args(_Args& ...) [with _Context = basic_format_context<__format::_Sink_iter, char>; _Args = {basic_string_view<char, char_traits >}]’
3411 | make_format_args(_Args&... __fmt_args) noexcept
| ~~~~~~^~~~~~~~~~~~~~
[22/46] Building CXX object tests/CMakeFiles/queue_test.dir/queue_test.cpp.o
ninja: build stopped: subcommand failed.
make: *** [Makefile:3: build] Error 1
g++ --version
g++ (GCC) 13.2.1 20240417
升级GCC后出现的问题, 看起来是跟这个提案有关系
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2905r2.html
升级GCC后出现的问题, 看起来是跟这个提案有关系
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2905r2.html
看完了,确实不应该用forward,你可以把你的更改传上来,我到时候合并。
前面忘记提交了, 现在补上, 另外format的参数改成了const Args &...args