diff --git a/hardware/arduino/avr/cores/arduino/Print.h b/hardware/arduino/avr/cores/arduino/Print.h index 7b53aa4d17e..bc039b20f1b 100644 --- a/hardware/arduino/avr/cores/arduino/Print.h +++ b/hardware/arduino/avr/cores/arduino/Print.h @@ -79,6 +79,52 @@ class Print size_t println(double, int = 2); size_t println(const Printable&); size_t println(void); + + // Addition by NicoHood + template + inline size_t print(const First& first, const Second& second, const Third& third, const Rest&... rest) { + // A Wrapper is needed here in order to not call the + // Formatted functions if the input was three integers + // If you input only two integers the formatted + // Functions have higher priority + return printWrapper(first, second, third, rest...); + } + + template + inline size_t printWrapper(const First& first) { + return print(first); + } + + template + inline size_t printWrapper(const First& first, const Rest&... rest) { + size_t r = 0; + r+=print(first); + r+=printWrapper(rest...); // recursive call using pack expansion syntax + return r; + } + + template + inline size_t println(const First& first, const Second& second, const Third& third, const Rest&... rest) { + // A Wrapper is needed here in order to not call the + // Formatted functions if the input was three integers + // If you input only two integers the formatted + // Functions have higher priority + return printlnWrapper(first, second, third, rest...); + } + + template + inline size_t printlnWrapper(const First& first) { + return println(first); + } + + template + inline size_t printlnWrapper(const First& first, const Rest&... rest) { + size_t r = 0; + r+=print(first); + r+=printlnWrapper(rest...); // recursive call using pack expansion syntax + return r; + } + }; #endif