{"id":9992,"date":"2021-02-15T10:39:09","date_gmt":"2021-02-15T10:39:09","guid":{"rendered":"http:\/\/www.max-sperling.bplaced.net\/?p=9992"},"modified":"2024-05-28T08:04:44","modified_gmt":"2024-05-28T08:04:44","slug":"declaration-specifiers-c","status":"publish","type":"post","link":"http:\/\/www.max-sperling.bplaced.net\/?p=9992","title":{"rendered":"Declaration specifiers (C++)"},"content":{"rendered":"<p>The following list is just a selection.<\/p>\n<table>\n<tr>\n<th>Specifier<\/th>\n<th>Variable<\/th>\n<th>Function<\/th>\n<\/tr>\n<tr>\n<th>const<\/th>\n<td>Can&#8217;t be modified.<sup>1<\/sup><\/td>\n<td>Method: Can&#8217;t modify its fields.<sup>1<\/sup><\/td>\n<\/tr>\n<tr>\n<th>constexp<\/th>\n<td colspan=\"2\">Calculation happens (if possible) during compile time.<sup>2<\/sup><\/td>\n<\/tr>\n<tr>\n<th>extern<\/th>\n<td colspan=\"2\">Global: Can be defined in another translation unit.<sup>3<\/sup><\/td>\n<\/tr>\n<tr>\n<th>final<\/th>\n<td><\/td>\n<td>Method: Can&#8217;t be overridden in a derived class.<\/td>\n<\/tr>\n<tr>\n<th>inline<\/th>\n<td><\/td>\n<td>Code gets inserted at calling spots.<sup>4<\/sup><\/td>\n<\/tr>\n<tr>\n<th>mutable<\/th>\n<td>Field: Modifiable, even if object is const.<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<th>noexcept<\/th>\n<td><\/td>\n<td>Shall not throw an exception.<sup>5<\/sup><\/td>\n<\/tr>\n<tr>\n<th>override<\/th>\n<td><\/td>\n<td>Method: Overrides a virtual method of a base class.<\/td>\n<\/tr>\n<tr>\n<th rowspan=\"2\">static<\/th>\n<td colspan=\"2\">Field \/ Method: Part of the class, not the objects.<br \/>Global: Restricts the visibility to its translation unit.<\/td>\n<\/tr>\n<tr>\n<td>Local: Stays alive after leaving the scope.<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<th>thread_local<\/th>\n<td>Local: Like static, but each thread has its own.<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<th>virtual<\/th>\n<td><\/td>\n<td>Method: Overridable in inheriting classes.<\/td>\n<\/tr>\n<tr>\n<th>volatile<\/th>\n<td>No compiler optimization allowed.<sup>6<\/sup><\/td>\n<td><\/td>\n<\/tr>\n<\/table>\n<p><sup>1<\/sup> Exception: Fields with mutable<br \/>\n<sup>2<\/sup> Faster run time, slower compile time.<br \/>\n<sup>3<\/sup> Default for non-const vars and funcs.<br \/>\n<sup>4<\/sup> Better performance, larger binary.<br \/>\n<sup>5<\/sup> Else std::terminate() gets executed.<br \/>\n<sup>6<\/sup> Worse performance, always right value.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The following list is just a selection. Specifier Variable Function const Can&#8217;t be modified.1 Method: Can&#8217;t modify its fields.1 constexp<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false},"categories":[27],"tags":[],"_links":{"self":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/9992"}],"collection":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9992"}],"version-history":[{"count":14,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/9992\/revisions"}],"predecessor-version":[{"id":17636,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=\/wp\/v2\/posts\/9992\/revisions\/17636"}],"wp:attachment":[{"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9992"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9992"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.max-sperling.bplaced.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9992"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}