Skip to content

Commit eafa8f3

Browse files
committed
fable,runtime: Use fmt::runtime() to ensure C++20 compatibility
1 parent 650d0a8 commit eafa8f3

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

fable/include/fable/conf.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ class Conf {
332332

333333
template <typename... Args>
334334
[[noreturn]] void throw_error(std::string_view format, Args&&... args) const {
335-
throw_error(fmt::format(format, std::forward<Args>(args)...));
335+
throw_error(fmt::format(fmt::runtime(format), std::forward<Args>(args)...));
336336
}
337337
[[noreturn]] void throw_error(const std::string& msg) const;
338338
[[noreturn]] void throw_unexpected(const std::string& key, const std::string& msg = "") const;

fable/include/fable/error.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class Error : public std::exception {
5252

5353
template <typename... Args>
5454
explicit Error(std::string_view format, Args&&... args)
55-
: message_(fmt::format(format, std::forward<Args>(args)...)) {}
55+
: message_(fmt::format(fmt::runtime(format), std::forward<Args>(args)...)) {}
5656

5757
[[nodiscard]] const char* what() const noexcept override { return message_.c_str(); }
5858
};

runtime/include/cloe/core/error.hpp

+6-5
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ class Error : public std::exception {
3636
explicit Error(const char* what) : err_(what) {}
3737

3838
template <typename... Args>
39-
explicit Error(const char* format, const Args&... args) : err_(fmt::format(format, args...)) {}
39+
Error(std::string_view format, Args&&... args)
40+
: err_(fmt::format(fmt::runtime(format), std::forward<Args>(args)...)) {}
4041

4142
virtual ~Error() noexcept = default;
4243

@@ -47,8 +48,8 @@ class Error : public std::exception {
4748
void set_explanation(const std::string& explanation);
4849

4950
template <typename... Args>
50-
void set_explanation(const char* format, const Args&... args) {
51-
set_explanation(fmt::format(format, args...));
51+
void set_explanation(std::string_view format, Args&&... args) {
52+
set_explanation(fmt::format(fmt::runtime(format), std::forward<Args>(args)...));
5253
}
5354

5455
const std::string& explanation() const { return explanation_; }
@@ -59,8 +60,8 @@ class Error : public std::exception {
5960
}
6061

6162
template <typename... Args>
62-
Error explanation(const char* format, const Args&... args) && {
63-
set_explanation(fmt::format(format, args...));
63+
Error explanation(std::string_view format, Args&&... args) && {
64+
set_explanation(fmt::format(fmt::runtime(format), std::forward<Args>(args)...));
6465
return std::move(*this);
6566
}
6667

runtime/include/cloe/model.hpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ class ModelError : public Error {
7575
}
7676

7777
template <typename... Args>
78-
ModelError explanation(const char* format, const Args&... args) && {
79-
this->set_explanation(fmt::format(format, args...));
78+
ModelError explanation(std::string_view format, const Args&... args) && {
79+
this->set_explanation(fmt::format(fmt::runtime(format), args...));
8080
return std::move(*this);
8181
}
8282
};
@@ -100,8 +100,8 @@ class ModelAbort : public ModelError {
100100
}
101101

102102
template <typename... Args>
103-
ModelError explanation(const char* format, const Args&... args) && {
104-
this->set_explanation(fmt::format(format, args...));
103+
ModelAbort explanation(std::string_view format, const Args&... args) && {
104+
this->set_explanation(fmt::format(fmt::runtime(format), args...));
105105
return std::move(*this);
106106
}
107107
};
@@ -123,8 +123,8 @@ class ModelReset : public ModelError {
123123
}
124124

125125
template <typename... Args>
126-
ModelError explanation(const char* format, const Args&... args) && {
127-
this->set_explanation(fmt::format(format, args...));
126+
ModelReset explanation(std::string_view format, const Args&... args) && {
127+
this->set_explanation(fmt::format(fmt::runtime(format), args...));
128128
return std::move(*this);
129129
}
130130
};
@@ -146,8 +146,8 @@ class ModelStop : public ModelError {
146146
}
147147

148148
template <typename... Args>
149-
ModelError explanation(const char* format, const Args&... args) && {
150-
this->set_explanation(fmt::format(format, args...));
149+
ModelStop explanation(std::string_view format, const Args&... args) && {
150+
this->set_explanation(fmt::format(fmt::runtime(format), args...));
151151
return std::move(*this);
152152
}
153153
};

0 commit comments

Comments
 (0)