#pragma once #include namespace utils { /* * Variadic argument print */ template void print_vargs(std::ostream& s, Head&& head) { s << std::forward(head); } template void print_vargs(std::ostream& s, Head&& head, Tail&& ...tail) { s << std::forward(head); print_vargs(s, std::forward(tail)...); } /* * Compile time print line. * * USAGE: * RUN: utils::printer("ONE ", "TWO"); * OUTPUT: "ONE TWO\n" * * TODO: reimplament with C++17 fold expressions */ template void println(Args&&... args) { print_vargs(std::cout, std::forward(args)...); std::cout << std::endl; } // value equality with any of variadic argument // example: value == varg[0] OR value == varg[1] OR ... template bool _or_vargs(Value&& value, Head&& head) { return value == head; } template bool _or_vargs(Value&& value, Head&& head, Tail&& ...tail) { return value == head || _or_vargs(std::forward(value), tail...); } template bool or_vargs(Value&& value, Array&&... array) { return _or_vargs(std::forward(value), std::forward(array)...); } }