{"id":305142,"date":"2020-06-10T15:00:14","date_gmt":"2020-06-10T15:00:14","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=305142"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=305142","title":{"rendered":"\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b, \u043a\u0432\u0430\u043b\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u044b"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/jugru\/blog\/506104\/\">\n<pre><code class=\"cpp\">template&lt;class T&gt; static inline thread_local constexpr const volatile T x = {};<\/code><\/pre>\n<p>  \u0422\u0430\u043a\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0441\u043b\u043e\u0432 \u0432\u0432\u0435\u0434\u0435\u0442 \u0432 \u0441\u0442\u0443\u043f\u043e\u0440 \u043b\u044e\u0431\u043e\u0433\u043e \u043d\u0435\u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430. \u041d\u043e \u043d\u0430 C++ Russia 2019 Piter \u041c\u0438\u0445\u0430\u0438\u043b \u041c\u0430\u0442\u0440\u043e\u0441\u043e\u0432 (<a href=\"https:\/\/habr.com\/ru\/users\/mmatrosov\/\" class=\"user_link\">mmatrosov<\/a>) \u0440\u0430\u0437\u043b\u043e\u0436\u0438\u043b \u043f\u043e \u043f\u043e\u043b\u043e\u0447\u043a\u0430\u043c \u043a\u0432\u0430\u043b\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u0438 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u043f\u0440\u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439. <\/p>\n<p>  \u041c\u044b \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b\u0438 \u0434\u043b\u044f \u0432\u0430\u0441 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0434\u043e\u043a\u043b\u0430\u0434\u0430, \u0447\u0442\u043e\u0431\u044b \u0432\u044b \u043c\u043e\u0433\u043b\u0438 \u0432 \u043b\u044e\u0431\u043e\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u0438 \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u0448\u043f\u0430\u0440\u0433\u0430\u043b\u043a\u0438 \u041c\u0438\u0445\u0430\u0438\u043b\u0430.<a name=\"habracut\"><\/a><\/p>\n<div class=\"oembed\">\n<div>\n<div style=\"left: 0; width: 100%; height: 0; position: relative; padding-bottom: 56.25%;\"><iframe src=\"https:\/\/www.youtube.com\/embed\/G_jcBrrYPAs?rel=0&amp;showinfo=1&amp;hl=en-US\" style=\"border: 0; top: 0; left: 0; width: 100%; height: 100%; position: absolute;\" allowfullscreen scrolling=\"no\" allow=\"encrypted-media; accelerometer; gyroscope; picture-in-picture\"><\/iframe><\/div>\n<\/div>\n<\/div>\n<p>  <\/p>\n<h2>\u0418\u0437 \u0434\u043e\u043a\u043b\u0430\u0434\u0430 \u0432\u044b \u0443\u0437\u043d\u0430\u0435\u0442\u0435:<\/h2>\n<p>  <\/p>\n<ul>\n<li>\u043a\u0430\u043a \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0441\u0434\u0435\u043b\u0430\u0442\u044c internal \u0438 external linkage;<\/li>\n<li>\u043f\u043e\u0447\u0435\u043c\u0443 inline \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u043e\u0431\u044b\u0447\u043d\u043e \u043b\u0443\u0447\u0448\u0435\u043c, \u0447\u0435\u043c extern;<\/li>\n<li>\u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445;<\/li>\n<li>8 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443 (\u0443\u0436\u0430\u0441!);<\/li>\n<li>\u043a\u0430\u043a\u043e\u0435 \u0441\u0432\u0435\u0442\u043b\u043e\u0435 \u0431\u0443\u0434\u0443\u0449\u0435\u0435 \u043e\u0431\u0435\u0449\u0430\u0435\u0442 C++20.<\/li>\n<\/ul>\n<p>  \u041a\u0441\u0442\u0430\u0442\u0438, \u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u0441\u0442\u0443\u043f\u043b\u0435\u043d\u0438\u0435\u043c \u043d\u0430\u0448 \u0436\u0443\u0440\u043d\u0430\u043b\u0438\u0441\u0442 \u041e\u043b\u0435\u0433 \u0427\u0438\u0440\u0443\u0445\u0438\u043d (<a href=\"https:\/\/habr.com\/ru\/users\/olegchir\/\" class=\"user_link\">olegchir<\/a>) \u0438 \u041f\u0430\u0432\u0435\u043b \u0424\u0438\u043b\u043e\u043d\u043e\u0432 \u0438\u0437 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u0438\u0442\u0435\u0442\u0430 C++ Russia \u0432\u0437\u044f\u043b\u0438 \u0443 \u041c\u0438\u0445\u0430\u0438\u043b\u0430 <a href=\"https:\/\/habr.com\/ru\/company\/jugru\/blog\/473628\/\">\u0438\u043d\u0442\u0435\u0440\u0432\u044c\u044e<\/a>, \u0433\u0434\u0435 \u043e\u043d \u043f\u043e\u0434\u0435\u043b\u0438\u043b\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c\u0438 \u0438\u0441\u0442\u043e\u0440\u0438\u044f\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0432 Align Technology, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043e\u043f\u044b\u0442\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0434 \u043e\u043d\u043b\u0430\u0439\u043d-\u043a\u0443\u0440\u0441\u0430\u043c\u0438.<\/p>\n<p>  <b>\u0414\u0430\u043b\u0435\u0435 \u2014 \u043f\u043e\u0432\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0442 \u043b\u0438\u0446\u0430 \u0441\u043f\u0438\u043a\u0435\u0440\u0430.<\/b><\/p>\n<h2>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0442\u0435\u043e\u0440\u0438\u0438<\/h2>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0434\u0435\u043c \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u044d\u043a\u0441\u043a\u0443\u0440\u0441, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0439 \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b \u0434\u043e\u043a\u043b\u0430\u0434\u0430. <\/p>\n<p>  \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u0431\u043e\u0440\u043a\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043d\u0430 C++:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/no\/og\/oz\/noogozalzg0r4zzgrm3ymzsva0w.png\"><\/p>\n<p>  \u0412 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 cpp-\u0444\u0430\u0439\u043b\u044b \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0442 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0435 hpp-\u0444\u0430\u0439\u043b\u044b. \u0412\u043e \u0432\u0440\u0435\u043c\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u043f\u0435\u0440\u0432\u044b\u043c \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u0440\u0435\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440. \u0418\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u043e\u043d \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0435\u0434\u0438\u043d\u0438\u0446\u044b \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u0438 (translation units), \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0431\u0440\u0430\u043d\u044b \u0432\u0441\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b (headers), \u0430 \u0437\u0430 \u043d\u0438\u043c\u0438 \u0438\u0434\u0435\u0442 \u0442\u0435\u043b\u043e cpp-\u0444\u0430\u0439\u043b\u0430. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043d\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0438\u0445 \u0432 \u044f\u0432\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u043d\u0430 \u0436\u0435\u0441\u0442\u043a\u043e\u043c \u0434\u0438\u0441\u043a\u0435, \u0430 \u043e\u043d\u0438 \u043b\u0435\u0436\u0430\u0442 \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u0435\u0434\u0438\u043d\u0438\u0446\u044b \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u0438 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u044b, \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u044e \u043a\u0430\u0436\u0434\u043e\u0439 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0435\u0434\u0438\u043d\u0438\u0446\u044b \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u044b\u0439 \u0444\u0430\u0439\u043b. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u0449\u0438\u043a\u0443 (linker), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b \u0432 \u0438\u0442\u043e\u0433\u043e\u0432\u0443\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0438\u043b\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435. \u0423 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0433\u043e\u0434\u043d\u043e \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0439, \u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 (\u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u0433\u0434\u0435 \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439, \u043d\u043e \u0432\u0441\u0435 \u043e\u043d\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438).<\/p>\n<pre><code class=\"cpp\">\/\/ Function declaration int sqr(int x);  \/\/ Function definition int sqr(int x) { return x * x; }  \/\/ Variable declarations extern int n; struct A { static int n; };  \/\/ Variable definitions int n; int A::n;<\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043f\u043e\u043d\u044f\u0442\u0438\u044e linkage. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0443\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443. \u0412 \u0444\u0430\u0439\u043b\u0435 <code>a.cpp<\/code> \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <i>sqr()<\/i>:<\/p>\n<pre><code class=\"cpp\">int sqr(int x) {      return x * x; }<\/code><\/pre>\n<p>  \u0410 \u0432 \u0444\u0430\u0439\u043b\u0435 <code>b.cpp<\/code> \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0435\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0438 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f <i>check()<\/i>:<\/p>\n<pre><code class=\"cpp\">int sqr(int x);  bool check(int a, int b, int c) {     return sqr(a) + sqr(b) == sqr(c); } <\/code><\/pre>\n<p>  \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 a.cpp \u0438\u043c\u0435\u0435\u0442 external linkage. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u0433\u0434\u0430 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b, \u0432 a.obj \u043e\u043d \u043f\u043e\u043b\u043e\u0436\u0438\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 sqr(), \u0430 \u0432 b.obj \u2014 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0441 \u043f\u043e\u043c\u0435\u0442\u043a\u043e\u0439, \u0447\u0442\u043e \u0432 \u043a\u0430\u043a\u043e\u043c-\u0442\u043e \u0444\u0430\u0439\u043b\u0435 \u043b\u0435\u0436\u0438\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 sqr(), \u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u0449\u0438\u043a \u0435\u0433\u043e \u043d\u0430\u0439\u0434\u0435\u0442. \u0415\u0441\u043b\u0438 \u0436\u0435 \u0432 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e static, \u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0435 \u0441\u043e\u0431\u0435\u0440\u0435\u0442\u0441\u044f \u0438\u0437-\u0437\u0430 \u043e\u0448\u0438\u0431\u043a\u0438 \u043b\u0438\u043d\u043a\u043e\u0432\u043a\u0438. \u0422\u0430\u043a \u043a\u0430\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044f sqr() \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c internal linkage, \u0442\u043e \u0435\u0441\u0442\u044c \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0435\u0434\u0438\u043d\u0438\u0446\u0430\u0445 \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u0438, \u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u0449\u0438\u043a \u0435\u0451 \u043d\u0435 \u043d\u0430\u0439\u0434\u0451\u0442.<\/p>\n<p>  \u041a\u0440\u043e\u043c\u0435 external linkage \u0438 internal linkage \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0441\u0442\u0430\u0442\u0443\u0441 no linkage. \u0422\u0430\u043a\u0430 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0430. \u0422\u0438\u043f\u0438\u0447\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u2014 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u043c \u0442\u0438\u043f\u044b storage duration \u0432 C++:<\/p>\n<ul>\n<li><b>automatic<\/b> \u2014 \u043f\u0430\u043c\u044f\u0442\u044c \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u0442\u043e\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0445\u043e\u0434\u0438\u0442 \u0432 scope, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0430, \u0438 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u0442\u043e\u043a \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0438\u0437 scope;<\/li>\n<li><b>static<\/b> \u2014 \u043f\u0430\u043c\u044f\u0442\u044c \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443, \u0438 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443;<\/li>\n<li><b>thread<\/b> \u2014 \u043f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430 static storage duration, \u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u043e \u043a \u043f\u043e\u0442\u043e\u043a\u0443 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f;<\/li>\n<li><b>dynamic<\/b> \u2014 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0437\u043e\u0432\u043e\u0432 <i>new<\/i> \u0438 <i>delete<\/i>.<\/li>\n<\/ul>\n<p>  \u041f\u043e\u043d\u044f\u0442\u0438\u0435 storage duration \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0433\u0434\u0435-\u0442\u043e \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e. \u0412\u0441\u0435 \u0437\u0432\u0443\u0447\u0438\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u0441\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044e \u043f\u0430\u043c\u044f\u0442\u0438. \u0410 \u0432\u043e\u0442 \u043c\u043e\u043c\u0435\u043d\u0442, \u043a\u043e\u0433\u0434\u0430 \u043e\u0431\u044a\u0435\u043a\u0442 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u0435\u0435.<\/p>\n<p>  Storage duration \u0438 linkage \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0440\u044f\u0434\u043e\u043c \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0441\u043b\u043e\u0432 (storage class specifiers) \u2014 <i>static, extern, thread_local<\/i> \u0438 <i>mutable<\/i>. Mutable \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044f \u043a Storage duration \u0438 linkage, \u0438 \u043e\u0431 \u044d\u0442\u043e\u043c \u0432 \u0434\u043e\u043a\u043b\u0430\u0434\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442, \u043d\u043e \u043e\u043d \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f storage class specifier.<\/p>\n<p>  \u041d\u0430 \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u044d\u043a\u0441\u043a\u0443\u0440\u0441\u0435 \u043c\u044b \u043e\u0442\u0432\u0435\u0442\u0438\u043b\u0438 \u043d\u0430 \u0442\u0440\u0438 \u0432\u043e\u043f\u0440\u043e\u0441\u0430:<\/p>\n<ul>\n<li>\u0427\u0442\u043e? \u041e\u0431\u044a\u0435\u043a\u0442.<\/li>\n<li>\u0413\u0434\u0435? Linkage.<\/li>\n<li>\u041a\u043e\u0433\u0434\u0430? Storage duration.<\/li>\n<\/ul>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e C++ \u043d\u0435 \u0431\u044b\u043b \u0431\u044b C++, \u0435\u0441\u043b\u0438 \u0431\u044b \u0432\u0441\u0435 \u0431\u044b\u043b\u043e \u0442\u0430\u043a \u043f\u0440\u043e\u0441\u0442\u043e.<\/p>\n<h2>Internal \u0438 external linkage <\/h2>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440. \u0412 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 common.hpp \u043e\u0431\u044a\u044f\u0432\u0438\u043b\u0438 \u0434\u0432\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b:<\/p>\n<pre><code class=\"cs\">const double thickness = 0.65; const char* name = &quot;tooth&quot;; <\/code><\/pre>\n<p>  \u0410 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b a.cpp \u0438 b.cpp \u0432\u043a\u043b\u044e\u0447\u0438\u043b\u0438 \u044d\u0442\u043e\u0442 hpp-\u0444\u0430\u0439\u043b:<\/p>\n<pre><code class=\"cpp\">\/\/ a.cpp #include \u201ccommon.hpp\u201d  \/\/ b.cpp #include \u201ccommon.hpp\u201d<\/code><\/pre>\n<p>  \u042d\u0442\u043e \u043d\u0435 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439 \u043e\u0434\u043d\u043e\u0433\u043e \u0438 \u0442\u043e\u0433\u043e \u0436\u0435 \u0438\u043c\u0435\u043d\u0438 name. \u041e\u0434\u043d\u0430\u043a\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043d\u0435 \u0440\u0443\u0433\u0430\u0435\u0442\u0441\u044f \u043d\u0430 <i>thickness<\/i>. \u041f\u043e\u0447\u0435\u043c\u0443?<\/p>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u043c\u0441\u044f \u043a <a href=\"https:\/\/en.cppreference.com\/w\/cpp\/language\/storage_duration\">C++ Reference<\/a>:  <\/p>\n<blockquote><p>Any of the following names declared at namespace scope have internal linkage:<\/p>\n<ul>\n<li>non-volatile non-template non-inline const-qualified variables (including constexpr) that aren&#8217;t declared extern and aren&#8217;t previously declared to have external linkage;<\/li>\n<\/ul>\n<p>  <\/p><\/blockquote>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u043e\u0431\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 const-qualified, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u043c\u0435\u044e\u0442 internal linkage, \u0438 \u0438\u0445 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0432 \u0435\u0434\u0438\u043d\u0438\u0446\u0430\u0445 \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b. \u041e\u0434\u043d\u0430\u043a\u043e <i>name<\/i> \u2014 \u044d\u0442\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c, \u0438 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e const \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u043e\u0431\u044a\u0435\u043a\u0442\u0443, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u043d \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442. \u0422\u043e \u0435\u0441\u0442\u044c \u043e\u043d \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u043c \u043d\u0430 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443, \u043d\u043e \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u044b\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u043c. \u0427\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0433\u043e \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u044b\u043c, \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0437\u0430\u043f\u0438\u0441\u044c:<\/p>\n<pre><code class=\"cpp\">const char* const name = &quot;tooth&quot;;<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c <i>name<\/i> \u0441\u0442\u0430\u043b \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u044b\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u043c \u043d\u0430 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443, \u043f\u043e\u043b\u0443\u0447\u0438\u043b internal linkage, \u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c.<\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"cpp\">constexpr double thickness = 0.65; const std::string name = &quot;tooth&quot;; <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e <i>name<\/i> \u2014 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u043d\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b, \u0430 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 constexpr \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432\u043b\u0435\u0447\u0435\u0442 \u0437\u0430 \u0441\u043e\u0431\u043e\u0439 const, \u043f\u043b\u044e\u0441 linkage constexpr \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0432 \u044f\u0432\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u043e\u043f\u0438\u0441\u0430\u043d \u0432 \u0442\u043e\u043c \u0436\u0435 \u0430\u0431\u0437\u0430\u0446\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0431\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u0438\u043c\u0435\u044e\u0442 internal linkage.  <\/p>\n<blockquote><p>Any of the following names declared at namespace scope have internal linkage:<\/p>\n<ul>\n<li>non-volatile non-template non-inline const-qualified variables (including constexpr) that aren&#8217;t declared extern and aren&#8217;t previously declared to have external linkage;<\/li>\n<\/ul>\n<p>  <\/p><\/blockquote>\n<p>  \u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u043f\u0440\u0438\u043c\u0435\u0440\u0443. \u0412 <code>common.hpp<\/code> \u043e\u0441\u0442\u0430\u0432\u0438\u043c <i>name<\/i> \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <i>getName()<\/i>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0438\u0437 \u0440\u0430\u0437\u043d\u044b\u0445 \u0435\u0434\u0438\u043d\u0438\u0446 \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u0438:<\/p>\n<pre><code class=\"cpp\">const std::string name = &quot;tooth&quot;; const char* getName();<\/code><\/pre>\n<p>  \u0412 <code>a.cpp<\/code> \u043c\u044b \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u0430\u0434\u0440\u0435\u0441\u0430 \u0431\u0443\u0444\u0435\u0440\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 <i>name.data()<\/i> \u0438 <i>getName()<\/i>:<\/p>\n<pre><code class=\"cpp\">#include &quot;common.hpp&quot; #include &lt;iostream&gt;  bool dumbCmp(const char* s1, const char* s2) {     return s1 == s2; }  int main() {     std::cout &lt;&lt; std::boolalpha         &lt;&lt; dumbCmp(name.data(), getName()); }<\/code><\/pre>\n<p>  \u0412 <code>b.cpp<\/code> \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <i>getName()<\/i>:<\/p>\n<pre><code class=\"cpp\">#include &quot;common.hpp&quot;  const char* getName() {     return name.data(); }<\/code><\/pre>\n<p>  \u041c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e <i>name<\/i> \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0432 \u043e\u0431\u0435\u0438\u0445 \u0435\u0434\u0438\u043d\u0438\u0446\u0430\u0445 \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u0438. \u041d\u043e \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u0430\u044f \u043b\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0432 \u043e\u0431\u043e\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445? \u041d\u0435\u0442, \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0430\u043f\u0435\u0447\u0430\u0442\u0430\u0435\u0442 false, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0435\u0434\u0438\u043d\u0438\u0446\u044b \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u043a\u043e\u043f\u0438\u044f name, \u0430 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0432 <i>dumbCmp()<\/i> \u0438\u0434\u0435\u0442 \u043d\u0435 \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e, \u0430 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0432\u044b\u0434\u0430\u043b\u0430 true, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044e name \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 <i>inline<\/i>:<\/p>\n<pre><code class=\"cpp\">inline const std::string name = &quot;tooth&quot;;<\/code><\/pre>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u043e \u0432\u0441\u0435\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0431\u0443\u0434\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u043e\u0431\u044a\u0435\u043a\u0442 <i>name<\/i>, \u0438 \u044d\u0442\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u044b\u0439 external linkage. \u0412 \u043a\u0430\u0436\u0434\u043e\u0439 \u0435\u0434\u0438\u043d\u0438\u0446\u0435 \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u0438 \u0432\u0441\u0435 \u0435\u0449\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u0432\u043e\u044f \u043a\u043e\u043f\u0438\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e\u0442 \u0441\u0438\u043c\u0432\u043e\u043b \u043f\u043e\u043f\u0430\u0434\u0435\u0442 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u044b\u0439 \u0444\u0430\u0439\u043b, \u0442\u043e \u043e\u043d \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u043f\u043e\u043c\u0435\u0442\u043a\u0443, \u0447\u0442\u043e \u044d\u0442\u043e weak \u0441\u0438\u043c\u0432\u043e\u043b. \u0418 \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u0449\u0438\u043a \u043f\u0440\u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0432\u044b\u0431\u0435\u0440\u0435\u0442 \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d. \u0412 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0435 \u043d\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u0438\u044f external weak linkage, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c <i>external linkage<\/i>. \u041e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u043b\u0438 \u043f\u043e\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0443\u0442\u0438\u043b\u0438\u0442\u044b \u0442\u0438\u043f\u0430 nm \u0438\u043b\u0438 dumpbin \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 \u044d\u0442\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435, \u0442\u043e \u043e\u043d\u0438 \u0432\u044b\u0432\u0435\u0434\u0443\u0442 \u0438\u043c\u0435\u043d\u043d\u043e <i>external weak linkage<\/i>.<\/p>\n<p>  \u0412 \u0434\u0440\u0443\u0433\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432 <code>a.cpp<\/code> \u0438 <code>b.cpp<\/code> \u0432\u043a\u043b\u044e\u0447\u0438\u043c \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0439 \u0444\u0430\u0439\u043b <code>common.hpp<\/code>, \u0430 \u0432 <code>common.hpp<\/code> \u0437\u0430\u043f\u0438\u0448\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <i>sqr()<\/i>:<\/p>\n<pre><code class=\"cpp\">int sqr(int x) {     return x * x; }<\/code><\/pre>\n<p>  \u042d\u0442\u043e \u043d\u0435 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0435\u0434\u0438\u043d\u0438\u0446\u0435 \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0441\u0432\u043e\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0427\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043b\u0430\u0441\u044c, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 <i>constexpr<\/i>:<\/p>\n<pre><code class=\"cpp\">constexpr int sqr(int x) {      return x * x; }<\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f constexpr-qualified, \u0442\u043e \u043e\u043d\u0430 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f <i>inline<\/i>. \u0410 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 <i>inline<\/i> \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0442\u0430\u043a\u0436\u0435 \u0432\u043b\u0435\u0447\u0435\u0442 external weak linkage. \u0412 \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c C++ <i>inline<\/i> \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u0449\u0438\u043a \u0432\u044b\u0431\u0435\u0440\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438.<\/p>\n<p>  \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u043c\u044b \u043f\u0438\u0448\u0435\u043c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e main.cpp, \u0433\u0434\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043b\u0430\u0441\u0441 Local \u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u0432 \u043d\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e <i>foo()<\/i>:<\/p>\n<pre><code class=\"cpp\">\/\/ main.cpp void other();  struct Local {     static void foo() {         std::cout &lt;&lt; &quot;main &quot;;     } };  int main() {     Local::foo();     other(); }<\/code><\/pre>\n<p>  \u041d\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0432 <code>other.cpp<\/code> \u0442\u043e\u0436\u0435 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u0437\u0430\u0432\u0435\u043b \u043a\u043b\u0430\u0441\u0441 <i>Local<\/i> \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <i>foo()<\/i>:<\/p>\n<pre><code class=\"cpp\">\/\/ other.cpp struct Local {     static void foo() {         std::cout &lt;&lt; &quot;main &quot;;     } };  void other() {     Local::foo(); }<\/code><\/pre>\n<p>  \u0412 \u0438\u0442\u043e\u0433\u0435 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439 \u043e\u0434\u043d\u043e\u0433\u043e \u0438 \u0442\u043e\u0433\u043e \u0436\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0435\u0434\u0438\u043d\u0438\u0446\u0430\u0445 \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u0438. \u041f\u0440\u0438\u0447\u0451\u043c \u044d\u0442\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f <i>\u0440\u0430\u0437\u043d\u044b\u0435<\/i>. \u0422\u0430\u043a\u0430\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u043d\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u043e\u043c\u0443 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044e. \u0422\u043e \u0435\u0441\u0442\u044c \u0444\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043c\u043e\u0436\u0435\u0442 \u043d\u0430\u043f\u0435\u0447\u0430\u0442\u0430\u0442\u044c \u0432\u0441\u0451, \u0447\u0442\u043e \u0443\u0433\u043e\u0434\u043d\u043e. \u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0436\u0435 \u043c\u044b \u0443\u0432\u0438\u0434\u0438\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"cpp\">main main<\/code><\/pre>\n<p>  GCC \u0441\u0447\u0438\u0442\u0430\u0435\u0442, \u0447\u0442\u043e Local \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u0430\u0445 \u2014 \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043a\u043b\u0430\u0441\u0441, \u0432 \u043d\u0451\u043c \u0435\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u044f <i>foo()<\/i>. \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0437\u043d\u0430\u0435\u0442, \u0447\u0442\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u0430\u0445 \u043e\u0431\u044f\u0437\u0430\u043d\u044b \u0431\u044b\u0442\u044c \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u043d \u0432\u0437\u044f\u043b \u043f\u0435\u0440\u0432\u043e\u0435 \u043f\u043e\u043f\u0430\u0432\u0448\u0435\u0435\u0441\u044f \u2014 \u0438\u0437 main.cpp. \u0414\u0440\u0443\u0433\u043e\u0439 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043c\u043e\u0433 \u0431\u044b \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0447\u0442\u043e-\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0435.<\/p>\n<p>  \u042d\u0442\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043a\u043b\u0430\u0441\u0441 Local \u0438\u043c\u0435\u043b external linkage. \u0427\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u043f\u043e\u043b\u043e\u0436\u0438\u043c \u043a\u043b\u0430\u0441\u0441\u044b \u0432 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0435\u043d (unnamed namespace):<\/p>\n<pre><code class=\"cpp\">namespace {     struct Local {         static void foo() {             std::cout &lt;&lt; &quot;main &quot;;         }     }; }<\/code><\/pre>\n<p>  \u0412\u0441\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0438\u043c\u0435\u043d, \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u043c\u0435\u044e\u0442 internal linkage, \u0442\u043e \u0435\u0441\u0442\u044c \u043d\u0438\u0447\u0435\u0433\u043e \u0438\u0437 translation unit \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0441\u043e\u0447\u0438\u0442\u044c\u0441\u044f \u043d\u0430\u0440\u0443\u0436\u0443. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0442\u0430\u043a, \u043a\u0430\u043a \u043c\u044b \u043e\u0436\u0438\u0434\u0430\u0435\u043c:<\/p>\n<pre><code class=\"cpp\">main other<\/code><\/pre>\n<p>  <\/p>\n<h2>\u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0432 \u043a\u0443\u0447\u0443<\/h2>\n<p>  \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a\u0438\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u0435 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0438 \u043c\u0435\u0436\u0434\u0443 storage duration \u0438 linkage:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/xs\/ec\/ga\/xsecgaq52exykhrjuwuz2l-euqq.png\"><\/p>\n<p>  \u0414\u043b\u044f dynamic storage duration \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u044f linkage, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043c\u044b \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 \u043a\u0443\u0447\u0435 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e. \u0414\u043b\u044f automatic storage duration \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u043e \u0442\u043e\u043b\u044c\u043a\u043e no linkage, \u0432\u0435\u0434\u044c \u043f\u0430\u043c\u044f\u0442\u044c \u043f\u043e\u0434 \u043e\u0431\u044a\u0435\u043a\u0442 \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u0438 \u0432 scope, \u0442\u043e \u0435\u0441\u0442\u044c \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c, \u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u0431\u0443\u0434\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0438 thread_local \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u0445.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u043a\u0430\u043a\u043e\u0439 storage duration \u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u043b\u043e\u043a-\u0441\u0445\u0435\u043c\u0443:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/d7\/v1\/cp\/d7v1cpq0gkkjr4hnamvneetp3tg.png\"><\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u0438\u043c\u0435\u0435\u0442 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 thread_local, \u0442\u043e \u0443 \u043d\u0435\u0435 thread storage duration. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a, \u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 scope. \u0415\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0430\u044f, \u0442\u043e \u0443 \u043d\u0435\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 static storage duration. \u0414\u043b\u044f \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0438\u043b\u0438 \u0447\u043b\u0435\u043d\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 static. \u0415\u0441\u043b\u0438 \u043e\u043d \u0435\u0441\u0442\u044c, \u0442\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f, \u0438\u043d\u0430\u0447\u0435 \u2014 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f.<\/p>\n<p>  \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u044d\u0444\u0444\u0435\u043a\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043f\u0440\u043e\u043d\u0430\u0431\u043b\u044e\u0434\u0430\u043b\u0438, \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435 \u0434\u043b\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u0438\u0434\u043e\u0432 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ss\/av\/mx\/ssavmxs4gn17t9qnayamyo_lf7g.png\"><\/p>\n<p>  \u041a\u043e\u043b\u043e\u043d\u043a\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0440\u0430\u0437\u043d\u044b\u043c \u0432\u0438\u0434\u0430\u043c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439, \u0430 \u0441\u0442\u0440\u043e\u043a\u0438 \u2014 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u043a \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u0421\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0442\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u0447\u0442\u043e \u043d\u0438\u0436\u0435, \u0438\u043c\u0435\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u0438\u0439 \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442 \u0447\u0435\u043c \u0442\u0435, \u0447\u0442\u043e \u0432\u044b\u0448\u0435.<\/p>\n<p>  \u0414\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e. \u0418\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043d\u044f\u0442\u044c:<\/p>\n<ul>\n<li>\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043e\u043d\u0430 \u0438\u043c\u0435\u0435\u0442 external linkage;<\/li>\n<li>\u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0430 constexpr, \u0442\u043e \u043e\u043d\u0430 \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 const;<\/li>\n<li>\u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u043a\u0430\u043a const, \u0442\u043e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0432\u043b\u0435\u0447\u0435\u0442 \u0437\u0430 \u0441\u043e\u0431\u043e\u0439 internal linkage (\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432 volatile \u0438 template);<\/li>\n<li>\u0435\u0441\u043b\u0438 \u043e\u043d\u0430 inline, \u0442\u043e \u043e\u043d\u0430 \u0438\u043c\u0435\u0435\u0442 external (weak) linkage;<\/li>\n<li>\u0435\u0441\u043b\u0438 \u043e\u043d\u0430 static, \u0442\u043e \u043e\u043d\u0430 \u0438\u043c\u0435\u0435\u0442 internal linkage, \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u044f \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u043f\u0443\u043d\u043a\u0442\u044b;<\/li>\n<li>\u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u043b\u0435\u0436\u0438\u0442 \u0432 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u0438\u043c\u0435\u043d, \u0442\u043e \u043e\u043d\u0430 \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u043c\u0435\u0435\u0442 internal linkage.<\/li>\n<\/ul>\n<p>  \u0417\u0430\u043f\u0438\u0441\u044c <i>N\/A<\/i> \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e \u0438\u0437 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u043d\u0435\u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u043e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, inline \u043d\u0435\u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u043a \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439.<\/p>\n<p>  \u0410 \u043f\u043e\u0434 \u0437\u0430\u043f\u0438\u0441\u044c\u044e <i>Required<\/i> \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u044d\u0442\u0438 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u044f\u0437\u0430\u043d\u044b \u0438\u043c\u0435\u0442\u044c \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e \u0438\u0437 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430, \u0447\u0442\u043e\u0431\u044b \u0432\u043e\u043e\u0431\u0449\u0435 \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0432 \u044d\u0442\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0443 \u043f\u043e\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 static, \u0442\u043e \u043e\u043d\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0451\u0442 \u0432 \u044d\u0442\u0443 \u0442\u0430\u0431\u043b\u0438\u0446\u0443.<\/p>\n<h2>\u0421\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 extern<\/h2>\n<p>  \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u0433\u0434\u0435 \u043c\u044b \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043b\u0438 \u0431\u0443\u0444\u0435\u0440\u044b, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 <i>inline<\/i>, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0432\u044b\u0432\u0435\u043b\u0430 true. \u041e\u0434\u043d\u0430\u043a\u043e \u044d\u0442\u043e \u043d\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438.<\/p>\n<p>  \u0414\u043e C++17 \u043d\u0435 \u0431\u044b\u043b\u043e inline-\u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445, \u0438 \u043c\u044b \u043c\u043e\u0433\u043b\u0438 \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <i>name<\/i> \u043a\u0430\u043a extern:<\/p>\n<pre><code class=\"cpp\">extern const std::string name;<\/code><\/pre>\n<p>  \u0422\u043e\u0433\u0434\u0430 \u0431\u044b \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430 external linkage \u0438 \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u043b\u0430\u0441\u044c \u0432 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 (declaration). \u041d\u043e \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0433\u0434\u0435-\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u044f\u0432\u043d\u043e\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <i>name<\/i>, \u0438 \u043c\u044b \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0433\u043e \u0432 <code>a.cpp<\/code>:<\/p>\n<pre><code class=\"cpp\">const std::string name = &quot;tooth&quot;;<\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0442\u043e\u0442 \u0436\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b.<\/p>\n<p>  \u041a\u0430\u043a\u0438\u043c\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438 \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 <i>extern<\/i>?<\/p>\n<ul>\n<li>\u041f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043a \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c.<\/li>\n<li>\u041d\u0435\u0441\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c \u0441\u043e <i>static<\/i>.<\/li>\n<li>\u041d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430 \u0441 constexpr \u0438 \u0441 <i>inline<\/i>.<\/li>\n<li>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043d\u0435 \u0432\u0438\u0434\u043d\u043e \u0432 \u0442\u043e\u0447\u043a\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f (\u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a).<\/li>\n<\/ul>\n<p>  \u0423 <i>extern<\/i> \u0435\u0441\u0442\u044c \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a: \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0434\u0435\u043b\u0430\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435, \u0442\u043e \u0435\u0441\u0442\u044c \u044f\u0432\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0430. \u041e\u0434\u043d\u0430\u043a\u043e \u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438 <i>extern<\/i> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0441\u0431\u043e\u0440\u043a\u0438. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u0442\u043e <i>extern<\/i> \u0434\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430 \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u0449\u0438\u043a, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u043f\u0430\u0434\u0430\u0442\u044c \u0432 \u043a\u0430\u0436\u0434\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u044b\u0439 \u0444\u0430\u0439\u043b, \u043a\u0430\u043a \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441 <i>inline<\/i>.<\/p>\n<p>  \u041d\u043e \u044d\u0442\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442, \u0438 \u043e\u0431\u044b\u0447\u043d\u043e \u0432\u043c\u0435\u0441\u0442\u043e extern \u043b\u0443\u0447\u0448\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <i>inline<\/i>.<\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c extern \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u0439 \u0441\u0432\u043e\u0439\u0441\u0442\u0432 \u0438 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/6h\/fn\/gm\/6hfngmfpezpyszi0c_0ssbbnrde.png\"><\/p>\n<p>  \u0414\u043b\u044f \u043d\u0435 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 <i>extern<\/i> \u043d\u0435\u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c. \u0414\u043b\u044f \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0445 \u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0438\u0437\u043b\u0438\u0448\u0435\u043d, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043b\u044e\u0431\u043e\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <i>extern<\/i>. \u041d\u043e \u0434\u043b\u044f \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u0438 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c external linkage \u0438 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u0435\u0435 \u0432 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439.<\/p>\n<h2>Practice time<\/h2>\n<p>  \u041e\u0442 \u0442\u0435\u043e\u0440\u0438\u0438 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0442\u0430\u043a\u043e\u0439 \u043a\u043b\u0430\u0441\u0441:<\/p>\n<pre><code class=\"cpp\">struct A {     double x1;     static double x2;     static const double x3;     static inline const double x4 = 4.0;     static constexpr double x5 = 5.0; };<\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0442\u0430\u0431\u043b\u0438\u0446\u0443. \u041d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u043a\u043e\u043b\u043e\u043d\u043a\u0430 member variable. \u041a\u0430\u043a\u0438\u0435 \u0432\u044b\u0432\u043e\u0434\u044b \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c?<\/p>\n<ul>\n<li>x1 \u0438\u043c\u0435\u0435\u0442 automatic storage duration \u0438 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0438\u043c\u0435\u0442\u044c linkage;<\/li>\n<li>x2, x3, x4 \u0438 x5 \u0438\u043c\u0435\u044e\u0442 static storage duration;<\/li>\n<li>x2 \u0438 x3 \u0438\u043c\u0435\u044e\u0442 external linkage. \u041f\u0440\u0438\u0447\u0435\u043c x2 \u0438 x3 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f\u043c\u0438.<\/li>\n<li>x4 \u0438 x5 \u0438\u043c\u0435\u044e\u0442 external (weak) linkage, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d\u0438 inline (<i>constexpr<\/i> \u0432\u043b\u0435\u0447\u0435\u0442 \u0437\u0430 \u0441\u043e\u0431\u043e\u0439 <i>inline<\/i> \u0434\u043b\u044f \u0447\u043b\u0435\u043d\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430). \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043f\u0440\u044f\u043c\u043e \u0432 \u0442\u0435\u043b\u0435 \u043a\u043b\u0430\u0441\u0441\u0430. \u0418 \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u0449\u0438\u043a \u043f\u043e\u0437\u0430\u0431\u043e\u0442\u0438\u0442\u0441\u044f \u043e \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u0435 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u043e\u0432\u0430\u043b\u0438 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0435\u0434\u0438\u043d\u0438\u0446\u0430\u0445 \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u0438.<\/li>\n<\/ul>\n<p>  \u0410 \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 <i>static constexpr<\/i>? \u041c\u044b \u0437\u043d\u0430\u0435\u043c, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0441 constexpr \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0430 static \u044d\u0442\u043e \u043f\u0440\u043e storage duration, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u041c\u043e\u0436\u0435\u0442, \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435\u0442 \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e storage duration, \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438?<\/p>\n<p>  \u041d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c. <code>constexpr<\/code> \u0438 <code>static<\/code> \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043c\u0438\u0440\u0430\u0445. <code>constexpr<\/code> \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0438 \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u043e\u0442 constexpr \u043d\u0435 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0438 \u0441\u043b\u0435\u0434\u0430 (\u043d\u0443, \u0442\u043e\u0447\u043d\u0435\u0435, \u043e\u0442 \u043d\u0435\u0433\u043e \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f const \u0438\u043b\u0438 inline, \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439 \u0441\u0432\u043e\u0439\u0441\u0442\u0432). \u041d\u043e \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f, \u0442\u0435 \u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0443\u0436\u0435 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f. \u041a \u043d\u0438\u043c \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 static, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0441\u0442\u0430\u0434\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0443 \u043d\u0438\u0445 \u0435\u0441\u0442\u044c storage duration.<\/p>\n<p>  \u0421\u0442\u043e\u0438\u0442 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u043d\u0443 \u00ab\u043f\u0430\u0440\u043e\u0447\u043a\u0443\u00bb \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0441\u043b\u043e\u0432 \u2014 <code>const<\/code> \u0438 <code>volatile<\/code>. <code>const<\/code> \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0438\u0437 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0430\u0448 \u043e\u0431\u044a\u0435\u043a\u0442. <code>volatile<\/code> \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c \u0438 \u0447\u0438\u0442\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043e\u043c\u0443-\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u0438\u0437\u0432\u043d\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. <code>const volatile<\/code> \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043c\u044b \u043c\u0435\u043d\u044f\u0442\u044c \u043d\u0435 \u043c\u043e\u0436\u0435\u043c, \u043d\u043e \u0435\u0435 \u043c\u043e\u0436\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043a\u0442\u043e-\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0439. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0432 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043b\u044e\u0431\u043e\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435, \u0433\u0434\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f const, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c volatile.<\/p>\n<h2>\u0428\u0430\u0431\u043b\u043e\u043d\u044b<\/h2>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u0438, \u043a\u043b\u0430\u0441\u0441\u044b \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c\u0438. \u041e\u0434\u043d\u0430\u043a\u043e \u0432\u0430\u0436\u043d\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u043d\u0435 \u0431\u044b\u0432\u0430\u0435\u0442 \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 (template entity), \u0430 \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u044b \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 (entity template). \u0421\u0440\u0430\u0432\u043d\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438 \u0448\u0430\u0431\u043b\u043e\u043d:<\/p>\n<ul>\n<li>\u0448\u0430\u0431\u043b\u043e\u043d \u043d\u0435\u043b\u044c\u0437\u044f \u0432\u044b\u0437\u0432\u0430\u0442\u044c, \u043a\u0430\u043a \u0444\u0443\u043d\u043a\u0446\u0438\u044e;<\/li>\n<li>\u0443 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u043d\u0435\u043b\u044c\u0437\u044f \u0432\u0437\u044f\u0442\u044c \u0430\u0434\u0440\u0435\u0441, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0438;<\/li>\n<li>\u0448\u0430\u0431\u043b\u043e\u043d \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0435\u0440\u0435\u0433\u0440\u0443\u0437\u0438\u0442\u044c.<\/li>\n<\/ul>\n<p>  \u0415\u0441\u043b\u0438 \u0436\u0435 \u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0430\u0446\u0438\u044e \u0448\u0430\u0431\u043b\u043e\u043d\u0430, \u0442\u043e \u0438\u0437 \u043d\u0435\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 \u0434\u043e\u043a\u043b\u0430\u0434\u0430 \u0443\u0434\u043e\u0431\u043d\u043e \u0434\u0443\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u043a \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u0430 \u043d\u0435 \u043a \u0448\u0430\u0431\u043b\u043e\u043d\u0443, \u0445\u043e\u0442\u044f \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u044d\u0442\u043e \u043d\u0435 \u0442\u0430\u043a. \u0423 \u0441\u0430\u043c\u043e\u0433\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0442\u043e\u0436\u0435 \u0435\u0441\u0442\u044c linkage, \u043d\u043e \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u044d\u0442\u043e \u043f\u043e\u0447\u0442\u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0434\u0430\u043b\u0435\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043f\u0440\u043e linkage \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0430\u0446\u0438\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u0430.<\/p>\n<p>  \u0423 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0435\u0441\u0442\u044c \u043d\u0435\u044f\u0432\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0430\u0446\u0438\u0438. \u041d\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u0449\u0438\u043a \u0441\u0430\u043c \u043f\u043e\u0437\u0430\u0431\u043e\u0442\u0438\u0442\u0441\u044f \u043e \u043d\u0438\u0445 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043c\u043e\u0434\u0443\u043b\u044f\u0445 \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u0438. \u0418\u0445 linkage \u043d\u0435 \u0442\u0430\u043a \u0432\u0430\u0436\u0435\u043d \u0438 \u0434\u0430\u0436\u0435 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u043d\u044f\u0442\u0435\u043d.<\/p>\n<p>  \u041f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443. \u0417\u0430\u0432\u0435\u0434\u0435\u043c \u0442\u0440\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435:<\/p>\n<pre><code class=\"cpp\">template&lt;class T&gt; bool b = true; template&lt;class T&gt; const bool cb = true; template&lt;class T&gt; inline const bool icb = true;<\/code><\/pre>\n<p>  \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c hpp-\u0444\u0430\u0439\u043b \u0432 \u0434\u0432\u0430 cpp-\u0444\u0430\u0439\u043b\u0430. \u0414\u0430\u043b\u0435\u0435 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0440\u0443\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435: b, cb \u0438 icb. \u0412 \u043a\u0430\u0436\u0434\u043e\u0439 \u0435\u0434\u0438\u043d\u0438\u0446\u0435 \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u0438 \u043c\u044b \u0431\u0435\u0440\u0435\u043c \u0430\u0434\u0440\u0435\u0441 \u0443 \u044d\u0442\u0438\u0445 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0430\u0446\u0438\u0439 \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u043c. \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 clang \u0432\u044b\u0434\u0430\u043b:<\/p>\n<pre><code class=\"cpp\">0x6030c0 0x401ae4 0x401ae5 \/\/ first translation unit 0x6030c0 0x401ae4 0x401ae5 \/\/ second translation unit<\/code><\/pre>\n<p>  \u041c\u044b \u0432\u0438\u0434\u0438\u043c \u043e\u0434\u043d\u0438 \u0438 \u0442\u0435 \u0436\u0435 \u0430\u0434\u0440\u0435\u0441\u0430. \u0417\u043d\u0430\u0447\u0438\u0442, \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u0441 \u043e\u0434\u043d\u0438\u043c\u0438 \u0438 \u0442\u0435\u043c\u0438 \u0436\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438. \u0421\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e gcc \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<pre><code class=\"cpp\">0x6015b0 0x400ef5 0x400ef4 \/\/ first translation unit 0x6015b0 0x400ef6 0x400ef4 \/\/ second translation unit<\/code><\/pre>\n<p>  \u0414\u043b\u044f <i>const bool cb<\/i> \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u0430\u0434\u0440\u0435\u0441\u0430. \u042f \u0434\u0430\u0436\u0435 \u0437\u0430\u0434\u0430\u043b \u0432\u043e\u043f\u0440\u043e\u0441 \u043d\u0430 stackoverflow \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/bu\/sk\/kz\/buskkzqhklnd_wz5rwlrbsmpwgm.png\"><\/p>\n<p>  \u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u044f\u0432\u043d\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0435\u0442, \u043a\u0430\u043a\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 linkage \u0443 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0430\u0446\u0438\u0438 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0442\u043e\u0436\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043d\u0430\u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0443\u0433\u043b\u0443\u0431\u043b\u044f\u0442\u044c\u0441\u044f \u0432 \u044d\u0442\u0438 \u0434\u0435\u0442\u0430\u043b\u0438. \u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043e\u0431\u044a\u0435\u043a\u0442, \u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <i>inline<\/i>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u043f\u043e\u0434\u0432\u0435\u0434\u0435\u0442. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430 <code>std::is_const_v<\/code>, \u043a\u0430\u043a \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b, \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\">template&lt;class T&gt; inline constexpr bool is_const_v = is_const&lt;T&gt;::value;<\/code><\/pre>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <i>inline<\/i> \u0434\u043b\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043d\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430. \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043f\u0440\u043e\u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u0442 \u0442\u0430\u043a\u043e\u0439 <i>inline<\/i>, \u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043f\u043e\u0434\u0441\u043a\u0430\u0436\u0435\u0442, \u0447\u0442\u043e \u043e\u043d \u043b\u0438\u0448\u043d\u0438\u0439. \u0415\u0441\u043b\u0438 \u0432\u044b \u0434\u0435\u043b\u0430\u0435\u0442\u0435 \u044f\u0432\u043d\u0443\u044e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 (\u0430 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0443\u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u043c, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439), \u0442\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435 <i>inline<\/i> \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b, \u0438\u043d\u0430\u0447\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0435\u0434\u0438\u043d\u0438\u0446\u0430\u0445 \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u0438 \u043f\u0440\u0438\u0432\u0435\u043b\u043e \u0431\u044b \u043a \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u043c\u0443 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044e.<\/p>\n<p>  \u041a\u0430\u043a \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u043e\u0441\u044c \u0440\u0430\u043d\u0435\u0435, \u0443 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043d\u0435\u044f\u0432\u043d\u0430\u044f \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0430\u0446\u0438\u044f, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0443\u0433\u043b\u043e\u0432\u044b\u0435 \u0441\u043a\u043e\u0431\u043a\u0438. \u0415\u0441\u0442\u044c \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439, \u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u2014 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u044f\u0432\u043d\u043e\u0439 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0430\u0446\u0438\u0438 (explicit instantiation declaration).<\/p>\n<p>  \u041f\u0443\u0441\u0442\u044c \u0432 <code>header.hpp<\/code> \u0435\u0441\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u043b\u043e\u0436\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"cpp\">template&lt;class T&gt; int complicatedTemplateFunction(const T&amp; x) {     \/\/ Some complicated stuff }<\/code><\/pre>\n<p>  \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c <i>extern template<\/i> \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u0441 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u0442\u0438\u043f\u043e\u043c:<\/p>\n<pre><code class=\"cpp\">extern template int complicatedTemplateFunction(const std::string&amp; x);<\/code><\/pre>\n<p>  \u041a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0441\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u044d\u0442\u043e \u043a\u0430\u043a \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u044f\u0432\u043d\u043e\u0439 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0430\u0446\u0438\u0438. \u0415\u0441\u043b\u0438 \u0432 \u043a\u0430\u043a\u043e\u0439-\u043b\u0438\u0431\u043e \u0435\u0434\u0438\u043d\u0438\u0446\u0435 \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u0438 \u043e\u043d \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u043e\u043d \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u0442 \u043d\u0435\u044f\u0432\u043d\u0443\u044e \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0430\u0446\u0438\u044e, \u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0441\u0442\u0430\u0432\u0438\u0442 \u043f\u043e\u043c\u0435\u0442\u043a\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u0449\u0438\u043a\u0443, \u0447\u0442\u043e\u0431\u044b \u0442\u043e\u0442 \u0438\u0441\u043a\u0430\u043b \u044f\u0432\u043d\u0443\u044e \u0438\u043d\u0441\u0442\u0430\u043d\u0438\u0446\u0438\u0430\u0446\u0438\u044e \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u0435\u0434\u0438\u043d\u0438\u0446\u0430\u0445 \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u0438. \u0410 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435.<\/p>\n<p>  \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u044f\u0432\u043d\u043e\u0439 \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0430\u0446\u0438\u0438, \u043a\u0443\u0434\u0430-\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0435\u0451 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"cpp\">template int complicatedTemplateFunction(const std::string&amp; x);<\/code><\/pre>\n<p>  \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043c\u0435\u0442\u043d\u043e \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0441\u0431\u043e\u0440\u043a\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u0430\u044f \u0448\u0430\u0431\u043b\u043e\u043d\u043d\u0430\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0442\u0438\u043f\u043e\u0432, \u0442\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432 \u044f\u0432\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0430\u0446\u0438\u0438. \u0411\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e\u0442 \u0448\u0430\u0431\u043b\u043e\u043d \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441 \u0442\u0438\u043f\u0430\u043c\u0438, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0443\u0436\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u044f\u0432\u043d\u0443\u044e \u0438\u043d\u0441\u0442\u0430\u043d\u0446\u0438\u0430\u0446\u0438\u044e, \u0442\u043e \u0442\u0435\u043b\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0430 \u0438\u0437 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u043e\u0431\u0449\u0435 \u0443\u0431\u0440\u0430\u0442\u044c.<\/p>\n<h2>\u0414\u043e\u043b\u0433\u0438\u0439 \u043f\u0443\u0442\u044c \u043a const<\/h2>\n<p>  \u041a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u0434\u043e C++17 \u043c\u043e\u0433\u043b\u0438 \u0431\u044b\u0442\u044c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u044b \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u043a\u0443\u0447\u0435\u0439 \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432:<\/p>\n<pre><code class=\"cpp\">#define n 42<\/code><\/pre>\n<p>  \u0422\u0443\u0442 \u0432\u0440\u043e\u0434\u0435 \u0431\u044b \u0443\u0436\u0435 \u0432\u0441\u0435 \u0437\u043d\u0430\u044e\u0442, \u0447\u0442\u043e \u0442\u0430\u043a \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435 \u0441\u0442\u043e\u0438\u0442.<\/p>\n<pre><code class=\"cpp\">const int n = 42;<\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0438\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u043e\u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0435\u0434\u0438\u043d\u0438\u0446\u0435 \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u0438, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0432\u043b\u0438\u044f\u0442\u044c \u043d\u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u0438\u0445 \u0430\u0434\u0440\u0435\u0441\u0430.<\/p>\n<pre><code class=\"cpp\">extern const int n;<\/code><\/pre>\n<p>  \u041d\u0435\u043f\u043b\u043e\u0445\u043e, \u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u044b \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c, \u043f\u0440\u043e\u043f\u0430\u0434\u0430\u0435\u0442, \u0438 \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043a\u0430\u0442\u044c \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0435\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e.<\/p>\n<pre><code class=\"cpp\">inline int n() {     return 42; }<\/code><\/pre>\n<p>  \u0422\u0430\u043a \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u043d\u043e, \u043d\u043e \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0432\u0437\u044f\u0442\u044c \u0430\u0434\u0440\u0435\u0441, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f <code>rvalue<\/code>. \u0414\u0430 \u0438 \u0435\u0449\u0451 \u0441\u043a\u043e\u0431\u043a\u0438 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438.<\/p>\n<pre><code class=\"cpp\">enum {      n = 42 };<\/code><\/pre>\n<p>  \u0412\u0435\u0441\u044c\u043c\u0430 \u043d\u0435\u043f\u043b\u043e\u0445\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434, \u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432.<\/p>\n<p>  \u041d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 C++17 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c inline, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u0442\u0438\u043f\u0430. \u0412 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\">inline constexpr int n1 = 1; \/\/ Default choice inline const std::string s2 = &quot;2&quot;; \/\/ If not a literal type<\/code><\/pre>\n<p>  \u041d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0432\u0442\u043e\u0440\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f, \u043d\u043e \u0432 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0432\u0441\u0435 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e \u0438 \u043f\u0440\u0438 <code>constexpr<\/code>.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043c\u044b \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443 \u0432 cpp-\u0444\u0430\u0439\u043b\u0435, \u0442\u043e \u043e\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0435\u0434\u0438\u043d\u0438\u0446\u0435 \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u0438:<\/p>\n<pre><code class=\"cpp\">constexpr int n3 = 3; \/\/ Default choice; implicitly static const std::string s4 = &quot;4&quot;; \/\/ If not a literal type; implicitly static<\/code><\/pre>\n<p>  \u0423\u0431\u0438\u0440\u0430\u0435\u043c <i>inline<\/i>, \u0438\u043d\u0430\u0447\u0435 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u043c\u043e\u0436\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0435\u0434\u0438\u043d\u0438\u0446\u0435\u0439 \u0442\u0440\u0430\u043d\u0441\u043b\u044f\u0446\u0438\u0438. \u041a\u0441\u0442\u0430\u0442\u0438, \u0432 module interface unit \u0432 C++20 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u0442 \u0436\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430 \u2014 \u0447\u043b\u0435\u043d \u043a\u043b\u0430\u0441\u0441\u0430, \u0442\u043e \u043e\u043d\u0430 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u043a <i>static<\/i>:<\/p>\n<pre><code class=\"cpp\">struct A {     static constexpr int n = 5; \/\/ Default choice; implicitly inline     static inline const std::string s = &quot;6&quot;; \/\/ If not a literal type };<\/code><\/pre>\n<p>  \u0415\u0441\u043b\u0438 \u043a \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0435 \u043d\u0435\u043b\u044c\u0437\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c constexpr, \u0442\u043e \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c <i>inline<\/i>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0434\u043b\u044f \u043f\u043e\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0430 \u0435\u0433\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043d\u0435 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u0442, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u0439. <\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0436\u0435 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430 \u2014 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u0430\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f, \u0442\u043e \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439, \u043d\u043e \u0441\u043e <i>static<\/i>:<\/p>\n<pre><code class=\"cpp\">void f() {     static constexpr int n = 7; \/\/ Default choice     static const std::string s = &quot;8&quot;; \/\/ If not a literal type }<\/code><\/pre>\n<p>  \u0426\u0435\u043b\u044b\u0445 8 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432. \u041d\u043e \u0432\u0441\u0435 \u043d\u0435 \u0442\u0430\u043a \u0441\u043b\u043e\u0436\u043d\u043e, \u043a\u0430\u043a \u043a\u0430\u0436\u0435\u0442\u0441\u044f. \u0410\u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u044f \u043c\u0435\u0436\u0434\u0443 <code>constexpr<\/code> \u0438 <code>const<\/code> \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u043a\u043e\u0433\u0434\u0430 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430 \u2014 \u0447\u043b\u0435\u043d \u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<p>  \u041a\u043e\u0433\u0434\u0430 \u0432 \u0441\u0432\u0435\u0442\u043b\u043e\u043c \u0431\u0443\u0434\u0443\u0449\u0435\u043c, \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043e\u0441\u0442\u0430\u043d\u0443\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u0434\u0443\u043b\u0438 \u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432, \u043e\u0441\u0442\u0430\u043d\u0443\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u0438 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b:<\/p>\n<pre><code class=\"cpp\">\/\/ module.ixx constexpr int n3 = 3;  \/\/ Anywhere struct A {     static constexpr int n = 5; };  void f() {     static constexpr int n = 7; }<\/code><\/pre>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0443\u0442\u0430\u0442\u044c\u0441\u044f \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c, \u043e\u0431\u0440\u0430\u0442\u0438\u043c\u0441\u044f \u043a \u0431\u043b\u043e\u043a-\u0441\u0445\u0435\u043c\u0435, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a \u043e\u0431\u044a\u044f\u0432\u0438\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0443 \u0441 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u043c:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/l-\/jv\/fn\/l-jvfnyp1pytuwoegjmjmcqrfso.png\"><\/p>\n<p>  \u041e\u043d\u0430 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0440\u043e\u0432\u043d\u043e \u0442\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b, \u0447\u0442\u043e \u043c\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438 \u0432\u044b\u0448\u0435.<\/p>\n<h2>\u0417\u0430\u0433\u0430\u0434\u043e\u0447\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0438\u0437 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f<\/h2>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0434\u043e\u043a\u043b\u0430\u0434\u0430:<\/p>\n<pre><code class=\"cpp\">template&lt;class T&gt; static inline thread_local constexpr const volatile T x = {};<\/code><\/pre>\n<p>  \u041f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0435\u0433\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c:<\/p>\n<ol>\n<li><code>const<\/code> \u043d\u0435 \u043d\u0443\u0436\u0435\u043d, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0443\u0436\u0435 \u0435\u0441\u0442\u044c <code>constexpr<\/code>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0443\u0431\u0438\u0440\u0430\u0435\u043c.<\/li>\n<li>\u041c\u044b \u0437\u043d\u0430\u0435\u043c \u043f\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u0447\u0442\u043e <code>static<\/code> \u043f\u0435\u0440\u0435\u0431\u0438\u0432\u0430\u0435\u0442 <code>inline<\/code>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u0436\u0435\u043c \u0441\u043c\u0435\u043b\u043e \u0443\u0431\u0438\u0440\u0430\u0442\u044c <code>inline<\/code>.<\/li>\n<\/ol>\n<p>  \u0412 \u0438\u0442\u043e\u0433\u0435 \u0443 \u043d\u0430\u0441 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f:<\/p>\n<pre><code class=\"cpp\">template&lt;class T&gt; static thread_local constexpr volatile T x = {};<\/code><\/pre>\n<p>  <code>static<\/code> \u0434\u043b\u044f \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0434\u0430\u0451\u0442 internal linkage. <code>thread_local<\/code> \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 thread storage duration. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 x \u2014 \u044d\u0442\u043e constexpr volatile \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0441 thread storage duration \u0438 internal linkage (constexpr volatile variable template with thread storage duration and internal linkage).<\/p>\n<h2>\u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432 C++20<\/h2>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/6f\/ou\/cv\/6foucvpa7qy1mk4sh5iecn_ktne.png\"><\/p>\n<p>  \u0412 C++ 20 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0432\u0438\u0434 linkage \u2014 module linkage. external linkage \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f module linkage, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044d\u0442\u043e linkage \u0432\u043d\u0443\u0442\u0440\u0438 \u043c\u043e\u0434\u0443\u043b\u044f, \u0430 \u0432\u0441\u0435, \u0447\u0442\u043e \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b \u043c\u043e\u0434\u0443\u043b\u044f, \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f external linkage.<\/p>\n<p>  \u0412 C++20 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0434\u043b\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>consteval<\/code>. \u042d\u0442\u043e \u043a\u0430\u043a constexpr, \u043d\u043e \u0435\u0441\u043b\u0438 constexpr \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043a\u0430\u043a \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0442\u0430\u043a \u0438 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0442\u043e consteval \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438.<\/p>\n<p>  \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043c\u043e\u0436\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e consteval \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u043e\u0432\u043a\u0438 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u043d\u0435 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0432\u043e\u0435\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c \u043c\u0430\u043a\u0440\u043e\u0441\u043e\u043c. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0435 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435\u0442 \u0442\u0430\u043a\u0438\u0445 \u043f\u043e\u043d\u044f\u0442\u0438\u0439, \u043a\u0430\u043a \u201c\u0432\u0440\u0435\u043c\u044f \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438\u201d \u0438 \u201c\u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f\u201d. \u0415\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u201c\u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c\u044b\u0439 \u044d\u0444\u0444\u0435\u043a\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b\u201d. \u041e\u0434\u043d\u0430\u043a\u043e \u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u043a\u0430 consteval \u0434\u0430\u043d\u0430 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u044b \u0438\u043c\u0435\u043b\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435.<\/p>\n<p>  \u0414\u043b\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0432 C++ \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 <code>constinit<\/code>. \u0415\u0441\u043b\u0438 <code>constinit<\/code> \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0447\u0435\u043c-\u0442\u043e, \u0447\u0442\u043e \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0442\u043e \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u0432\u044b\u0434\u0430\u0441\u0442 \u043e\u0448\u0438\u0431\u043a\u0443. \u0417\u0430\u0431\u0430\u0432\u043d\u043e, \u0447\u0442\u043e <code>constinit<\/code> \u043d\u0435 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>const<\/code>. \u041e\u043d \u0437\u043d\u0430\u0447\u0438\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0442\u043e, \u0447\u0442\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438, \u0430 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c.<\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c consteval \u0438 constinit \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/yb\/h7\/iy\/ybh7iyfi4i2datindbqagdmv-cm.png\"><\/p>\n<h2>\u041a\u0430\u043a \u0436\u0438\u0442\u044c \u0441 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u043c\u0438 C++ \u0438 \u043d\u0435 \u0441\u043e\u0439\u0442\u0438 \u0441 \u0443\u043c\u0430<\/h2>\n<p>  <\/p>\n<ul>\n<li>\u041f\u043e\u043c\u0435\u0449\u0430\u0439\u0442\u0435 \u0432\u0441\u0451 \u0432 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0435\u043d, \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e. \u041f\u043e\u0434\u0443\u043c\u0430\u0439\u0442\u0435, \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u043b\u0438 \u0432\u044b \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043e\u0442\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043e\u0442 <i>static<\/i> \u0434\u043b\u044f \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0432 \u043f\u043e\u043b\u044c\u0437\u0443 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u0438\u043c\u0435\u043d.<\/li>\n<li>\u041f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u0439\u0442\u0435 <i>inline<\/i> \u0432\u043c\u0435\u0441\u0442\u043e extern.<\/li>\n<li>\u041f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u0439\u0442\u0435 <i>constexpr<\/i> \u0432\u043c\u0435\u0441\u0442\u043e <i>const<\/i>.<\/li>\n<li>\u0421\u0442\u0430\u0440\u0430\u0439\u0442\u0435\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441\u043e static \u0438 thread storage duration \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442. \u0418\u043d\u0430\u0447\u0435 \u0438\u0437\u043c\u0435\u043d\u0447\u0438\u0432\u043e\u0435 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u043b\u0438\u044f\u0442\u044c \u043d\u0430 \u043d\u0430\u0434\u0451\u0436\u043d\u043e\u0441\u0442\u044c, \u0434\u0438\u0437\u0430\u0439\u043d \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0441\u0442\u044c.<\/li>\n<\/ul>\n<p>  <\/p>\n<blockquote><p>\u0412 \u044d\u0442\u043e\u043c \u0433\u043e\u0434\u0443 \u043d\u0430 \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u0438 <a href=\"http:\/\/cppconf-moscow.ru\/?utm_source=habr&amp;utm_medium=506104\">\u0421++ Russia 2020 Moscow<\/a> \u0432\u044b\u0441\u0442\u0443\u043f\u044f\u0442 \u0441\u0430\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u0435\u043b\u044c \u044f\u0437\u044b\u043a\u0430 \u0421++ \u0411\u044c\u044f\u0440\u043d\u0435 \u0421\u0442\u0440\u0430\u0443\u0441\u0442\u0440\u0443\u043f \u0438 \u043f\u0440\u0435\u0434\u0441\u0435\u0434\u0430\u0442\u0435\u043b\u044c \u043a\u043e\u043c\u0438\u0442\u0435\u0442\u0430 \u043f\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0421++ \u0413\u0435\u0440\u0431 \u0421\u0430\u0442\u0442\u0435\u0440! \u0415\u0449\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u0437\u043d\u0430\u043c\u0435\u043d\u0438\u0442\u044b\u0445 \u0441\u043f\u0438\u043a\u0435\u0440\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u043f\u043e <a href=\"http:\/\/live.jugru.org\/?utm_source=habr&amp;utm_medium=506104#rec181625429\">\u0431\u0438\u043b\u0435\u0442\u0443-\u0430\u0431\u043e\u043d\u0435\u043c\u0435\u043d\u0442\u0443<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0434\u0430\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u043a\u043e \u0432\u0441\u0435\u043c 8 \u043a\u043e\u043d\u0444\u0435\u0440\u0435\u043d\u0446\u0438\u044f\u043c \u043b\u0435\u0442\u043d\u0435\u0433\u043e \u0441\u0435\u0437\u043e\u043d\u0430.<\/p><\/blockquote>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/jugru\/blog\/506104\/\"> https:\/\/habr.com\/ru\/company\/jugru\/blog\/506104\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/jugru\/blog\/506104\/\">\n<pre><code class=\"cpp\">template&lt;class T&gt; static inline thread_local constexpr const volatile T x = {};<\/code><\/pre>\n<p>  \u0422\u0430\u043a\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0441\u043b\u043e\u0432 \u0432\u0432\u0435\u0434\u0435\u0442 \u0432 \u0441\u0442\u0443\u043f\u043e\u0440 \u043b\u044e\u0431\u043e\u0433\u043e \u043d\u0435\u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430. \u041d\u043e \u043d\u0430 C++ Russia 2019 Piter \u041c\u0438\u0445\u0430\u0438\u043b \u041c\u0430\u0442\u0440\u043e\u0441\u043e\u0432 (<a href=\"https:\/\/habr.com\/ru\/users\/mmatrosov\/\" class=\"user_link\">mmatrosov<\/a>) \u0440\u0430\u0437\u043b\u043e\u0436\u0438\u043b \u043f\u043e \u043f\u043e\u043b\u043e\u0447\u043a\u0430\u043c \u043a\u0432\u0430\u043b\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u0438 \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u044b \u043f\u0440\u0438 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439. <\/p>\n<p>  \u041c\u044b \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b\u0438 \u0434\u043b\u044f \u0432\u0430\u0441 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0434\u043e\u043a\u043b\u0430\u0434\u0430, \u0447\u0442\u043e\u0431\u044b \u0432\u044b \u043c\u043e\u0433\u043b\u0438 \u0432 \u043b\u044e\u0431\u043e\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u0438 \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u0448\u043f\u0430\u0440\u0433\u0430\u043b\u043a\u0438 \u041c\u0438\u0445\u0430\u0438\u043b\u0430.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-305142","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/305142","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=305142"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/305142\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=305142"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=305142"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=305142"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}