Kaspersky Neuromorphic Platform  1.0.0
API Reference
Loading...
Searching...
No Matches
stringify.h
Go to the documentation of this file.
1
22#pragma once
23
24#include <string>
25#include <tuple>
26#include <vector>
27
28#include <boost/mp11.hpp>
29#include <boost/preprocessor.hpp>
30
31
35namespace knp::meta
36{
37
45template <class T1, class T2>
46using mp_neq = boost::mp11::mp_bool<T1::value != T2::value>;
47
53template <class AllList, class L>
54using mp_flt = boost::mp11::mp_filter_q<boost::mp11::mp_bind_front<mp_neq, boost::mp11::mp_size<AllList>>, L>;
55
61template <class AllList, class L>
64
68#define KNP_MAKE_TUPLE_INTERNAL(n, tuple_type, tuple_elem) (BOOST_PP_STRINGIZE(tuple_elem))
69
73#define KNP_MAKE_TUPLE(tuple_elems) \
74 ::std::make_tuple( \
75 BOOST_PP_SEQ_ENUM(BOOST_PP_SEQ_FOR_EACH(KNP_MAKE_TUPLE_INTERNAL, "", BOOST_PP_VARIADIC_TO_SEQ(tuple_elems))));
76
83template <typename AllTypes, typename SupportedTypes>
84std::vector<size_t> get_supported_type_indexes()
85{
86 std::vector<size_t> result;
87 result.reserve(boost::mp11::mp_size<SupportedTypes>::value);
88
89 boost::mp11::mp_for_each<knp::meta::mp_supported_indexes<SupportedTypes, AllTypes>>([&result](auto i)
90 { result.push_back(i); });
91
92 return result;
93}
94
103template <typename AllTypes, typename SupportedTypes, typename NamesType>
104std::vector<std::string> get_supported_type_names(const NamesType &type_names)
105{
106 std::vector<std::string> result;
107 result.reserve(boost::mp11::mp_size<SupportedTypes>::value);
108
109 boost::mp11::mp_for_each<knp::meta::mp_supported_indexes<SupportedTypes, AllTypes>>(
110 [&type_names, &result](auto i) { result.push_back(std::get<i>(type_names)); });
111
112 return result;
113}
114
115} // namespace knp::meta
Metaprogramming library namespace.
boost::mp11::mp_bool< T1::value !=T2::value > mp_neq
Template used to determine if two arbitrary types are not the same at the compile stage.
Definition stringify.h:46
std::vector< size_t > get_supported_type_indexes()
Get supported type indexes.
Definition stringify.h:84
mp_flt< AllList, boost::mp11::mp_transform_q< boost::mp11::mp_bind_front< boost::mp11::mp_find, AllList >, L > > mp_supported_indexes
Index array for types from the global type list that are used in the local type list.
Definition stringify.h:62
boost::mp11::mp_filter_q< boost::mp11::mp_bind_front< mp_neq, boost::mp11::mp_size< AllList > >, L > mp_flt
List of types from the global type list that are used in the local type list.
Definition stringify.h:54
std::vector< std::string > get_supported_type_names(const NamesType &type_names)
Get names of supported object types.
Definition stringify.h:104