Skip to content

Commit 8cee8d3

Browse files
committed
Fix MSVC warnings
1 parent 0c1d6e2 commit 8cee8d3

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

include/inja/environment.hpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ class Environment {
3131
using BasicArg = std::remove_const_t<
3232
std::remove_pointer_t<std::remove_reference_t<std::decay_t<Arg>>>>;
3333

34-
constexpr bool check = std::is_const_v<std::remove_reference_t<Arg>> ||
34+
static constexpr bool check =
35+
std::is_const_v<std::remove_reference_t<Arg>> ||
3536
std::is_same_v<BasicArg, Arg>;
3637
static_assert(check, "Arguments should be either const& or a value type");
3738

@@ -49,7 +50,8 @@ class Environment {
4950
function_signature::ArgsList<Args...> /*args*/,
5051
std::index_sequence<Is...> /*seq*/) {
5152
add_callback(name, sizeof...(Args),
52-
[func = std::move(func)](const Arguments &args) -> json {
53+
[func = std::move(func)] //
54+
([[maybe_unused]] const Arguments &args) -> json {
5355
if constexpr (std::is_same_v<Ret, void>) {
5456
func(get_callback_argument<Args>(args, Is)...);
5557
return {};
@@ -217,17 +219,18 @@ class Environment {
217219
*/
218220
template <class Callback>
219221
void add_callback(const std::string &name, Callback callback) {
220-
constexpr auto get_sig = [] {
222+
static constexpr auto get_sig = [] {
221223
if constexpr (std::is_class_v<Callback>) {
222224
return function_signature::Get<decltype(&Callback::operator())> {};
223225
} else {
224226
return function_signature::Get<Callback>{};
225227
}
226228
};
227229
using Sig = decltype(get_sig());
228-
constexpr size_t num_args = std::tuple_size_v<typename Sig::ArgsTuple>;
230+
static constexpr size_t num_args =
231+
std::tuple_size_v<typename Sig::ArgsTuple>;
229232

230-
constexpr auto is_arguments_vector = [] {
233+
static constexpr auto is_arguments_vector = [] {
231234
if constexpr (num_args == 1) {
232235
return std::is_same_v<
233236
std::remove_cv_t<std::remove_reference_t<

single_include/inja/inja.hpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2830,7 +2830,8 @@ class Environment {
28302830
using BasicArg = std::remove_const_t<
28312831
std::remove_pointer_t<std::remove_reference_t<std::decay_t<Arg>>>>;
28322832

2833-
constexpr bool check = std::is_const_v<std::remove_reference_t<Arg>> ||
2833+
static constexpr bool check =
2834+
std::is_const_v<std::remove_reference_t<Arg>> ||
28342835
std::is_same_v<BasicArg, Arg>;
28352836
static_assert(check, "Arguments should be either const& or a value type");
28362837

@@ -2848,7 +2849,8 @@ class Environment {
28482849
function_signature::ArgsList<Args...> /*args*/,
28492850
std::index_sequence<Is...> /*seq*/) {
28502851
add_callback(name, sizeof...(Args),
2851-
[func = std::move(func)](const Arguments &args) -> json {
2852+
[func = std::move(func)] //
2853+
([[maybe_unused]] const Arguments &args) -> json {
28522854
if constexpr (std::is_same_v<Ret, void>) {
28532855
func(get_callback_argument<Args>(args, Is)...);
28542856
return {};
@@ -3016,17 +3018,18 @@ class Environment {
30163018
*/
30173019
template <class Callback>
30183020
void add_callback(const std::string &name, Callback callback) {
3019-
constexpr auto get_sig = [] {
3021+
static constexpr auto get_sig = [] {
30203022
if constexpr (std::is_class_v<Callback>) {
30213023
return function_signature::Get<decltype(&Callback::operator())> {};
30223024
} else {
30233025
return function_signature::Get<Callback>{};
30243026
}
30253027
};
30263028
using Sig = decltype(get_sig());
3027-
constexpr size_t num_args = std::tuple_size_v<typename Sig::ArgsTuple>;
3029+
static constexpr size_t num_args =
3030+
std::tuple_size_v<typename Sig::ArgsTuple>;
30283031

3029-
constexpr auto is_arguments_vector = [] {
3032+
static constexpr auto is_arguments_vector = [] {
30303033
if constexpr (num_args == 1) {
30313034
return std::is_same_v<
30323035
std::remove_cv_t<std::remove_reference_t<

0 commit comments

Comments
 (0)