Boost logo

Boost Users :

From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-04-23 10:35:47


AMDG

Lang Stefan wrote:
>> How about some really weird pointer type? If you did a member
>> function type that doesn't actually exist, you should be able to
>> construct with NULL, but nothing else
>
> Whatever you have in mind, I have no idea what you mean. Could you
> elaborate please?
>
> Btw., I did consider somehow introducing one of the boost smart pointer
> types to resolve this issue, but apparently even the smart pointers
> cannot directly deal with NULL values (e.g. comparison to NULL requires
> calling the get() method first).
>
> I could of course introduce special functions for semantically equal
> purposes, but that would force me to change several thousand lines of
> code to match the new syntax. I can think of better ways to waste my
> time...
>
> Is it possible to construct metafunctions that allow a function argument
> of NULL, but not any other integer value? Or at least cause the compiler
> to call out whenever a non-NULL argument is provided?
>
> Cheers,
> Stefan

struct convertible_from_null {
    struct null_pointer_impl_t;
    typedef null_pointer_impl_t (convertible_from_null::*null_pointer_t)();
    convertible_from_null(null_pointer_t* = 0) {}
};

convertible_from_null test = 0;

//convertible_from_null fail = 1;

int main() {}

In Christ,
Steven Watanabe


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