문제

How to determine elements count in boost.preprocessor tuple`s ?

도움이 되었습니까?

해결책

Boost 1.49 already has BOOST_PP_TUPLE_SIZE macro

다른 팁

You don't. That's why every macro that uses tuples requires you to specify the size of the tuple. You could try doing something based on a 2 tuple where the first value is the size of the second:

#define MyTuple (2,(a,tuple))
#define MyTupleSize( S_ ) BOOST_PP_TUPLE_ELEM( 2, 0, S_ )
#define GetMyTuple( S_, I_ ) BOOST_PP_TUPLE_ELEM( MyTupleSize(S_), I_, BOOST_PP_TUPLE_ELEM(2, 1, S_ ) )
MyTupleSize( MyTuple ) // this is '2'
GetMyTuple( MyTuple, 1 )// this is 'tuple'

Unfortunately there is no way to determine the size of a tuple other than to know it or store it in a known sized tuple or in a list etc.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top