Skip to content

Instantly share code, notes, and snippets.

@hutorny
Created November 27, 2016 06:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hutorny/c9340f7aa469974584d44e5eed660719 to your computer and use it in GitHub Desktop.
Save hutorny/c9340f7aa469974584d44e5eed660719 to your computer and use it in GitHub Desktop.
/** assign - assigns a value to all array elements
* usage: short arr[77]; assign(arr,88);
* License: MIT */
template<typename T, size_t N, typename V>
static inline void assign(T (&a)[N], V v) noexcept {
for(size_t i=0; i<N; ++i) a[i] = v;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment