Boost.Flyweight Documentation - Key-value flyweights reference

# Key-value flyweights reference

`flyweight` reference
Boost.Flyweight reference
Tags

## Contents

- Key extractors
- Header `"boost/flyweight/key_value_fwd.hpp"` synopsis
- Header `"boost/flyweight/key_value.hpp"` synopsis
  - Class template `key_value`

## Key extractors

Let `Key` be a type with some implicit equivalence relationship and `Value` a type constructible from `Key`. A `Default Constructible` type `KeyFromValue` is said to be a key extractor from `Value` to `Key` if

1. `kfv(cv)` is defined and have type `const Key&`,
2. `kfv(cv)` is equivalent to `kfv(Value(cv))`,
3. `kfv(Value(k))` is equivalent to `k`,

for every `kfv` of type `const KeyFromValue`, `cv` of type `const Value` and `k` of type `Key`.

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

>     namespace boost{

>     namespace flyweights{

>     struct no_key_from_value;

>     template<
>       typename Key,typename Value,
>       typename KeyFromValue=no_key_from_value
>     >
>     struct key_value;

>     } // namespace boost::flyweights

>     } // namespace boost

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

### Class template `key_value`

In `flyweight` instantiations of the form `flyweight<T,...>`, the associated `key_type` and `value_type` are both equal to `T`. Instantiations of the form `flyweight<key_value<Key,Value[,KeyFromValue]>,...>` allow to specify these types separately. `Key` and `Value` must be different types. When provided, `KeyFromValue` must be a `Key Extractor` from `Value` to `Key`.

`flyweight` reference
Boost.Flyweight reference
Tags

Revised April 24th 2019

© Copyright 2006-2019 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)