
On 09/27/2005 03:24 PM, Calum Grant wrote: [snip]
Is there any interest in providing relational containers in Boost? Are there any features/improvements you can suggest for RML? Why not use boost/preprocessor in RM_DEFINE_ROW? The following shows it can be used to define at least 2 parts of the struct Name:
<------------- RM_DEFINE_ROW.hpp ------------------- #include <boost/preprocessor/punctuation/comma_if.hpp> #include <boost/preprocessor/seq/size.hpp> #include <boost/preprocessor/repetition/repeat.hpp> #include <boost/preprocessor/seq/elem.hpp> #include <boost/preprocessor/tuple/elem.hpp> #define RM_DECL_COL(r,d,tf_pair) \ BOOST_PP_TUPLE_ELEM(2,0,BOOST_PP_SEQ_ELEM(d,tf_pair)) \ BOOST_PP_TUPLE_ELEM(2,1,BOOST_PP_SEQ_ELEM(d,tf_pair)); \ /**/ #define RM_APPEND_TYPE(r,d,tf_pair) \ BOOST_PP_COMMA_IF(d) \ BOOST_PP_TUPLE_ELEM(2,0,BOOST_PP_SEQ_ELEM(d,tf_pair)) \ /**/ #define RM_DEFINE_ROW(Name, type_field_seq) \ struct Name \ { \ BOOST_PP_REPEAT(BOOST_PP_SEQ_SIZE(type_field_seq),RM_DECL_COL,type_field_seq) \ typedef ::relational::type_list_v< \ BOOST_PP_REPEAT(BOOST_PP_SEQ_SIZE(type_field_seq),RM_APPEND_TYPE,type_field_seq) \ > type_list; \ } \ /**/
--------------------------------------------------- <------------- test.cpp ------------------- #include "RM_DEFINE_ROW.hpp"
RM_DEFINE_ROW(xxx,((int,a_int))((float,a_float)));
------------------------------------------ The resulting preprocessor output is: <------------- code ------------------- struct xxx { int a_int; float a_float; typedef ::relational::type_list_v< int , float > type_list; }; ------------- code -------------------