Boost logo

Boost Users :

From: martin f krafft (madduck_at_[hidden])
Date: 2005-05-14 09:20:31


Dear all,

I am trying to create an assertion macro which can be used inside
and outside of class member functions. When inside a class, I want
it to be able to use information from *this, which obviously does
not exist outside of a class member function.

Right now, I have two different macros and I would like to unify the
API. The situation is actually more complex but boils down to the
following question:

How can I create a macro (#define) such that its definition does
different things when inside a class member function than outside.
Something like:

  if exists(*this) assertion(a, *this);
  else assertion(a);

such that this is resolved to either of the assertion() overloads at
compile time.

I guess this is the domain of MPL, but my head just doesn't work in
MPL-terms (yet). I would appreciate if someone gave me a solution to
this case and promise to try to work my way into MPL more with it.

-- 
martin;              (greetings from the heart of the sun.)
  \____ echo mailto: !#^."<*>"|tr "<*> mailto:" net_at_madduck
 
invalid/expired pgp subkeys? use subkeys.pgp.net as keyserver!
spamtraps: madduck.bogus_at_[hidden]
 
"arguments are extremely vulgar,
 for everyone in good society
 holds exactly the same opinion."
                                                        -- oscar wilde



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