|
Boost : |
Subject: Re: [boost] [TTI] Review
From: lcaminiti (lorcaminiti_at_[hidden])
Date: 2011-07-11 17:02:39
Edward Diener-3 wrote:
>
> On 7/11/2011 2:45 PM, Joel falcou wrote:
>> See :
>>
>> https://github.com/MetaScale/nt2/blob/master/modules/sdk/include/nt2/sdk/details/preprocessor.hpp
>>
>>
>>
>> for the file, line 85 and after.
>>
>> The point is it works without variadics
>
> Line 87: #define NT2_PP_DETAILS_STRIP_PARENS_I(...) 1,1
> Line 91: #define NT2_PP_DETAILS_TEST_ARITY_I(a,b,c,...) c
> Line 96: #define NT2_PP_DETAILS_MAYBE_STRIP_PARENS_2_I(...) __VA_ARGS__
>
> Clearly it needs variadic macro support.
>
> I have already added a REMOVE_PARENS ( the equivalent to NT2_PP_STRIP(X)
> in your URL above ) to a proposed addition to pp-lib which I am
> discussing with Paul Mensonides, based on the updated variadic macro
> support on which both of us worked and which is now in the Boost trunk.
>
> My point is also that I may well be able to simplify the
> BOOST_TTI_TEMPLATE macros in TTI using variadic macro support
> techniques, as Lorenzo suggested, but I do not feel correct in dropping
> macro support support for compilers which do not support variadic macros
> although I understand there are few of them left.
>
I will later reply to all your comments on my review but let me quickly
clarify a couple of things.
My suggestion was to have the *same* macro TTI_TEMPLATE handle *both*
variadics tupletes and sequences. The pp skeleton code will go something
like:
#if VARIADICS
#define TTI_TEMPLATE_VA_(...) \
TTI_TEMPLATE_SEQ_(VA_TUPLE_TO_SEQ(__VA_ARGS__))
#define TTI_TEMPLATE(...) \
BOOST_PP_IIF(IS_VARIADIC(__VA_ARGS__), \
TTI_TEMPLATE_VA_ \
, \
TTI_TEMPLATE_SEQ_ \
)(__VA_ARGS__)
#else // variadics
#define TTI_TEMPLATE(seq) TTI_TEMPLATE_SEQ_(seq)
#endif // variadics
Take a look at BOOST_LOCAL_FUNCTION_PARAMS at:
http://svn.boost.org/svn/boost/sandbox/local/boost/local/function.hpp
This macro could be expanded to also detect a single token and accept the
trait parameters in front. The full grammar will then read something like:
TTI_TEMPLATE(trait, [tpl_signature_ {class | struct }] name)
If the compiler supports variadics:
tpl_signature_:
tpl_signature_va_ | tpl_signature_seq_ // you can use either variadics
or sequences :)
If not:
tpl_signature_:
tpl_signature_seq_ // you must use sequences (because variadiacs are not
supported)
Where:
tpl_signature_seq_:
template( (class | typename | type_identifier | tpl_signature_seq_) ...
) // the pp-seq
tpl_signature_va_:
template< {class | typename | type_identifier | tpl_signature_seq_} ...
> // the pp-variadic tuple
Where lexical conventions are:
[token] := token is optional
token1 | token 2 := either token1 or token2
{expr} := the token(s) resulting from the inner expression epxr
(tokens) ... := repeat tokens within parenthesis one or more times
(tokens) (tokens) etc
tokens ... := repeat tokens separated by commas one or more times
tokens, tokens etc
I think this should be possible but usually the devil is in the details...
so I don't know unless someone tries to implement it :)
The real question still stands: Would this be a better interface for
TTI_TEMPLATE? (You know my opinion is yes, but that's just my opinion.)
Please ask questions and let me know if I am not able to explain myself.
--Lorenzo
-- View this message in context: http://boost.2283326.n4.nabble.com/TTI-Review-tp3658414p3660843.html Sent from the Boost - Dev mailing list archive at Nabble.com.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk