{"id":915,"date":"2012-05-06T15:40:34","date_gmt":"2012-05-06T15:40:34","guid":{"rendered":"http:\/\/kera.name\/articles\/?p=915"},"modified":"2012-05-06T16:03:01","modified_gmt":"2012-05-06T16:03:01","slug":"whats-different-about-static-members-defined-in-line","status":"publish","type":"post","link":"https:\/\/kera.name\/articles\/2012\/05\/whats-different-about-static-members-defined-in-line\/","title":{"rendered":"What&#039;s Different About Static Members Defined In-line?"},"content":{"rendered":"<p>While writing <a href=\"\/articles\/2012\/05\/when-is-a-scoped-lock-not-a-scoped-lock\/\">my previous post<\/a>, a question came to mind.<\/p>\n<p>The following is not valid:<\/p>\n<pre><code>struct T\n{\n   static const size_t BUF_SIZE;\n   char buf[BUF_SIZE];\n};\n\nsize_t T::BUF_SIZE = 256;\n\n\/\/ error: array bound is not an integer constant<\/code><\/pre>\n<p>Clearly, for any instance of <code>T<\/code>, the array bound could be found in a different translation unit and <code>T<\/code>&#039;s size would be incalculable.<\/p>\n<p>However, since the following compiles and links, I came to wonder whether it&#039;s really well-defined:<\/p>\n<pre><code>struct T\n{\n   static const size_t BUF_SIZE = 100*1024;\n   char buf[BUF_SIZE];\n};<\/code><\/pre>\n<p>My standard-fu fails me so far&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>While writing my previous post, a question came to mind regarding the use of static members for bounding arrays that are members of the same type.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[21,20,12],"_links":{"self":[{"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/posts\/915"}],"collection":[{"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/comments?post=915"}],"version-history":[{"count":7,"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/posts\/915\/revisions"}],"predecessor-version":[{"id":926,"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/posts\/915\/revisions\/926"}],"wp:attachment":[{"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/media?parent=915"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/categories?post=915"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kera.name\/articles\/wp-json\/wp\/v2\/tags?post=915"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}