SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
smtrat::VariantMap< Key, Value > Class Template Reference

This class is a specialization of std::map where the keys are of arbitrary type and the values are of type boost::variant. More...

#include <VariantMap.h>

Inheritance diagram for smtrat::VariantMap< Key, Value >:
Collaboration diagram for smtrat::VariantMap< Key, Value >:

Public Member Functions

template<typename T , typename Output >
void assertType (const Key &key, Output out) const
 Asserts that the value that is associated with the given key has a specified type. More...
 
template<typename T >
bool has (const Key &key) const
 Checks if there is a value of the specified type for the given key. More...
 
template<typename T >
const T & get (const Key &key) const
 Returns the value associated with the given key as type T. More...
 

Data Fields

keys
 STL member. More...
 
elements
 STL member. More...
 

Private Member Functions

std::string demangle (const char *t) const
 Asserts that the value type is a variant. More...
 

Detailed Description

template<typename Key, typename Value>
class smtrat::VariantMap< Key, Value >

This class is a specialization of std::map where the keys are of arbitrary type and the values are of type boost::variant.

There is no point in using this class if the values are no variants. Most probably, it would not compile anyway and fail to do so with a large bunch of compiler errors. To prevent this, we assert that the value type is indeed a boost::variant.

Additionally to the standard methods inherited from std::map, it implements three additional methods:

  • assertType<T>(key, out): Asserts that there is a value for the given key and that it has the type T. If this is not the case, an appropriate error is written to out.
  • has<T>(key): Checks if there is a value for the given key and if this value has the type T.
  • get<T>(key): Returns the value for the given key as type T.
Template Parameters
KeyType of keys.
ValueType of values.

Definition at line 55 of file VariantMap.h.

Member Function Documentation

◆ assertType()

template<typename Key , typename Value >
template<typename T , typename Output >
void smtrat::VariantMap< Key, Value >::assertType ( const Key &  key,
Output  out 
) const
inline

Asserts that the value that is associated with the given key has a specified type.

The assertion holds, if

  • there is a value in the map for the given key and
  • the stored value has the type T.
    Template Parameters
    TType that the value should have.
    OutputType of out.
    Parameters
    keyKey.
    outFunctor returning an output stream.

Definition at line 90 of file VariantMap.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ demangle()

template<typename Key , typename Value >
std::string smtrat::VariantMap< Key, Value >::demangle ( const char *  t) const
inlineprivate

Asserts that the value type is a variant.

Converts a type string from typeid to a human-readable representation. This function makes use of abi::__cxa_demangle.

Parameters
tA type string obtained from typeid.
Returns
Demangled type string.

Definition at line 65 of file VariantMap.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get()

template<typename Key , typename Value >
template<typename T >
const T& smtrat::VariantMap< Key, Value >::get ( const Key &  key) const
inline

Returns the value associated with the given key as type T.

Template Parameters
TType of the value.
Parameters
keyKey.
Returns
Value of key as type T.

Definition at line 120 of file VariantMap.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ has()

template<typename Key , typename Value >
template<typename T >
bool smtrat::VariantMap< Key, Value >::has ( const Key &  key) const
inline

Checks if there is a value of the specified type for the given key.

Template Parameters
TType that the value should have.
Parameters
keyKey.
Returns
If there is a value of this type.

Definition at line 108 of file VariantMap.h.

Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ elements

T std::map< K, T >::elements
inherited

STL member.

◆ keys

K std::map< K, T >::keys
inherited

STL member.


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