Boost logo

Boost Users :

From: Paul Mensonides (yg-boost-users_at_[hidden])
Date: 2003-05-06 20:31:14


Tanton Gibbs wrote:
> Yes, I think he just has a problem with using a placeholder value, he
> wants to show, at the call site, that the value is not used.

There are two ways to "simulate" passing nothing in C++. One is more intrusive
at the point of call than the other:

1) BOOST_PP_EMPTY and BOOST_PP_IDENTITY:

#define MACRO(x) x()

MACRO( BOOST_PP_EMPTY ) // expands to nothing
MACRO( BOOST_PP_IDENTITY( abc ) ) // expands to: abc

2) BOOST_PP_NIL and BOOST_PP_APPLY

#define MACRO(x) BOOST_PP_APPLY(x)

MACRO( BOOST_PP_NIL ) // expands to nothing
MACRO( (abc) ) // expands to: abc

Of course, these facilities are only necessary if you want to abstract the
difference between "something" and "nothing." If he just wants to make it
obvious that the parameter is not used, you can still use BOOST_PP_NIL (which is
guaranteed to *not* be a macro) or pass "unused" or something similar. The only
foolproof way is to pass a non-identifier token, such as an operator or a
pp-number which cannot be used in any other context:

MACRO( 0xIgnored )

Or a simple string literal:

MACRO( "This parameter is ignored." )

Regards,
Paul Mensonides


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net