ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> boost
boost
Re: [boost] null
by Jason Hise other posts by this author
Jul 28 2005 8:37PM messages near this date
Re: [boost] null | Re: [boost] Interest for a perl6-like-junctions-class?
SOURCE Eric Niebler wrote:

>  [...redefining NULL breaks things...]
>  <>struct foo { foo(void*) {} };
>  void bar(foo f) {}
>  void baz() {
>  bar(NULL);
>  }
> 
>  Works with NULL as 0, fails with NULL as null because it needs two
>  user-defined conversions.
> 
>  Redefining NULL is a career-limiting move. Don't do it.

Alright, I concede that I shouldn't redefine a standard macro.  :-P  
Interesting example by the way... hadn't thought of that.  Would be nice 
if there was a way around it.  I find the upper limit on user defined 
implicit conversions frustrating.  This limit has already thwarted my 
plan to make a smart reference type which only locks the contained 
instance while being implicitly converted to the raw reference type.  It 
would have worked something like:

template < typename Type > 
struct Ref
{
    struct InternalRef
    {
        Lock my_lock;
        operator Type & (  );
    };
    operator InternalRef (  );
};

This was planned to work similar to the locking pointer idiom:

template < typename Type > 
struct Ptr
{
    struct InternalPtr
    {
        Lock my_lock;
        Type * operator ->  (  );
    };
    InternalPtr * operator ->  (  );
};

But sadly, the locking reference idea requires two implicit user defined 
conversions.  And I can't exactly overload the '.' operator.  *sigh*  
Why does the C++ language have to ban such potentially fun things as 
infinite implicit conversion chains and overloading the dot operator?

-Jason


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Thread:
Jason Hise
Martin Wille
Jason Hise
Martin Wille
Eric Niebler
Eric Niebler
Jason Hise

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved