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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 2013-02-04 at 23:52 -0800, mmcwilli@xxxxxxx 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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux