LocalGuidance
A library that generates velocity references to follow a path.
std_utils::CompileTimeMap< KeyType_, ValueType_, KeyValuePair< KeyType_, ValueType_, Key_, Value_ >, REST_... > Class Template Reference

#include <CompileTimeMap.hpp>

Public Types

using KeyType = KeyType_
 Assert keys that are not unique. More...
 
using ValueType = ValueType_
 
template<ValueType_ value_>
using findAll = cts_insert_front_if_t< KeyType_, typename CompileTimeMap< KeyType_, ValueType_, REST_... >::template findAllRecursive< value_ >, Key_, value_==Value_ >
 Find all entries that map to ValueType_ value_. Defines a compile time set of the found values. More...
 

Static Public Member Functions

static std::vector< KeyType_ > findVector (ValueType_ value)
 Finds all keys that match a specific value, and returns them as a vector. More...
 
template<template< KeyType_, ValueType_ > class F, class... Args>
static constexpr bool forEach (Args &&...args)
 Implementation of forEach: Call F() on every kv-pair until F returns false. More...
 
static constexpr bool forEach (std::function< bool(const KeyType_ &, const ValueType_ &)> f)
 Implementation of forEach: Call f() on every kv-pair until f returns false. More...
 
template<template< KeyType_, ValueType_ > class F, class... Args>
static constexpr bool forEachRange (KeyType_ begin, KeyType_ end, Args &&...args)
 Implementation of forEachRange: Call F() on every kv-pair in [begin, end] until F returns false. More...
 
static constexpr bool forEachRange (KeyType_ begin, KeyType_ end, std::function< bool(const KeyType_ &, const ValueType_ &)> f)
 Implementation of forEachRange: Call f() on every kv-pair in [begin, end] until f returns false. More...
 
static constexpr ValueType_ at (const KeyType_ key)
 Returns value at key. More...
 
template<KeyType_ key_>
static constexpr ValueType_ at ()
 Returns value at key_. More...
 
static constexpr KeyType_ find (const ValueType_ value)
 Return first occurrence of value in map. More...
 
template<ValueType_ value_>
static constexpr KeyType_ find ()
 Return first occurrence of value in map. More...
 
static constexpr bool contains (const KeyType_ key)
 Check if key is contained in map. More...
 
static constexpr bool containsRange (const KeyType_ begin, const KeyType_ end)
 Check if the range [begin, end] is contained in the map. More...
 
static constexpr bool containsValue (const ValueType_ value)
 Check if value is contained in map. More...
 
static constexpr bool allValuesUnique ()
 Check all values in map for uniqueness. More...
 
static constexpr std::size_t size ()
 Return the size of the map. More...
 

Private Types

template<ValueType_ value_>
using findAllRecursive = cts_insert_front_if_t< KeyType_, typename CompileTimeMap< KeyType_, ValueType_, REST_... >::template findAllRecursive< value_ >, Key_, value_==Value_ >
 Implementation helper for findAll. Defines empty CompileTimeSet of keys. More...
 

Static Private Member Functions

static void findVectorRecursive (ValueType_ value, std::vector< KeyType_ > &vec)
 Implementation helper for findVector. If value matches adds key to vector. More...
 
template<template< KeyType_, ValueType_ > class F, class... Args>
static constexpr bool forEachRangePreBegin (KeyType_ begin, KeyType_ end, Args &&...args)
 Implementation helper for functor based forEachRange. More...
 
static constexpr bool forEachRangePreBegin (KeyType_ begin, KeyType_ end, std::function< bool(const KeyType_ &, const ValueType_ &)> f)
 Implementation helper for std::function based forEachRange. More...
 
template<template< KeyType_, ValueType_ > class F, class... Args>
static constexpr bool forEachRangePostBegin (KeyType_ begin, KeyType_ end, Args &&...args)
 Implementation helper for functor based forEachRange. More...
 
static constexpr bool forEachRangePostBegin (KeyType_ begin, KeyType_ end, std::function< bool(const KeyType_ &, const ValueType_ &)> f)
 Implementation helper for std::function based forEachRange. More...
 
