|
Boost : |
Subject: Re: [boost] [mpl] is_macro_called
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-04-03 16:44:07
AMDG
Lorenzo Caminiti wrote:
> Is there a way I can check at compile-time and class-scope if a macro
> has been called and expanded (at least one time) from within a member
> function?
>
> For example:
>
> #define X(...) ... // Some macro definition -- the macro
> parameters could be anything needed to implement is_macro_called.
>
> struct is_macro_X_called { ... }; // Some implementation -- this
> could be a template or something else.
>
> So that:
>
> struct z {
> void f() {
> X(...); // Macro called from within a member function.
> }
>
> // Detect at class-scope and a compile-time that the macro was called.
> static const bool is_macro_X_called::value; // Evaluates to true.
> };
>
> Instead:
>
> struct z {
> void f() {
> // X(...); // Macro not called.
> }
>
> static const bool is_macro_X_called::value; // Evaluates to false.
> };
>
> I do not know how to program this. However, could for example the
> macro X() instantiate a template with some special template parameter
> that can then be inspected at compile-time by a is_macro_called
> metafunction?
>
How do you prevent someone from defining the member function
out of line? Even if you could do it, it seems prone to subtle bugs.
In Christ,
Steven Watanabe
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk