# Function Template `compose`

Description
Headers
Reference

## Description

Given a Filter `f` and a Device `d`, we may construct a device `c` whose member functions are implemented by invoking the fundamental i/o operations `read`, `write`, etc. with `f` as the first argument and `d` as the second. Similarly, if we are given two filters `f1` and `f2`, we may construct a third filter `f3` whose member function templates are implemented by invoking the fundamental i/o operations `read`, `write`, etc., with first argument equal to `f1` and second argument equal to the result of composing `f2` with the provided Device.

The function template `composite` represents a Filter or Device which has been constructed in the above manner. The function template `compose` is an object generator which given a pair of components returns an appropriate instance of `composite`.

The mode of a `composite` is defined to provide a maximal subset of the common functionality of the two components. A `composite` is Closable, Flushable, Localizable and OptimallyBuffered.

## Headers

`<boost/iostreams/compose.hpp>`

## Reference

#### Synopsis

    namespace boost { namespace iostreams {

    template<typename Filter, typename FilterOrDevice>
    class composite {
    public:
        typedef typename char_type_of<Filter>::type  char_type;
        typedef implementation-defined               mode;

        composite(const Filter& first, [const] FilterOrDevice& second);

        // Filter or Device member functions
    };

    template<typename Filter, typename FilterOrDevice>
    composite<Filter, FilterOrDevice>
    compose(const Filter& first, [const] FilterOrDevice& second);

    } } // End namespace boost::io

## Class Template `composite`

#### Template parameters

Filter | - | A model of Filter
FilterOrDevice | - | A model of Filter or Device

#### `composite::composite`

        composite(const Filter& first, [const] FilterOrDevice& second);

Constructs an instance of `composite` based on the given components. If `FilterOrDevice` is a stream or stream buffer type, the second parameter is a non-`const` reference; otherwise it is a `const` reference.

## Function Template `compose`

        composite(const Filter& first, [const] FilterOrDevice& second);

#### Template parameters

Filter | - | A model of Filter
FilterOrDevice | - | A model of Filter or Device

Returns an instance of an appropriate specialization of `composite` constructed from the given components. If `FilterOrDevice` is a stream or stream buffer type, the second parameter is a non-`const` reference; otherwise it is a `const` reference.

Revised 02 Feb 2008

© Copyright 2008 CodeRage, LLC
© Copyright 2004-2007 Jonathan Turkanis

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)