Boost logo

Boost :

Subject: Re: [boost] [mpl] is_macro_called
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-04-04 19:21:05


AMDG

Lorenzo Caminiti wrote:
> On Sat, Apr 3, 2010 at 4:44 PM, Steven Watanabe <watanabesj_at_[hidden]> wrote:
>
>> 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.
>>
> -
> I understand but I would be interested in a solution even if it had
> limitations. In this specific case, even if the solution was to only
> work when the member function is defined inline within the class, I
> would still be interested in it.
>
> However, even for inlined member functions, personally I could not
> come up with any code that I can program within the member function
> definition scope which has an effect that can be inspected at
> compile-time at the class definition scope...

Even if it could be done on some compilers, it wouldn't be portable
because there's a good chance that the compiler won't try to compile
the member functions until it's finished with the class body.

Try compiling this
class C {
    void f() {
        int i = ::test;
    }
    static const int i = ::test;
};

The first error is likely to be for the class member rather than
inside f.

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