I have a custom Buf struct (working as a simple vector)

struct Buf(T) {
    size_t cap, len;
    T *data;

    this(T[] arr) {
        foreach(item; arr) {

And I have a function like this:

void test(Buf!(int) buf) {

I want to be able to make it work array-like to have compact function calls.
Something like this:

Currently I have the constructor shown and with that I do:
which is compact but can it be done differently? Meaning, if a function takes a Buf!(T), can it also take a T[] and construct a Buf!(T) using some constructor?

Thanks in advance!

Reply via email to