Skip to content

Instantly share code, notes, and snippets.

@boatilus
Created December 2, 2012 04:36
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 boatilus/4186981 to your computer and use it in GitHub Desktop.
Save boatilus/4186981 to your computer and use it in GitHub Desktop.
Statically-checked std::array set()
namespace stdx {
template <size_t position, typename T, size_t size>
void set(std::array<T, size>& arr, const T& value) noexcept {
static_assert(position < size, "index out of bounds");
arr[position] = value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment