<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>Takachan</author_name>
  <author_url>https://blog.hatena.ne.jp/Takachan/</author_url>
  <blog_title>PG日誌</blog_title>
  <blog_url>https://takap-tech.com/</blog_url>
  <categories>
    <anon>C++</anon>
    <anon>C++11以上</anon>
    <anon>C+/CLI</anon>
  </categories>
  <description>const 参照と shared_ptr のダウンキャスト方法です。 先に方法を書いておきますが以下の通りです。 // const参照のダウンキャスト auto&amp;/*const Type&amp;*/ sub = static_cast&lt;const Type&amp;&gt;(obj); // shared_ptrのダウンキャスト std::shared_ptr&lt;Type&gt; sub = std::dynamic_pointer_cast&lt;Type&gt;(ptr); 説明 以下のように Base を継承した Derived クラス定義があったとします。 class Base { public: int a = 0; vi…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Ftakap-tech.com%2Fentry%2F2021%2F07%2F07%2F222745&quot; title=&quot;【C++】const参照とshared_ptrをダウンキャストする - PG日誌&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>2021-07-07 22:27:45</published>
  <title>【C++】const参照とshared_ptrをダウンキャストする</title>
  <type>rich</type>
  <url>https://takap-tech.com/entry/2021/07/07/222745</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
