#include <iostream>
using namespace std;
template<typename T,int N> constexpr bool bounds_check(T (&array)[N], int i)
{
return i < N;
}
int main() {
int a[] = { 21, 213, 45 };
static_assert(bounds_check(a, 22), "error for a\n");
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKICAgIHRlbXBsYXRlPHR5cGVuYW1lIFQsaW50IE4+IGNvbnN0ZXhwciBib29sIGJvdW5kc19jaGVjayhUICgmYXJyYXkpW05dLCBpbnQgaSkKICAgIHsKICAgICAgICByZXR1cm4gaSA8IE47CiAgICB9CgppbnQgbWFpbigpIHsKICAgIGludCBhW10gPSB7IDIxLCAyMTMsIDQ1IH07CiAgICBzdGF0aWNfYXNzZXJ0KGJvdW5kc19jaGVjayhhLCAyMiksICJlcnJvciBmb3IgYVxuIik7CglyZXR1cm4gMDsKfQ==
prog.cpp: In function ‘int main()’:
prog.cpp:11:5: error: static assertion failed: error for a
static_assert(bounds_check(a, 22), "error for a\n");
^