static constexpr bool containsRangePostBegin (const KeyType_ begin, const KeyType_ end)
 Implementation helper for containsRange(). More...
 
static constexpr ValueType_ atRecursive (const KeyType_ key)
 Implementation helper for at(). More...
 
static constexpr KeyType_ findRecursive (const ValueType_ value)
 Implementation helper for find(). More...
 
static constexpr bool uniqueKey (const KeyType_ key)
 Helper for assertion that only unique keys are allowed in map. More...
 
static constexpr bool uniqueValue (const ValueType_ value)
 Implementation helper for allValuesUnique(). More...
 

Friends

template<typename... Any>
class CompileTimeMap
 Allow private access on all template specializations of CompileTimeMap. More...
 

Member Typedef Documentation

template<typename KeyType_ , typename ValueType_ , KeyType_ Key_, ValueType_ Value_, typename... REST_>
template<ValueType_ value_>
using std_utils::CompileTimeMap< KeyType_, ValueType_, KeyValuePair< KeyType_, ValueType_, Key_, Value_ >, REST_... >::findAll = cts_insert_front_if_t<KeyType_, typename CompileTimeMap<KeyType_, ValueType_, REST_...>::template findAllRecursive<value_>, Key_, value_ == Value_>

Find all entries that map to ValueType_ value_. Defines a compile time set of the found values.

template<typename KeyType_ , typename ValueType_ , KeyType_ Key_, ValueType_ Value_, typename... REST_>
template<ValueType_ value_>
using std_utils::CompileTimeMap< KeyType_, ValueType_, KeyValuePair< KeyType_, ValueType_, Key_, Value_ >, REST_... >::findAllRecursive = cts_insert_front_if_t<KeyType_, typename CompileTimeMap<KeyType_, ValueType_, REST_...>::template findAllRecursive<value_>, Key_, value_ == Value_>
private

Implementation helper for findAll. Defines empty CompileTimeSet of keys.

template<typename KeyType_ , typename ValueType_ , KeyType_ Key_, ValueType_ Value_, typename... REST_>
using std_utils::CompileTimeMap< KeyType_, ValueType_, KeyValuePair< KeyType_, ValueType_, Key_, Value_ >, REST_... >::KeyType = KeyType_

Assert keys that are not unique.

Expose KeyType and ValueType.

template<typename KeyType_ , typename ValueType_ , KeyType_ Key_, ValueType_ Value_, typename... REST_>
using std_utils::CompileTimeMap< KeyType_, ValueType_, KeyValuePair< KeyType_, ValueType_, Key_, Value_ >, REST_... >::ValueType = ValueType_

Member Function Documentation

template<typename KeyType_ , typename ValueType_ , KeyType_ Key_, ValueType_ Value_, typename... REST_>
static constexpr bool std_utils::CompileTimeMap< KeyType_, ValueType_, KeyValuePair< KeyType_, ValueType_, Key_, Value_ >, REST_... >::allValuesUnique ( )
inlinestatic

Check all values in map for uniqueness.

Returns
true iff all values are unique. False otherwise.
template<typename KeyType_ , typename ValueType_ , KeyType_ Key_, ValueType_ Value_, typename... REST_>
static constexpr ValueType_ std_utils::CompileTimeMap< KeyType_, ValueType_, KeyValuePair< KeyType_, ValueType_, Key_, Value_ >, REST_... >::at ( const KeyType_  key)
inlinestatic

Returns value at key.

Parameters
keykey at which ctm is evaluated.
Returns
The Value_ corresponding to the key, iff key contained in map. Throws std::out_of_range exception otherwise.
template<typename KeyType_ , typename ValueType_ , KeyType_ Key_, ValueType_ Value_, typename... REST_>
template<KeyType_ key_>
static constexpr ValueType_ std_utils::CompileTimeMap< KeyType_, ValueType_, KeyValuePair< KeyType_, ValueType_, Key_, Value_ >, REST_... >::at ( )
inlinestatic

Returns value at key_.

