<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>osyo-manga</author_name>
  <author_url>https://blog.hatena.ne.jp/osyo-manga/</author_url>
  <blog_title>C++でゲームプログラミング</blog_title>
  <blog_url>https://osyo-manga.hatenadiary.org/</blog_url>
  <categories>
    <anon>C++</anon>
  </categories>
  <description>Lingr の C++ 部屋で話題になったのですが、参照キャプチャしたラムダを static 変数で保持するのは未定義の動作になることがあるので注意しましょうという話。さて、話題になっていたのは次のようなコードです。 void func(int const&amp; i){ static auto f = [&amp;]{ std::cout &lt;&lt; i &lt;&lt; std::endl; }; f(); } func(1); // =&gt; 1 func(2); // =&gt; 1 呼び出した f() は両方共 1 が出力されます。 ここで引数を int に変えてみるとどうでしょう。 // 引数を int に変更 void …</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fosyo-manga.hatenadiary.org%2Fentry%2F20140628%2F1403964112&quot; title=&quot;ラムダオブジェクトを static 変数で保持する時の注意 - C++でゲームプログラミング&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2014-06-28 23:01:52</published>
  <title>ラムダオブジェクトを static 変数で保持する時の注意</title>
  <type>rich</type>
  <url>https://osyo-manga.hatenadiary.org/entry/20140628/1403964112</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
