# Function Template `copy`

Description
Headers
Synopsis

## Description

The function template `copy` reads data from a given model of Source and writes it to a given model of Sink until the end of stream is reached. It then closes both components, using the function template `close`, and returns the number of characters written.

The size of the temporary buffer used may be supplied as an optional parameter.

There are four overloads of `copy` to accommodate all combinations of Sources and Sinks, which are passed by `const` reference, and streams and stream buffers, which are passed by non-`const` reference.

## Headers

`<boost/iostreams/copy.hpp>`

## Synopsis

    namespace boost { namespace iostreams {

    template<typename Source, typename Sink>
    std::streamsize
    copy( [const] Source& src, [const] Sink& sink,
          std::streamsize buffer_size = default value );

    } } // End namespace boost::io

Revised 20 May, 2004

© Copyright Jonathan Turkanis, 2004

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)