Template Parameters
key_key at which ctm is evaluated.
Returns
The Value_ corresponding to the key, iff key contained in map. Throws std::out_of_range exception otherwise.
template<typename KeyType_ , typename ValueType_ , KeyType_ Key_, ValueType_ Value_, typename... REST_>
static constexpr ValueType_ std_utils::CompileTimeMap< KeyType_, ValueType_, KeyValuePair< KeyType_, ValueType_, Key_, Value_ >, REST_... >::atRecursive ( const KeyType_  key)
inlinestaticprivate

Implementation helper for at().

Parameters
keykey at which ctm is evaluated.
Returns
The Value_ corresponding to the key, iff key contained in map. Throws std::out_of_range exception otherwise.
template<typename KeyType_ , typename ValueType_ , KeyType_ Key_, ValueType_ Value_, typename... REST_>
static constexpr bool std_utils::CompileTimeMap< KeyType_, ValueType_, KeyValuePair< KeyType_, ValueType_, Key_, Value_ >, REST_... >::contains ( const KeyType_  key)
inlinestatic

Check if key is contained in map.

Parameters
keykey at which ctm is evaluated.
Returns
true iff key is contained in the map. False otherwise.
template<typename KeyType_ , typename ValueType_ , KeyType_ Key_, ValueType_ Value_, typename... REST_>
static constexpr bool std_utils::CompileTimeMap< KeyType_, ValueType_, KeyValuePair< KeyType_, ValueType_, Key_, Value_ >, REST_... >::containsRange ( const KeyType_  begin,
const KeyType_  end 
)
inlinestatic

Check if the range [begin, end] is contained in the map.

Parameters
beginfirst key of range.
endlast key of range.
Returns
true iff range is contained in the map. False otherwise.
template<typename KeyType_ , typename ValueType_ , KeyType_ Key_, ValueType_ Value_, typename... REST_>
static constexpr bool std_utils::CompileTimeMap< KeyType_, ValueType_, KeyValuePair< KeyType_, ValueType_, Key_, Value_ >, REST_... >::containsRangePostBegin ( const KeyType_  begin,
const KeyType_  end 
)
inlinestaticprivate

Implementation helper for containsRange().

Parameters
beginfirst key of range.
endlast key of range.
Returns
true, iff range is contained in map.
template<typename KeyType_ , typename ValueType_ , KeyType_ Key_, ValueType_ Value_, typename... REST_>
static constexpr bool std_utils::CompileTimeMap< KeyType_, ValueType_, KeyValuePair< KeyType_, ValueType_, Key_, Value_ >, REST_... >::containsValue ( const ValueType_  value)
inlinestatic

Check if value is contained in map.

Parameters
valuevalue to check for.
Returns
true iff value is contained in the map. False otherwise.
template<typename KeyType_ , typename ValueType_ , KeyType_ Key_, ValueType_ Value_, typename... REST_>
static constexpr KeyType_ std_utils::CompileTimeMap< KeyType_, ValueType_, KeyValuePair< KeyType_, ValueType_, Key_, Value_ >, REST_... >::find ( const ValueType_  value)
inlinestatic

Return first occurrence of value in map.

Parameters
valueValue to search in map.
Returns
Key corresponding to the first occurrence of value, iff value contained in map. Throws std::out_of_range exception otherwise.
template<typename KeyType_ , typename ValueType_ , KeyType_ Key_, ValueType_ Value_, typename... REST_>
template<ValueType_ value_>
static constexpr KeyType_ std_utils::CompileTimeMap< KeyType_, ValueType_, KeyValuePair< KeyType_, ValueType_, Key_, Value_ >, REST_... >::find ( )
inlinestatic

Return first occurrence of value in map.

Template Parameters
value_Value to search in map.
Returns
Key corresponding to the first occurrence of value, iff value contained in map. Throws std::out_of_range exception otherwise.
template<typename KeyType_ , typename ValueType_ , KeyType_ Key_, ValueType_ Value_, typename... REST_>
static constexpr KeyType_ std_utils::CompileTimeMap< KeyType_, ValueType_, KeyValuePair< KeyType_, ValueType_, Key_, Value_ >, REST_... >::findRecursive ( const ValueType_  value)
inlinestaticprivate

Implementation helper for find().

