Created
December 2, 2012 04:36
-
-
Save boatilus/4186981 to your computer and use it in GitHub Desktop.
Statically-checked std::array set()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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