Hard
A class type as a non-type template parameter
Compiled as C++20, what happens when this is compiled?
main.cpp
#include <iostream>
class Vec2 {
public:
constexpr Vec2(int x, int y) : x_(x), y_(y) {}
int x_, y_;
private:
int cachedNorm_ = 0;
};
template <Vec2 V>
struct Fixed {
static constexpr int sum = V.x_ + V.y_;
};
int main() {
constexpr Vec2 v{3, 4};
Fixed<v> f;
std::cout << f.sum << std::endl;
}36 of 117 in C++