This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Cannot convert int (aka NULL) to std::vector<double*>::value_type


On Mon, 2013-02-04 at 23:52 -0800, mmcwilli@uvic.ca wrote:
> Hi nick
> 
>     Thanks nick, really appreciate you taking the time to look into my
> error and finding a fix. I will work on it tomorrow. Could you answer
> one question, is this a compiler bug or a standards conformance issue?
> Thanks a tonne for your help!

You're welcome.  Unfortunately I don't know whether this is a bug or
expected w/ the newer standard.

I tried the alternatives in my previous e-mail based on the error
message from GCC:

error: invalid conversion from 'int' to
'std::vector<double*>::value_type {aka double*}'

So clearly it sees 'NULL' as an int, which is understandable since it's
not an actual type (that's what nullptr addressed) and is usually a
#define for 0.

I'm guessing using anything that's implicitly convertible to double* and
has a value of 0 should work for you.  That being said, qualifying NULL
as a double* also works:

	vector<double*> myVect(1,static_cast<double*>(NULL) );

Beyond whether this is a bug or not, I suggest using nullptr as that's
the proper representation of "NULL" going forward.


Nick



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]