From: Vesa Karvonen (vesa.karvonen_at_[hidden])
Date: 2001-07-01 07:57:53
----- Original Message -----
From: "Vesa Karvonen" <vesa.karvonen_at_[hidden]>
Sent: Saturday, June 30, 2001 22:46
Subject: [boost] PREPROCESSOR library review
> A few hours ago, I invented a technique for implementing ADD(X,Y) and
> using linear amount of tokens.
> It is highly likely that other interesting and useful operations could be
> implemented in the future.
I have now implemented also MUL(X,Y), MAX(X,Y) and MIN(X,Y).
A pint of beer is promised to the first person to implement DIV(X,Y) and
MOD(X,Y) using at most a linear amount of tokens (and the result must, of
course, be a single token).
MUL was implemented by changing the previously introduced REPEAT_CALL to
RECURSE that makes it possible to have an additional parameter (the same
technique was suggested by Aleksey Gurtovoy for REPEAT earlier) and the
introduction of 2ND_RECURSE making it possible to make recursive functions
that have quadratic complexity. I will also consider passing the recursion
level/depth to the macro.
#define BOOST_PREPROCESSOR_RECURSE0(M,C,P) P
#define BOOST_PREPROCESSOR_RECURSE1(M,C,P) M(C,P)
#define BOOST_PREPROCESSOR_RECURSE2(M,C,P) M(C,M(C,P))
MAX and MIN use SUB. In addition, I changed DEC and INC to use saturation
arithmetic. In other words, and most importantly for MAX and MIN, DEC(0)
results in 0.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk