6th May 2012
What's Different About Static Members Defined In-line?
While writing my previous post, a question came to mind.
The following is not valid:
struct T
{
static const size_t BUF_SIZE;
char buf[BUF_SIZE];
};
size_t T::BUF_SIZE = 256;
// error: array bound is not an integer constant
Clearly, for any instance of T
, the array bound could be found in a different translation unit and T
's size would be incalculable.
However, since the following compiles and links, I came to wonder whether it's really well-defined:
struct T
{
static const size_t BUF_SIZE = 100*1024;
char buf[BUF_SIZE];
};
My standard-fu fails me so far…