Note that there are some explanatory texts on larger screens.

plurals
  1. POC++11 Check COM smart pointer for members
    primarykey
    data
    text
    <p>I have a bunch of collection-like COM interfaces that I'm trying to write an STL-like iterator for. I've got the iterator working and specialized <code>begin()</code> and <code>end()</code> to return my iterator. Everything works perfectly! Except, when I try to use <code>begin(std::vector)</code>, it's using my very general specialization of <code>begin()</code>. Since these COM objects don't extend from a base collection object, I first tried:</p> <pre><code>template&lt; class CollType &gt; CollectionIterator&lt;CollType&gt; begin( CollType coll ) </code></pre> <p>I see why the overload resolution isn't picking the right <code>begin()</code> for <code>std::vector</code>, but I'm not sure how to fix this.</p> <p>Unfortunately, I don't have a base collection class to specialize the <code>coll</code> parameter against. I'm assuming I need something like SFINAE to only resolve these specializations if the right members exist. I tried:</p> <pre><code>template&lt; class CollType, typename std::enable_if&lt; std::is_member_pointer&lt; decltype(&amp;CollType::GetItem) &gt;::value &gt;::type &gt; CollectionIterator&lt;CollType&gt; begin( CollType coll ) </code></pre> <p><em>(where <code>GetItem</code> is a method of <code>CollType</code>)</em></p> <p>As well as a handful of variations, to no avail. To make matters worse, these collections are COM smart pointers, so I'm not sure if <code>GetItem</code> will actually register as a member of the smart pointer.</p> <p>Any insights into the right direction would be great, I've been mostly running in circles with this.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload