Add an example

This commit is contained in:
Johannes Laire
2015-09-29 11:01:26 +02:00
parent 9a976c8a85
commit 74b5debe8c

View File

@@ -1435,6 +1435,10 @@ Use `const` for the "from" argument:
void copy_n(const T* p, T* q, int n); // copy from [p:p+n) to [q:q+n) void copy_n(const T* p, T* q, int n); // copy from [p:p+n) to [q:q+n)
**Example**: If the order of the parameters is not important, there is no problem:
int max(int a, int b);
**Alternative**: Don't pass arrays as pointers, pass an object representing a range (e.g., an `array_view`): **Alternative**: Don't pass arrays as pointers, pass an object representing a range (e.g., an `array_view`):
void copy_n(array_view<const T> p, array_view<T> q); // copy from p to q void copy_n(array_view<const T> p, array_view<T> q); // copy from p to q