[SAoC] Move semantics and STL containers

bachmeier no at spam.net
Wed Dec 11 17:48:24 UTC 2019


On Wednesday, 11 December 2019 at 17:15:26 UTC, Suleyman wrote:
> On Wednesday, 11 December 2019 at 17:02:47 UTC, bachmeier wrote:
>> On Wednesday, 11 December 2019 at 16:56:40 UTC, Suleyman wrote:
>>> Week 11:
>>>
>>> GCC and Clang versions of std::vector were ported. Like the 
>>> windows port version there is not range API yet, only arrays 
>>> are accepted, for this reason the bitmap packed vector<bool> 
>>> is not yet implemented. The Range interface is on the TODO 
>>> list for the future.
>>
>> Could you expand a bit on this? Does it mean I can call a C++ 
>> function taking std::vector<double> as an argument with a 
>> double[] allocated on the D side?
>
> D doesn't have implicit constructors for function parameters 
> otherwise you could do what you've described.
>
> But you can currently construct a vector and assign it from an 
> array, it just won't do it automatically for function arguments 
> for the reason mentioned.
>
> Example:
> ```
> import core.stdcpp.vector;
>
> // construct
> vector!double v = [1.0, 2.1];
>
> double[] a = [];
> // assign
> v = a;
>
> void f(vector!double);
> f(a); // error
> ```

Okay. That's reasonable. Does v = a copy or can we reuse a.ptr 
with your implementation? Keep in mind that I don't know much 
about std::vector or the work you're doing.


More information about the Digitalmars-d mailing list