先に進む前に、ブーストまたはそれを使用する小さな実装のいずれかにタイプリストの実装がすでにありますか?今のところ、役に立つものは何も見つかりませんでした。
boost ppを使用して、さまざまなサイズのリストクラスを生成しようとしています。
#define BOOST_PP_LOCAL_MACRO(n) \
template< BOOST_PP_ENUM_TRAILING_PARAMS(n, class t) > /*error C2913: explicit specialization; 'typelist1' is not a specialization of a class template*/ \
struct typelist##n \
{ \
typedef t##n e##n; /*I want n of these*/ \
};
#define Type_At(list, element) list::e##element
#define BOOST_PP_LOCAL_LIMITS (1, 5)
#include BOOST_PP_LOCAL_ITERATE()
問題のコードのコメントを参照してください。これはタイプリストを作成するための適切な方法ですか?汚いようです。タイプリストの概念について聞いたばかりなので、さまざまなフレーバーに精通していません。
解決:
#define BOOST_MPL_LIMIT_VECTOR_SIZE 50
#include <boost/mpl/vector.hpp>
#include <boost/mpl/at.hpp>
typedef boost::mpl::vector<int, float, double, long, short> vecType;
boost::mpl::at_c<vecType, 3>::type hi = 3;