Directly initialize variable from std::istream For some time it has been bothering me that there is apparently no way to directly initialize variables from input streams (something like int i &lt;&lt; std::cin;)

My solution is this:

#include &lt;iostream&gt;
#include &lt;iomanip&gt;
#include &lt;string&gt;

template&lt;class T&gt;
T get(std::istream&amp; in){
    T tmp;
    in &gt;&gt; tmp;
    return tmp;
}

template&lt;class T,class A, class... ARGS&gt;
T get(std::istream&amp; in, A&amp; arg, ARGS&amp;... args){
    in &gt;&gt; arg;
    return get&lt;T&gt;(in, args...);
}

int main() {
    int i = get&lt;int&gt;(std::cin);
    std::cout &lt;&lt; i &lt;&lt; std::endl;

    std::string s = get&lt;std::string&gt;(std::cin , std::setw(5));
    std::cout &lt;&lt; s &lt;&lt; std::endl;
}


I'd like to know if 


I can improve something on the design 
There are serious performance implications
There are corner cases where this will not work or even worse produce silent errors.
I've overlooked any standard functions/classes that already implement that functionality.
There are corner cases where this will not work or even worse produce silent errors.


The function as it is, depends on the client to check for errors on the stream (either by calling std::cin.exceptions(std::ifstream::failbit); or by checking the stream state, after the call to get).

Ideally, I would want to write:

if(auto a = get&lt;int&gt;(std::cin))
    // use a here


Maybe you could add something like this to your solution:

template&lt;class T&gt;
boost::optional&lt;T&gt; get_optional(std::istream&amp; in){
    T tmp;
    in &gt;&gt; tmp;
    return (in) ?
        boost::optional&lt;T&gt;{ std::move(tmp) } :
        boost::optional&lt;T&gt;{};
}