POV-Ray : Newsgroups : povray.off-topic : C++: Seriously? : Re: C++: Seriously? Server Time
28 Jul 2024 16:23:11 EDT (-0400)
  Re: C++: Seriously?  
From: Le Forgeron
Date: 22 Nov 2013 05:13:10
Message: <528f2e36@news.povray.org>
Le 21/11/2013 23:20, Orchid Win7 v1 a écrit :
> On 21/11/2013 09:15 PM, Warp wrote:
>> Orchid Win7 v1<voi### [at] devnull>  wrote:
>>> The suggested solution? "Why don't you just use a std::vector<char>?"
>>
>>> Erm... because std::vector<char>  /= char *. One is basically an
>>> unstructured chunk of arbitrary memory, this other is a complex
>>> implementation-dependent data structure.
>>
>> std::vector is not very implementation-dependent because the standard
>> guarantees certain properties for it. One of these properties is that
>> std::vector will always allocate contiguous memory (in the same way
>> as 'new[]' does.)
> 
> The standard actually *promises* this? So there is literally only one
> possible implementation for vector?
> 
> Wow. My mind is blown...

It's not a promise, it's a contract.
you can make your own std::vector (well, if you dare to provide your own
compiler...), but you can only claims conformance to standard if your
implementation provides all the tiny expectation that are in the
standard. The standard describes the minimal requirements, you can
provide more than the bare minimum.

And if you are not conform, you should not name it std::vector.

If it is named spoon and works like a spoon, it's a spoon and everybody
will be ok.
If you name it spoon and it works like a fork without being able to be
use as spoon in all aspect, you are putting shit on everyone.
If you name it spoon and it can work as well as a spoon or a fork, it's ok.

-- 
Just because nobody complains does not mean all parachutes are perfect.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.