]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Simplify array_of using types deduction
authorVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 11 Jun 2022 11:24:23 +0000 (12:24 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Sat, 11 Jun 2022 11:24:23 +0000 (12:24 +0100)
src/client/rspamc.cxx
src/libserver/html/html_tag_defs.hxx
src/libutil/cxx/util.hxx

index 2a2332bca43f197e83bcf90794367cd1a07366b9..b7341be4f0a8217abea90daf066e4576aae55db9 100644 (file)
@@ -214,7 +214,7 @@ struct rspamc_command {
        void (*command_output_func)(FILE *, ucl_object_t *obj);
 };
 
-static const constexpr auto rspamc_commands = rspamd::array_of<rspamc_command>(
+static const constexpr auto rspamc_commands = rspamd::array_of(
                rspamc_command{
                                .cmd = RSPAMC_COMMAND_SYMBOLS,
                                .name = "symbols",
index 7e6cc9bf6f1a62339572933f0b059dc8f9450c99..812ec202181c4e16258bf4cfc8cbd59180dd74df 100644 (file)
@@ -33,7 +33,7 @@ struct html_tag_def {
 
 #define TAG_DEF(id, name, flags) html_tag_def{(name), (id), (flags)}
 
-static const auto html_tag_defs_array = rspamd::array_of<html_tag_def>(
+static const auto html_tag_defs_array = rspamd::array_of(
                /* W3C defined elements */
                TAG_DEF(Tag_A, "a", FL_HREF),
                TAG_DEF(Tag_ABBR, "abbr", (CM_INLINE)),
index e45f16008a50d15372110baf653287c025b8856c..5b2020bb6684944537402392e3e44b5f85de7538 100644 (file)
@@ -72,9 +72,10 @@ struct smart_ptr_hash {
 /*
  * Creates std::array from a standard C style array with automatic size calculation
  */
-template <typename V, typename... T>
-constexpr auto array_of(T&&... t) -> std::array<V, sizeof...(T)>
+template <typename... Ts>
+constexpr auto array_of(Ts&&... t) -> std::array<typename std::decay_t<typename std::common_type_t<Ts...>>, sizeof...(Ts)>
 {
+       using T = typename std::decay_t<typename std::common_type_t<Ts...>>;
        return {{ std::forward<T>(t)... }};
 }