I have a tuple with multiple template class where only the template of the class change, as such:
template<template<class> class T, class ...Ts>
class TriggerMap;
template<template<class> class T, class ...Ts>
class TriggerMap<T, std::tuple<Ts...>>
{
public:
TriggerMap(ThreadPool &_tp) : m_map(_tp) {}
~TriggerMap() = default;
private:
using TriggerMapImp = typename tuple_apply_template<T, Ts...>::type;
TriggerMapImp m_tup;
};
with tuple_apply_template
:
template<class, class>
struct tuple_prepend;
template<class T, class ...Ts>
struct tuple_prepend<T, std::tuple<Ts...>>
{
using type = std::tuple<T, Ts...>;
};
template<template<class> class T, class ...Ts>
struct tuple_apply_template;
template<template<class> class T, class _T, class ...Ts>
struct tuple_apply_template<T, _T, Ts...>
{
using type = typename tuple_prepend<T<_T>, typename tuple_apply_template<T, Ts...>::type>::type;
};
template<template<class> class T, class _T>
struct tuple_apply_template<T, _T>
{
using type = std::tuple<T<_T>>;
};
I would like to construct my object with an object reference in this case the object ThreadPool
, how can I change the constructor of TriggerMap
(that doesn't actually work) in an effiente way for run-time optimisation?
To have the constructor compiling, I change it to:
TriggerMap(ThreadPool &_tp) : m_map(T<Ts>(_tp)...) {}