Header-only variadic console output and runtime input validation in C++ using templates
Comment

First question is why I would use this instead of the standard operator&lt;&lt; that we are all very familiar with?

Code Review

Reserved Identifiers

Identifiers with a prefix underscore and an initial capital letter are reserved in all contexts for the implementations. i.e. You are not allowed to use them.

So _INPUT_VALIDATION_HPP is an illegal identifier (for you).

The rules on leading underscore are complex. Even if you know the rules, most people don't, so avoid at all costs.

If you must, then make it a trailing underscore.

Manipulator support.

You have not provided support for stream manipulators (std::hex etc..).

std::endl or '\n'

Prefer '\n' over std::endl;. The difference is that std::endl also forces a flush. Manually forcing a flush is 99.99% of the time incorrect as the stream will automatically flush at the optimal times; doing it manually like this will severely degrade performance.

Recursive over iterative templates.

You use a recursive template design. Personally I prefer the iterative approach as it is more compact (and in my opinion readable).

// You recursive approach.
template &lt;typename T&gt;
void print(const T&amp; input)
{
    std::cout &lt;&lt; input &lt;&lt; ' ';
}


template &lt;typename T, typename... Types&gt;
void print(const T&amp; firstArg, const Types&amp;... arguments)
{
    std::cout &lt;&lt; firstArg &lt;&lt; ' ';
    print(arguments...);
}


The alternative:

// The iterative approach.
template &lt;typename T, typename... Types&gt;
void print(Types const&amp;... arguments)
{
    auto unused = {0, (std::cout &lt;&lt; arguments &lt;&lt; ' ', 0)...};
}


Get only half-checks.

In the get() function if it fails you drop the rest of the line and try again. This implies that the input is line based. BUT on success you don't check that the input is a whole line; you just check the line prefix.

// SO my code is.
int val = IO::get&lt;int&gt;();


// I type
10Ton


Then the above function accepts the input as good. But in my opinion that input should be considered to be incorrect as Ton is being ignored.