{"id":108118,"date":"2023-05-01T07:00:00","date_gmt":"2023-05-01T14:00:00","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/oldnewthing\/?p=108118"},"modified":"2023-04-30T07:31:44","modified_gmt":"2023-04-30T14:31:44","slug":"20230501-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20230501-00\/?p=108118","title":{"rendered":"A quick note about WRL&#8217;s <CODE>Chain&shy;Interfaces<\/CODE> template class"},"content":{"rendered":"<p>The <a href=\"https:\/\/learn.microsoft.com\/cpp\/cppcx\/wrl\/windows-runtime-cpp-template-library-wrl\"> Windows Runtime C++ Template Library<\/a> (commonly known as WRL) contains a template class called <code>Chain\u00adInterfaces<\/code>. The documentation for <code>Chain\u00adInterfaces<\/code> talks about what it does but doesn&#8217;t tell you <i>why it&#8217;s there<\/i> or when you should use it.<\/p>\n<p>The purpose of <code>Chain\u00adInterfaces<\/code> is to be included among the template arguments to the WRL <code>Runtime\u00adClass<\/code> and <code>Implements<\/code> template classes to indicate that you have a sequence (&#8220;chain&#8221;) of interfaces where each one extends the previous one.<\/p>\n<p>For example, the <code>IFileSystemBindData2<\/code> interface extends the <code>IFileSystemBindData<\/code> interface. If you want to use WRL to implement an object that implements both interfaces, you would write<\/p>\n<pre>namespace wrl = Microsoft::WRL;\r\n\r\nstruct MyFileSystemBindData :\r\n    wrl::RuntimeClass&lt;\r\n        wrl::RuntimeClassFlags&lt;wrl::ClassicCom&gt;,\r\n        wrl::ChainInterfaces&lt;IFileSystemBindData2, IFileSystemBindData&gt;\r\n    &gt;\r\n{\r\n    \u27e6 implementation elided for expository purposes \u27e7\r\n}\r\n<\/pre>\n<p>Note that you list the <code>Chain\u00adInterfaces<\/code> template parameters from <i>most derived to least derived<\/i>. Fortunately, if you get the order wrong, you get a compile-time error.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For interfaces which extend each other.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-108118","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>For interfaces which extend each other.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/108118","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=108118"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/108118\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=108118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=108118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=108118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}