@@ -214,10 +214,14 @@ void stop [[noreturn]] (const std::string& fmt_arg, Args&&... args) {
214214 safe.noreturn (Rf_errorcall)(R_NilValue, " %s" , msg.c_str ());
215215}
216216
217- // Always making copy of string to avoid weird unwind behavior.
217+ template <typename ... Args>
218+ void warning (const char * fmt_arg, Args&&... args) {
219+ std::string msg = fmt::format (fmt_arg, std::forward<Args>(args)...);
220+ safe[Rf_warningcall](R_NilValue, " %s" , msg.c_str ());
221+ }
218222
219223template <typename ... Args>
220- void warning (const std::string fmt_arg, Args&&... args) {
224+ void warning (const std::string& fmt_arg, Args&&... args) {
221225 std::string msg = fmt::format (fmt_arg, std::forward<Args>(args)...);
222226 safe[Rf_warningcall](R_NilValue, " %s" , msg.c_str ());
223227}
@@ -232,10 +236,13 @@ void stop [[noreturn]] (const std::string& fmt, Args... args) {
232236 safe.noreturn (Rf_errorcall)(R_NilValue, fmt.c_str (), args...);
233237}
234238
235- // Always making copy of string to avoid weird unwind behavior.
239+ template <typename ... Args>
240+ void warning (const char * fmt, Args... args) {
241+ safe[Rf_warningcall](R_NilValue, fmt, args...);
242+ }
236243
237244template <typename ... Args>
238- void warning (const std::string fmt, Args... args) {
245+ void warning (const std::string& fmt, Args... args) {
239246 safe[Rf_warningcall](R_NilValue, fmt.c_str (), args...);
240247}
241248#endif
0 commit comments