How do I know when to use `const ref` or `in`?

Viewed 123
void foo(T, size_t size)(in T[size] data){...}
//vs
void foo(T, size_t size)(const ref T[size] data){...}

According to https://stackoverflow.com/a/271344/944430 it seems that in C++ pass by value can be faster in some situations.

But D has a special keyword in and I am wondering when I should use it. Does in always result in a copy or is it a compiler optimization?

Are there any guidelines that I can follow that help me decide between const ref and in?

1 Answers
Related