From 0fab643858dfd2183cb545243d230d3ff84446b2 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Fri, 25 Jan 2019 15:17:37 +0000 Subject: Convert repetitive functions to use C++11 variadic templates. --- include/modules/stats.h | 90 ++----------------------------------------------- include/modules/whois.h | 40 ++-------------------- 2 files changed, 6 insertions(+), 124 deletions(-) (limited to 'include/modules') diff --git a/include/modules/stats.h b/include/modules/stats.h index e69070c9f..0d82f9f9a 100644 --- a/include/modules/stats.h +++ b/include/modules/stats.h @@ -97,95 +97,11 @@ class Stats::Context */ void AddRow(const Row& row) { rows.push_back(row); } - template - void AddRow(unsigned int numeric, T1 p1) + template + void AddRow(unsigned int numeric, Param... p) { Row n(numeric); - n.push(p1); - AddRow(n); - } - - template - void AddRow(unsigned int numeric, T1 p1, T2 p2) - { - Row n(numeric); - n.push(p1); - n.push(p2); - AddRow(n); - } - - template - void AddRow(unsigned int numeric, T1 p1, T2 p2, T3 p3) - { - Row n(numeric); - n.push(p1); - n.push(p2); - n.push(p3); - AddRow(n); - } - - template - void AddRow(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4) - { - Row n(numeric); - n.push(p1); - n.push(p2); - n.push(p3); - n.push(p4); - AddRow(n); - } - - template - void AddRow(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5) - { - Row n(numeric); - n.push(p1); - n.push(p2); - n.push(p3); - n.push(p4); - n.push(p5); - AddRow(n); - } - - template - void AddRow(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6) - { - Row n(numeric); - n.push(p1); - n.push(p2); - n.push(p3); - n.push(p4); - n.push(p5); - n.push(p6); - AddRow(n); - } - - template - void AddRow(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6, T7 p7) - { - Row n(numeric); - n.push(p1); - n.push(p2); - n.push(p3); - n.push(p4); - n.push(p5); - n.push(p6); - n.push(p7); - AddRow(n); - } - - template - void AddRow(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6, T7 p7, T8 p8) - { - Row n(numeric); - n.push(p1); - n.push(p2); - n.push(p3); - n.push(p4); - n.push(p5); - n.push(p6); - n.push(p7); - n.push(p8); + n.push(std::forward(p)...); AddRow(n); } }; diff --git a/include/modules/whois.h b/include/modules/whois.h index 4f09d268b..6cde7b29c 100644 --- a/include/modules/whois.h +++ b/include/modules/whois.h @@ -97,45 +97,11 @@ class Whois::Context /** Send a line of WHOIS data to the source of the WHOIS */ - template - void SendLine(unsigned int numeric, T1 p1) + template + void SendLine(unsigned int numeric, Param... p) { Numeric::Numeric n(numeric); - n.push(target->nick); - n.push(p1); - SendLine(n); - } - - template - void SendLine(unsigned int numeric, T1 p1, T2 p2) - { - Numeric::Numeric n(numeric); - n.push(target->nick); - n.push(p1); - n.push(p2); - SendLine(n); - } - - template - void SendLine(unsigned int numeric, T1 p1, T2 p2, T3 p3) - { - Numeric::Numeric n(numeric); - n.push(target->nick); - n.push(p1); - n.push(p2); - n.push(p3); - SendLine(n); - } - - template - void SendLine(unsigned int numeric, T1 p1, T2 p2, T3 p3, T4 p4) - { - Numeric::Numeric n(numeric); - n.push(target->nick); - n.push(p1); - n.push(p2); - n.push(p3); - n.push(p4); + n.push(std::forward(p)...); SendLine(n); } -- cgit v1.3.1-10-gc9f91