Parameters
valuevalue at which ctm is evaluated.
Returns
The Key_ corresponding to the value, iff value contained in map. Throws std::out_of_range exception otherwise.
template<typename KeyType_ , typename ValueType_ , KeyType_ Key_, ValueType_ Value_, typename... REST_>
static std::vector<KeyType_> std_utils::CompileTimeMap< KeyType_, ValueType_, KeyValuePair< KeyType_, ValueType_, Key_, Value_ >, REST_... >::findVector ( ValueType_  value)
inlinestatic

Finds all keys that match a specific value, and returns them as a vector.

Parameters
valueValue for which matching keys are queried
template<typename KeyType_ , typename ValueType_ , KeyType_ Key_, ValueType_ Value_, typename... REST_>
static void std_utils::CompileTimeMap< KeyType_, ValueType_, KeyValuePair< KeyType_, ValueType_, Key_, Value_ >, REST_... >::findVectorRecursive ( ValueType_  value,
std::vector< KeyType_ > &  vec 
)
inlinestaticprivate

Implementation helper for findVector. If value matches adds key to vector.

template<typename KeyType_ , typename ValueType_ , KeyType_ Key_, ValueType_ Value_, typename... REST_>
template<template< KeyType_, ValueType_ > class F, class... Args>
static constexpr bool std_utils::CompileTimeMap< KeyType_, ValueType_, KeyValuePair< KeyType_, ValueType_, Key_, Value_ >, REST_... >::forEach ( Args &&...  args)
inlinestatic

Implementation of forEach: Call F() on every kv-pair until F returns false.

Template Parameters
FFunctor type that is templated on Key and Value implements operator()(Args...).
ArgsVariadic template use for function arguments.
Parameters
argsParameter pack passes to the functor.
Returns
true, iff all F's returned true.
template<typename KeyType_ , typename ValueType_ , KeyType_ Key_, ValueType_ Value_, typename... REST_>
static constexpr bool std_utils::CompileTimeMap< KeyType_, ValueType_, KeyValuePair< KeyType_, ValueType_, Key_, Value_ >, REST_... >::forEach ( std::function< bool(const KeyType_ &, const ValueType_ &)>  f)
inlinestatic

Implementation of forEach: Call f() on every kv-pair until f returns false.

Parameters
ffunction to call.
Returns
true, iff all f's returned true.
template<typename KeyType_ , typename ValueType_ , KeyType_ Key_, ValueType_ Value_, typename... REST_>
template<template< KeyType_, ValueType_ > class F, class... Args>
static constexpr bool std_utils::CompileTimeMap< KeyType_, ValueType_, KeyValuePair< KeyType_, ValueType_, Key_, Value_ >, REST_... >::forEachRange ( KeyType_  begin,
KeyType_  end,
Args &&...  args 
)
inlinestatic

Implementation of forEachRange: Call F() on every kv-pair in [begin, end] until F returns false.

Template Parameters
FFunctor type that is templated on Key and Value implements operator()(Args...)
ArgsVariadic template use for function arguments
Parameters
beginFirst element in range (F is called with this element)
endLast element in range (F is called with this element)
argsParameter pack passes to the functor
Returns
true, iff all F's returned true.
template<typename KeyType_ , typename ValueType_ , KeyType_ Key_, ValueType_ Value_, typename... REST_>
static constexpr bool std_utils::CompileTimeMap< KeyType_, ValueType_, KeyValuePair< KeyType_, ValueType_, Key_, Value_ >, REST_... >::forEachRange ( KeyType_  begin,
KeyType_  end,
std::function< bool(const KeyType_ &, const ValueType_ &)>  f 
)
inlinestatic

Implementation of forEachRange: Call f() on every kv-pair in [begin, end] until f returns false.

Parameters
beginFirst element in range (f is called with this element)
endLast element in range (f is called with this element)
ffunction to call
Returns
true, iff all f's returned true.
template<typename KeyType_ , typename ValueType_ , KeyType_ Key_, ValueType_ Value_, typename... REST_>
template<template< KeyType_, ValueType_ > class F, class... Args>
static constexpr bool std_utils::CompileTimeMap< KeyType_, ValueType_, KeyValuePair< KeyType_, ValueType_, Key_, Value_ >, REST_... >::forEachRangePostBegin ( KeyType_  begin,
KeyType_  end,
Args &&...  args 
)
inlinestaticprivate

