[cfe-dev] Parser Stmt/Expr Owning Pointer

Sebastian Redl sebastian.redl at getdesigned.at
Tue Dec 9 10:10:29 PST 2008


Howard Hinnant wrote:
> On Dec 9, 2008, at 11:16 AM, Sebastian Redl wrote:
>
>   
>> The advantage of this is that I can pass my pointer's mover to a  
>> function that is updated to take my pointer as easily as I can pass  
>> it to a function that still takes a raw pointer, with no change in  
>> the caller's syntax. Since the update is the business of the callee,  
>> I don't see this as unsafe, I see it as convenient.
>> We're not redefining ownership here, we're just trying to enforce  
>> the existing rules through the type system. So the caller moves the  
>> pointer to the callee, no matter how the callee decides to handle it  
>> further.
>>     
>
> People have been warning against implicit conversions from smart  
> pointers to raw pointers for a very long time...
>
> http://www.aristeia.com/Papers/C++ReportColumns/jun96.pdf
>
>   
>> The bottom line is simple: don’t provide implicit conversion  
>> operators to dumb point-
>> ers unless there is a compelling reason to do so.
>>     
>
> Scott Meyers, 1996.
>
> I realize you're only converting implicitly from an ASTMove (result of  
> member move).  However this is at least conceptually the same as  
> implicitly converting from an rvalue smart pointer.
>   
But I the main objections to the implicit conversion in the article are 
technical, not conceptual. And technically, it's not at all the same, 
because you always have to call move() first.

Sebastian



More information about the cfe-dev mailing list