forked from boostorg/intrusive
Fix documentation to indicate key extractors can return the key by value
This commit is contained in:
@@ -1393,9 +1393,15 @@ The option is called [classref boost::intrusive::key_of_value].
|
||||
|
||||
If a user specifies that option when defining a `set/multiset` intrusive container, it specifies a function object
|
||||
that will tell the container which is the type of the ['key] that `value_type` holds and how to obtain it. This
|
||||
function object must be lightweight, `DefaultConstructible`, it shall define a `type` member that defines the type
|
||||
of the key and a member function to obtain a const reference to the key stored inside a `value_type`. Let's
|
||||
see an example of how a set can be configured as a map indexed by an integer stored in the `value_type`.
|
||||
function object must be:
|
||||
|
||||
* Lightweight to copy.
|
||||
* Default constructible (when the container constructor overload requires it).
|
||||
* It shall define:
|
||||
* A `type` member that defines the type of the key
|
||||
* A member function that returns the key derived a `value_type`, either by value or by const-reference.
|
||||
|
||||
Let's see an example of how a set can be configured as a map indexed by an integer stored in the `value_type`:
|
||||
|
||||
[import ../example/doc_map.cpp]
|
||||
[doc_map_code]
|
||||
|
@@ -28,10 +28,10 @@ class MyClass : public set_base_hook<>
|
||||
};
|
||||
|
||||
//key_of_value function object, must:
|
||||
//- be default constructible (and lightweight)
|
||||
//- be default constructible if the container constructor requires it
|
||||
//- define the key type using "type"
|
||||
//- define an operator() taking "const value_type&" and
|
||||
// returning "const type &"
|
||||
// returning "type" or "const type &"
|
||||
struct first_int_is_key
|
||||
{
|
||||
typedef int type;
|
||||
|
Reference in New Issue
Block a user