#include <iostream>
template<typename T, size_t N>
constexpr std::size_t arraySize(T (&)[N]) noexcept{
return N;
}
template<typename T>
class V{
public:
using type = V<T>;
constexpr V(T x, T y) noexcept : x(x), y(y) {}
friend constexpr type operator+(const type& lhs, const type& rhs) noexcept{
return std::move ( type(lhs.x + rhs.x, lhs.y + rhs.y) );
}
constexpr T lengthSqare () noexcept {return x*x+y*y;};
T x,y;
};
int main(int argc, const char * argv[]) {
char a1[(V<int>(1,2) + V<int>(3,5)).x];
char a2[V<int>(2,2).lengthSqare()];
std::cout<<"Some compile time vec+ "<<arraySize(a1)<<std::endl;
std::cout<<"And compile time lenght^2 is: "<<arraySize(a2)<<std::endl;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdGVtcGxhdGU8dHlwZW5hbWUgVCwgc2l6ZV90IE4+CmNvbnN0ZXhwciBzdGQ6OnNpemVfdCBhcnJheVNpemUoVCAoJilbTl0pIG5vZXhjZXB0ewogICAgcmV0dXJuIE47Cn0KCgp0ZW1wbGF0ZTx0eXBlbmFtZSBUPgpjbGFzcyBWewpwdWJsaWM6CiAgICB1c2luZyB0eXBlID0gVjxUPjsKICAgIGNvbnN0ZXhwciBWKFQgeCwgVCB5KSBub2V4Y2VwdCA6IHgoeCksIHkoeSkge30KICAgIGZyaWVuZCBjb25zdGV4cHIgdHlwZSBvcGVyYXRvcisoY29uc3QgdHlwZSYgbGhzLCBjb25zdCB0eXBlJiByaHMpIG5vZXhjZXB0ewogICAgICAgIHJldHVybiBzdGQ6Om1vdmUgKCB0eXBlKGxocy54ICsgcmhzLngsIGxocy55ICsgcmhzLnkpICk7CiAgICB9CiAgICBjb25zdGV4cHIgVCBsZW5ndGhTcWFyZSAoKSBub2V4Y2VwdCB7cmV0dXJuIHgqeCt5Knk7fTsKICAgIFQgeCx5Owp9OwoKaW50IG1haW4oaW50IGFyZ2MsIGNvbnN0IGNoYXIgKiBhcmd2W10pIHsKICAgIGNoYXIgYTFbKFY8aW50PigxLDIpICsgVjxpbnQ+KDMsNSkpLnhdOwogICAgY2hhciBhMltWPGludD4oMiwyKS5sZW5ndGhTcWFyZSgpXTsKICAgIHN0ZDo6Y291dDw8IlNvbWUgY29tcGlsZSB0aW1lIHZlYysgIjw8YXJyYXlTaXplKGExKTw8c3RkOjplbmRsOwogICAgc3RkOjpjb3V0PDwiQW5kIGNvbXBpbGUgdGltZSBsZW5naHReMiBpczogIjw8YXJyYXlTaXplKGEyKTw8c3RkOjplbmRsOwp9