@@ -1064,13 +1064,28 @@ template <typename Char> struct named_arg_info {
1064
1064
int id;
1065
1065
};
1066
1066
1067
+ template <typename Char>
1068
+ FMT_CONSTEXPR void check_for_duplicate (named_arg_info<Char>* named_args,
1069
+ int named_arg_index,
1070
+ basic_string_view<Char> arg_name) {
1071
+ if (named_arg_index <= 0 ) return ;
1072
+
1073
+ for (auto i = 0 ; i < named_arg_index; ++i) {
1074
+ if (basic_string_view<Char>(named_args[i].name ) == arg_name) {
1075
+ report_error (" duplicate named args found" );
1076
+ }
1077
+ }
1078
+ }
1079
+
1067
1080
template <typename Char, typename T, FMT_ENABLE_IF(!is_named_arg<T>::value)>
1068
1081
void init_named_arg (named_arg_info<Char>*, int & arg_index, int &, const T&) {
1069
1082
++arg_index;
1070
1083
}
1084
+
1071
1085
template <typename Char, typename T, FMT_ENABLE_IF(is_named_arg<T>::value)>
1072
1086
void init_named_arg (named_arg_info<Char>* named_args, int & arg_index,
1073
1087
int & named_arg_index, const T& arg) {
1088
+ check_for_duplicate<Char>(named_args, named_arg_index, arg.name );
1074
1089
named_args[named_arg_index++] = {arg.name , arg_index++};
1075
1090
}
1076
1091
@@ -1084,6 +1099,7 @@ template <typename T, typename Char,
1084
1099
FMT_ENABLE_IF (is_static_named_arg<T>::value)>
1085
1100
FMT_CONSTEXPR void init_static_named_arg (named_arg_info<Char>* named_args,
1086
1101
int & arg_index, int & named_arg_index) {
1102
+ check_for_duplicate<Char>(named_args, named_arg_index, T::name);
1087
1103
named_args[named_arg_index++] = {T::name, arg_index++};
1088
1104
}
1089
1105
0 commit comments