Boost logo

Boost :

Subject: [boost] [mpl] is_macro_called
From: Lorenzo Caminiti (lorcaminiti_at_[hidden])
Date: 2010-04-03 16:25:16


Hello all:

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?

Thank you very much.
Lorenzo


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