[SAoC] Move semantics and STL containers
Suleyman
sahmi.soulaimane at gmail.com
Wed Dec 11 17:15:26 UTC 2019
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
```
More information about the Digitalmars-d
mailing list