ROSE  0.11.145.0
Public Types | List of all members
Sawyer::Container::TraceIndexTraits< Label, Value, IndexTypeTag > Struct Template Reference

Description

template<class Label, class Value, class IndexTypeTag>
struct Sawyer::Container::TraceIndexTraits< Label, Value, IndexTypeTag >

Traits for a Trace label index.

The IndexTypeTag argument is used to select the index implementation used to associate some data with each label. Sawyer defines two kinds of indexes: the TraceMapIndexTag selects an index based on std::map while the TraceVectorIndexTag selects an index based on std::vector. The vector-based index is suitable for labels that can be used as vector indexes. The map-based index should be used for all other cases, including integer labels that would result in very sparse vectors.

Users are welcome to define their own index class. Their class should have the following interface:

To use a user-defined index, the user should define their index class, define a tag for their class, and specialize TraceIndexTraits. Here's a simple example where the user has a custom index for a specific user-defined label type:

class MyLabel {...};
template<class Value>
class MyLabelIndex; // see requirements above
class MyLabelIndexTag {};
namespace Sawyer { namespace Container {
template<class Value>
struct TraceIndexTraits<MyLabel, Value, MyLabelIndexTag> {
typedef MyIndex<Value> Index;
};
}}

Once you've defined your index, you can start to use it like this:

Definition at line 167 of file Trace.h.

#include <util/Sawyer/Trace.h>

Inheritance diagram for Sawyer::Container::TraceIndexTraits< Label, Value, IndexTypeTag >:
Inheritance graph
[legend]

Public Types

typedef TraceDetail::MapIndex< Label, Value > Index
 

The documentation for this struct was generated from the following file: