Well, that's a static type system.

I would explain this 'asymmetry' as:

some_pointer_type -> pointer_to_void conversion is safe (given that it's 
possible at all, since not every pointer type can be implicitly converted to 
void *).

while hypothetical (non-existent) implicit

pointer_to_void -> some_pointer_type 

IS NOT, and compiler, issuing error messages will help you to avoid some 
troubles.

________________________________________
From: René J.V. Bertin <[email protected]>
Sent: Friday, October 09, 2015 5:51 PM
To: Pocheptsov Timur
Cc: [email protected]
Subject: Re: [Development] 0 vs. NULL

On Friday October 09 2015 13:58:37 Pocheptsov Timur wrote:

> if NULL was (void *)0 - you'd have a compilation error in C++, since there is 
> no such implicit conversion.
>
> And yes, void * in C++ can be indeed considered generic, because you can do 
> this:
>
> int * p = ...
> void * pv = p;

Coming from C I have some trouble with that concept of generic pointer. Once 
you're used that it implies not only "can be assigned to any type of pointer" 
but also "can be assigned any type of pointer" it's not so easy to remember 
which of the 2 properties has been dropped. I don't see any evident reason why 
in the above example it should be possible to assign p to pv without an 
explicit cast, but not the other way round.

R.
_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to