Implementation helper for functor based forEachRange.

Template Parameters
FFunctor type that is templated on Key and Value implements operator()(Args...).
ArgsVariadic template use for function arguments.
Parameters
beginfirst key of range.
endlast key of range.
argsParameter pack passes to the functor.
Returns
true, iff all F's returned true.
template<typename KeyType_ , typename ValueType_ , KeyType_ Key_, ValueType_ Value_, typename... REST_>
static constexpr bool std_utils::CompileTimeMap< KeyType_, ValueType_, KeyValuePair< KeyType_, ValueType_, Key_, Value_ >, REST_... >::forEachRangePostBegin ( KeyType_  begin,
KeyType_  end,
std::function< bool(const KeyType_ &, const ValueType_ &)>  f 
)
inlinestaticprivate

Implementation helper for std::function based forEachRange.

Parameters
beginfirst key of range.
endlast key of range.
ffunction object to call.
Returns
true, iff all f's returned true.
template<typename KeyType_ , typename ValueType_ , KeyType_ Key_, ValueType_ Value_, typename... REST_>
template<template< KeyType_, ValueType_ > class F, class... Args>
static constexpr bool std_utils::CompileTimeMap< KeyType_, ValueType_, KeyValuePair< KeyType_, ValueType_, Key_, Value_ >, REST_... >::forEachRangePreBegin ( KeyType_  begin,
KeyType_  end,
Args &&...  args 
)
inlinestaticprivate

Implementation helper for functor based forEachRange.

Template Parameters
FFunctor type that is templated on Key and Value implements operator()(Args...).
ArgsVariadic template use for function arguments.
Parameters
beginfirst key of range.
endlast key of range.
argsParameter pack passes to the functor.
Returns
true, iff all F's returned true.
template<typename KeyType_ , typename ValueType_ , KeyType_ Key_, ValueType_ Value_, typename... REST_>
static constexpr bool std_utils::CompileTimeMap< KeyType_, ValueType_, KeyValuePair< KeyType_, ValueType_, Key_, Value_ >, REST_... >::forEachRangePreBegin ( KeyType_  begin,
KeyType_  end,
std::function< bool(const KeyType_ &, const ValueType_ &)>  f 
)
inlinestaticprivate

Implementation helper for std::function based forEachRange.

Parameters
beginfirst key of range.
endlast key of range.
ffunction object to call.
Returns
true, iff all f's returned true.
template<typename KeyType_ , typename ValueType_ , KeyType_ Key_, ValueType_ Value_, typename... REST_>
static constexpr std::size_t std_utils::CompileTimeMap< KeyType_, ValueType_, KeyValuePair< KeyType_, ValueType_, Key_, Value_ >, REST_... >::size ( )
inlinestatic

Return the size of the map.

Returns
size of the map.
template<typename KeyType_ , typename ValueType_ , KeyType_ Key_, ValueType_ Value_, typename... REST_>
static constexpr bool std_utils::CompileTimeMap< KeyType_, ValueType_, KeyValuePair< KeyType_, ValueType_, Key_, Value_ >, REST_... >::uniqueKey ( const KeyType_  key)
inlinestaticprivate

Helper for assertion that only unique keys are allowed in map.

Parameters
keykey that is checked for uniqueness
Returns
true iff all keys in the map are unique. False otherwise.
template<typename KeyType_ , typename ValueType_ , KeyType_ Key_, ValueType_ Value_, typename... REST_>
static constexpr bool std_utils::CompileTimeMap< KeyType_, ValueType_, KeyValuePair< KeyType_, ValueType_, Key_, Value_ >, REST_... >::uniqueValue ( const ValueType_  value)
inlinestaticprivate

Implementation helper for allValuesUnique().

Parameters
valuevalue that is checked for uniqueness
Returns
true iff all values in the map are unique. False otherwise.

Friends And Related Function Documentation

template<typename KeyType_ , typename ValueType_ , KeyType_ Key_, ValueType_ Value_, typename... REST_>
template<typename... Any>
friend class CompileTimeMap
friend

Allow private access on all template specializations of CompileTimeMap.


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