# Boost.Flyweight Holders reference

Factories
Boost.Flyweight reference
Locking policies

## Contents

- Holders and holder specifiers
- Header `"boost/flyweight/holder_tag.hpp"` synopsis
  - Class template `is_holder`
  - Class template `holder`
- Header `"boost/flyweight/static_holder_fwd.hpp"` synopsis
- Header `"boost/flyweight/static_holder.hpp"` synopsis
  - Class template `static_holder_class`
  - Class `static_holder`
- Header `"boost/flyweight/intermodule_holder_fwd.hpp"` synopsis
- Header `"boost/flyweight/intermodule_holder.hpp"` synopsis
  - Class template `intermodule_holder_class`
  - Class `intermodule_holder`

## Holders and holder specifiers

Given a type `C`, a type `Holder` is said to be a holder of `C` if the expression `Holder::get()` returns a reference to a default initialized `C` object unique to `Holder`. No invocation of `Holder::get()`, except possibly the first one in the program, does throw. `flyweight` privately uses a holder to instantiate a factory and some additional data (like a mutex for internal synchronization) unique to each instantiation type of the class template.

A type `S` is a holder specifier if:

1. One of the following conditions is satisfied:
   1. `is_holder<S>::type` is `boost::mpl::true_`,
   2. `S` is of the form `holder<S'>`.
2. `S`, or `S'` if (b) applies, is an `MPL Lambda Expression` such that invoking it with type `C` resolves to a holder of `C`.

## Header `"boost/flyweight/holder_tag.hpp"` synopsis

>     namespace boost{

>     namespace flyweights{

>     struct holder_marker;

>     template<typename T>
>     struct is_holder;

>     template<typename T>
>     struct holder;

>     } // namespace boost::flyweights

>     } // namespace boost

### Class template `is_holder`

Unless specialized by the user, `is_holder<T>::type` is `boost::mpl::true_` if `T` is derived from `holder_marker`, and it is `boost::mpl::false_` otherwise.

### Class template `holder`

`holder<T>` is a syntactic construct meant to indicate that `T` is a holder specifier without resorting to the mechanisms provided by the `is_holder` class template.

## Header `"boost/flyweight/static_holder_fwd.hpp"` synopsis

>     namespace boost{

>     namespace flyweights{

>     template<typename C>
>     struct static_holder_class;

>     struct static_holder;

>     } // namespace boost::flyweights

>     } // namespace boost

`static_holder_fwd.hpp` forward declares `static_holder_class` and `static_holder`.

## Header `"boost/flyweight/static_holder.hpp"` synopsis

### Class template `static_holder_class`

`static_holder_class<C>` keeps its unique instance of `C` as a local static object.

### Class `static_holder`

`Holder Specifier` for `static_holder_class`.

## Header `"boost/flyweight/intermodule_holder_fwd.hpp"` synopsis

>     namespace boost{

>     namespace flyweights{

>     template<typename C>
>     struct intermodule_holder_class;

>     struct intermodule_holder;

>     } // namespace boost::flyweights

>     } // namespace boost

`intermodule_holder_fwd.hpp` forward declares `intermodule_holder_class` and `intermodule_holder`.

## Header `"boost/flyweight/intermodule_holder.hpp"` synopsis

### Class template `intermodule_holder_class`

`intermodule_holder_class<C>` maintains a `C` instance which is unique even across different dynamically linked modules of the program using this same type. In general, this guarantee is not provided by `static_holder_class`, as most C++ implementations are not able to merge duplicates of static variables stored in different dynamic modules of a program.

### Class `intermodule_holder`

`Holder Specifier` for `intermodule_holder_class`.

Factories
Boost.Flyweight reference
Locking policies

Revised August 11th 2008

© Copyright 2006-2008 Joaquín M López Muñoz. 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)