Boost logo

Boost :

Subject: Re: [boost] [TTI] Review
From: Edward Diener (eldiener_at_[hidden])
Date: 2011-07-11 10:13:31


On 7/11/2011 3:26 AM, Nathan Ridge wrote:
>
>> On 7/10/2011 7:59 PM, Lorenzo Caminiti wrote:
>>
>>> HAS_MEMBER_VARIABLE(has_myvar, [static] myvar)
>>> HAS_MEMBER_FUNCTION(has_myfunc, [static] myfunc)
>>
>> I can easily combine BOOST_TTI_HAS_MEMBER_DATA and
>> BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION into HAS_MEMBER_VARIABLE, which
>> covers either case, and BOOST_TTI_HAS_MEMBER_FUNCTION and
>> BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION into a HAS_MEMBER_FUNCTION, which
>> cover either case. But then the end-user will lose the ability to
>> distinguish between a 'member data/static member data' or 'member
>> function/static member function'. Do you really think that is the
>> correct thing to do just because you think there are too many macros ? I
>> do not.
>>
>
> I think Lorenzo was suggesting having a single macro whose
> implementation checks whether the second argument starts
> with the token "static"; if so it performs a check for static
> functions only, otherwise it performs a check for nonstatic
> functions only.

Thanks for clarifying what Lorenzo meant.

It does seem to me that using 'static' in front of the variable or
function name is not as clear as simply having two different macro names.

My current solution is:

BOOST_TTI_HAS_MEMBER_FUNCTION(name)
BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION(name)

Lorenzo's suggested solution:

BOOST_TTI_HAS_MEMBER_FUNCTION([static] name)

Do you really think that the second solution is better ?

>
> Checking whether a macro argument starts with a particular
> token is certainly doable; see for example [1].

Yes I already know it is doable with the restricted input of a C++
identifier for the name.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk