I can do:
template <int n>
struct Buffer
{
char buffer[n * 128];
};
template <int n>
Buffer<n> buffer; // When I instantiate this the compiler makes many different static variables
int main()
{
buffer<sizeof(int)>;
buffer<sizeof(char)>;
buffer<sizeof(double)>;
buffer<sizeof(std::string)>;
}
But for some reason it fails to compile when I want the buffer object inside a class as a static variable:
template <int n>
struct Buffer
{
char buffer[n];
};
struct MyStaticClass
{
template <int n>
static inline Buffer<n> buffer;
};
int main()
{
MyStaticClass::buffer < sizeof(int)>;
//'public: static Buffer<4> MyStaticClass::buffer<4>': inline variable is undefined
}
I am on Visual 2019 Community 16.4.5 I have /std:c++latest flag on