At the heart of the implementation of a stream iis an associated stream buffer.
The stream buffer deals with the buffering and transportation of characters to or from the target or source device.
out << in.rdbuf() extracts characters one by one from the input sequence controlled by the stream buffer and writes them into out till eof occurs on input, or the output fails.
Overload (8) in: http://en.cppreference.com/w/cpp/io/basic_ostream/operator_ltlt
> The thing is that the constructor does not return any value,
> so how could you know if the constructor succeeded or not to create a copy of the file?
First of all there are things that just can’t be done right without exceptions. Consider an error detected in a constructor; how do you report the error? You throw an exception. That’s the basis of RAII (Resource Acquisition Is Initialization), which is the basis of some of the most effective modern C++ design techniques: A constructor’s job is to establish the invariants for the class (create the environment in which the member functions are to run) and that often requires the acquisition of resources, such as memory, locks, files, sockets, etc. https://isocpp.org/wiki/faq/exceptions