Doug,

Unfortunately adding nil will prevent anyone who is building Macintosh software from using Boost.

On a Mac, nil is a preprocessor macro included in the system headers as a legacy of the days when the OS had a Pascal interface.

Chris

> -----Original Message-----
> From: Douglas Gregor [mailto:gregod@cs.rpi.edu]
> Sent: Thursday, June 07, 2001 9:06 PM
> To: boost@yahoogroups.com
> Subject: [boost] boost::nil
>
>
> Hello all,
>       The function library currently under review contains a
> type 'nil_t' with an
> instance 'nil'. It is a replacement for "0" or "NULL" in any
> code. The
> implementation is trivial, but it should probably be placed
> in its own header
> because it's usefulness extends beyond 'function'. The code is just:
>
> namespace boost {
>   struct nil_t
>   {
>     template<typename T> operator T*() const { return 0; }
>     template<typename T, typename U> operator T U::*() const
> { return 0; }
>   };
>
>   template<typename T>
>   inline bool operator==(const T* p, const nil_t&) { return !p; }
>
>   template<typename T>
>   inline bool operator==(const nil_t&, const T* p) { return !p; }
>
>   template<typename T>
>   inline bool operator!=(const T* p, const nil_t&) { return p; }
>
>   template<typename T>
>   inline bool operator!=(const nil_t&, const T* p) { return p; }
>
>   namespace {
>     nil_t nil;
>   }
> }
>
> Advantages of 'nil' over NULL:
>       - NULL is not necessarily portable. Some C++ compilers
> pick up bad
> definitions of NULL from the system C libraries, making it useless.
>       - The type of NULL is unspecified, so it is impossible
> to overload a
> function based on it.
>
> Advantages of 'nil' over 0:
>       - 0 is an integer. It converts to pointer types but
> doesn't convey much
> information to the user.
>       - the type of 0 is "const int". Overloading a function
> to take a null value
> based on const int also allows any integer value to be passed
> in, and the
> error cannot be detected at compile-time.
>
>       Doug