Re: [Boost-users] [iterators] NULL pointer initialization and comparison using iterator_facade
On Tue, Apr 22, 2008 at 10:43 AM, Lang Stefan
wrote: I have a big problem though: The project I am working on is quite big and I intend to replace a particular typedef (currently simply a pointer to a struct) with this iterator class. There are two kinds of instructions though that my iterator class currently can't cope with:
1. Initializing a 'pointer' with NULL (in other words, I need a constructor with one argument of type int, but only in case that argument's value is 0)
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
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
participants (2)
-
Lang Stefan
-
Steven Watanabe