# Class Template `filter`

Description
Headers
Reference

## Description

The class templates `filter`, `wfilter`, `multichar_filter`, `multichar_wfilter` and their specializations are provided by the Iostreams library for use as base classes for user-defined Filters. These base classes supply the member types `char_type` and `category` used internally by the Iostreams library to classify filters.

The supplied `category` member is convertible to `closable_tag` and to `localizable_tag`. This allows users to define models of the concepts Closable and Localizable simply by providing definitions of member functions `close` and `imbue`.

## Headers

`<boost/iostreams/concepts.hpp>`

## Reference

### Synopsis

    namespace boost{ namespace iostreams {

    template<typename Mode, typename Ch = char>
    struct filter;

    template<typename Mode, typename Ch = wchar_t>
    struct wfilter : filter<Mode, Ch> { };

    typedef filter<input>      input_filter;
    typedef wfilter<input>     input_wfilter;
    typedef filter<output>     output_filter;
    typedef wfilter<output>    output_wfilter;
    typedef filter<seekable>   seekable_filter;
    typedef wfilter<seekable>  seekable_wfilter;
    typedef filter<dual_use>   dual_use_filter;
    typedef wfilter<dual_use>  dual_use_wfilter;

    template<typename Mode, typename Ch = char>
    struct multichar_filter : filter {
        typedef see below  category;
    };

    template<typename Mode, typename Ch = wchar_t>
    struct multichar_wfilter : multichar_filter<Mode, Ch> { };

    typedef multichar_filter<input>     multichar_input_filter;
    typedef multichar_filter<input>     multichar_input_wfilter;
    typedef multichar_filter<output>    multichar_output_filter;
    typedef multichar_filter<output>    multichar_output_wfilter;
    typedef multichar_filter<dual_use>  multichar_dual_use_filter;
    typedef multichar_filter<dual_use>  multichar_dual_use_wfilter;

    template<typename Mode, typename Ch = char>
    struct filter {
        typedef Ch         char_type;
        typedef see below  category;

        template<typename Device>
        void close(Device&);

        template<typename Device>
        void close(std::ios_base::openmode, Device&);

        void imbue(const std::locale&);
    };

    } } // End namespace boost::io

### Class Template `filter`

#### Description

Convenience base class for defining Filters

#### Template parameters

Mode | - | A mode tag.
Ch | - | The character type

#### `filter::category`

        typedef see below category;

A category tag convertible to `Mode`, `filter_tag`, `closable_tag` and `localizable_tag`.

#### `filter::close`

        template<typename Device>
        void close(Device&);

        template<typename Device>
        void close(std::ios_base::openmode, Device&);

Both overloads are implemented as no-ops. The second is available only if Mode is convertible to `bidirectional`. The first is available only if Mode is not convertible to `bidirectional`.

Required by Closable.

#### `filter::imbue`

        void imbue(const std::locale&);

Implemented as a no-op. Required by Localizable.

### Class Template `multichar_filter`

#### Description

Convenience base class for defining Multi-Character Filters. Derived class of `filter` whose member type `category` is convertible to the template parameter Mode and to `multichar_filter_tag`, `closable_tag` and `localizable_tag`.

#### Template parameters

Mode | - | A mode tag.
Ch | - | The character type

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)