Проверка типов при парсинге

При парсинге файла хочу ввести проверку типов. Решила создать список типов с индексацией

template<typename... Elements>
class TypeList {};

using MyTypes = TypeList<int, double, float, bool, std::string>;

/********/
template<typename List>
class FrontT;

template<typename Head, typename... Tail >
class FrontT<TypeList<Head, Tail...>>
{
public:
    using Type = Head;
};

template<typename List>
using Front = typename FrontT<List>::Type;

/*********/
template<typename List>
class PopFrontT;

template<typename Head, typename... Tail>
class PopFrontT<TypeList<Head, Tail...>>
{
public:
    using Type = TypeList<Tail... >;
};
template<typename List >
using PopFront = typename PopFrontT<List > ::Type;

/********/
template<typename List, unsigned N >
class GetNthType : public GetNthType <PopFront<List>, N - 1 >
{
};

template<typename List>
class GetNthType<List, 0> : public FrontT<List>
{
};

template<typename List, unsigned N>
using GetNthTypeT = typename GetNthType<List, N >::Type;

Далее, планировала создать unordered_map<std::string, unsigned> чтобы по строке идентифицировать индекс типа, и написать функции, что то вроде этого:

constexpr bool my_common_with(const unsigned& t1, const unsigned& t2)
{
    return std::common_with<
        GetNthTypeT<MyTypes, s1>, GetNthTypeT<MyTypes, s2>
    >;
}


constexpr bool my_common_with(const std::string& s1, const std::string& s2)
{
    return std::common_with<
        GetNthTypeT<MyTypes, ???>, GetNthTypeT<MyTypes, ???>
}

И зависла. Запуталась в compiletime и runtime. Как по строке выбрать compile time константу? Помогите, пожалуйста, советом


Ответы (0 шт):