<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[template methode mit typename?]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>ich habe eine utility class mit statischen Methoden,<br />
bei denen eine Methode wie folgt aussieht:</p>
<pre><code>class UtilCellUserPointer
{
    template &lt;int dim&gt;
    static element::Element&lt;dim&gt;  &amp; getRefToCellElement(const typename dealii::DoFHandler&lt;dim&gt;::active_cell_iterator  &amp; cell);

}
</code></pre>
<p>Sie wird an anderer Stelle wie folgt aufgerufen:</p>
<pre><code>const Material&lt;dim&gt; cellMaterial = UtilCellUserPointer::getRefToCellElement(cell).getMaterial();
</code></pre>
<p>Dabei wird vom Compiler folgende Fehlermeldung ausgegeben:</p>
<blockquote>
<p>source/internal/solver_unit.cpp(980): error: no instance of function template &quot;ares::utilities::UtilCellUserPointer::getRefToCellElement&quot; matches the argument list<br />
argument types are: (const dealii::TriaActiveIterator&lt;dealii::DoFCellAccessor&lt;dealii::DoFHandler&lt;2, 2&gt;&gt;&gt;)<br />
const Material&lt;dim&gt; cellMaterial = UtilCellUserPointer::getRefToCellElement(cell).getMaterial(); // get the material of the cell<br />
^<br />
detected during instantiation of &quot;dealii::FullMatrix&lt;double&gt; ares::internal::SolverUnit&lt;dim&gt;::computeCellMatrix(const dealii::DoFHandler&lt;dim, dim&gt;::active_cell_iterator &amp;, const dealii::FEValues&lt;dim, dim&gt; &amp;) const [with dim=2]&quot; at line 720</p>
</blockquote>
<p>Ich vermute, dass das irgendwas mit dem typename zu tun hat, denn die anderen Funktionen funzen alle, weiss es aber nicht genau...</p>
<p>Ich bin für jede neue Idee dankbar...</p>
<p>Rahul</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/280236/template-methode-mit-typename</link><generator>RSS for Node</generator><lastBuildDate>Mon, 24 Aug 2026 05:06:22 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/280236.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 11 Jan 2011 22:45:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to template methode mit typename? on Tue, 11 Jan 2011 22:45:43 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>ich habe eine utility class mit statischen Methoden,<br />
bei denen eine Methode wie folgt aussieht:</p>
<pre><code>class UtilCellUserPointer
{
    template &lt;int dim&gt;
    static element::Element&lt;dim&gt;  &amp; getRefToCellElement(const typename dealii::DoFHandler&lt;dim&gt;::active_cell_iterator  &amp; cell);

}
</code></pre>
<p>Sie wird an anderer Stelle wie folgt aufgerufen:</p>
<pre><code>const Material&lt;dim&gt; cellMaterial = UtilCellUserPointer::getRefToCellElement(cell).getMaterial();
</code></pre>
<p>Dabei wird vom Compiler folgende Fehlermeldung ausgegeben:</p>
<blockquote>
<p>source/internal/solver_unit.cpp(980): error: no instance of function template &quot;ares::utilities::UtilCellUserPointer::getRefToCellElement&quot; matches the argument list<br />
argument types are: (const dealii::TriaActiveIterator&lt;dealii::DoFCellAccessor&lt;dealii::DoFHandler&lt;2, 2&gt;&gt;&gt;)<br />
const Material&lt;dim&gt; cellMaterial = UtilCellUserPointer::getRefToCellElement(cell).getMaterial(); // get the material of the cell<br />
^<br />
detected during instantiation of &quot;dealii::FullMatrix&lt;double&gt; ares::internal::SolverUnit&lt;dim&gt;::computeCellMatrix(const dealii::DoFHandler&lt;dim, dim&gt;::active_cell_iterator &amp;, const dealii::FEValues&lt;dim, dim&gt; &amp;) const [with dim=2]&quot; at line 720</p>
</blockquote>
<p>Ich vermute, dass das irgendwas mit dem typename zu tun hat, denn die anderen Funktionen funzen alle, weiss es aber nicht genau...</p>
<p>Ich bin für jede neue Idee dankbar...</p>
<p>Rahul</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2005480</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2005480</guid><dc:creator><![CDATA[Rahul0891]]></dc:creator><pubDate>Tue, 11 Jan 2011 22:45:43 GMT</pubDate></item><item><title><![CDATA[Reply to template methode mit typename? on Tue, 11 Jan 2011 23:05:33 GMT]]></title><description><![CDATA[<p>Rahul0891 schrieb:</p>
<blockquote>
<pre><code>template &lt;int dim&gt;
Element&lt;dim&gt; &amp; getRefToCellElement(const typename DoFHandler&lt;dim&gt;::active_cell_iterator &amp; cell);
</code></pre>
<p>Sie wird an anderer Stelle wie folgt aufgerufen:</p>
<pre><code>getRefToCellElement(cell)
</code></pre>
</blockquote>
<p>&quot;typename DoFHandler&lt;dim&gt;::active_cell_iterator&quot; ist ein sogenannter &quot;non-deducible context&quot; bzgl des Template-Parameters &quot;dim&quot;. Und weil das der einzige Kontext ist, bei dem &quot;dim&quot; auftaucht, kann &quot;dim&quot; nicht automatisch bestimmt werden. Du musst entweder den Parameter explizit beim Aufruf angeben, oder Dein Funktionstemplate umschreiben, zB so:</p>
<pre><code class="language-cpp">template&lt;class Iter&gt;
Element&lt;...&gt;&amp; getRefToCellElement(Iter cell);
</code></pre>
<p>Leider fehlen Informationen über dein restliches Programm, dass ich für &quot;...&quot; hier nichts einsetzen kann. Du kannst Dich aber mal mit std::iterator_traits vertraut machen und/oder eine eigene &quot;Metafunktion&quot; schreiben, die Dir die richtige Dimension zurückgibt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2005484</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2005484</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Tue, 11 Jan 2011 23:05:33 GMT</pubDate></item><item><title><![CDATA[Reply to template methode mit typename? on Tue, 11 Jan 2011 23:54:22 GMT]]></title><description><![CDATA[<p>Ah, jetzt hats *ding* gemacht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>Ansonsten, wenn die Funktion selbst nicht umgeschrieben werden kann/soll, kann man den Aufruf umschreiben:<br />
(wobei das natürlich die weniger schöne Lösung ist)</p>
<pre><code class="language-cpp">// const Material&lt;dim&gt; cellMaterial = UtilCellUserPointer::getRefToCellElement(cell).getMaterial();
// -&gt;
const Material&lt;dim&gt; cellMaterial = UtilCellUserPointer::getRefToCellElement&lt;dim&gt;(cell).getMaterial();
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2005491</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2005491</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Tue, 11 Jan 2011 23:54:22 GMT</pubDate></item><item><title><![CDATA[Reply to template methode mit typename? on Wed, 12 Jan 2011 17:03:17 GMT]]></title><description><![CDATA[<p>Super, danke für die Antworten...</p>
<p>Nach ein wenig Recherche war ich auch in der Lage,<br />
aus dem Iterator, der mir von einer Library so vorgegeben war,<br />
die Information über dim auf einfache Weise zu extrahieren...</p>
<p>So sieht es dann aus:</p>
<pre><code>class UtilCellUserPointer
{
    template &lt;typename IteratorType&gt;
    static element::Element&lt;IteratorType::AccessorType::dim&gt;  &amp; getRefToCellElement(const IteratorType  &amp; cell);
}
</code></pre>
<p>Alles Gute und nochmals danke<br />
Rahul</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2005810</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2005810</guid><dc:creator><![CDATA[Rahul0891]]></dc:creator><pubDate>Wed, 12 Jan 2011 17:03:17 GMT</pubDate></item></channel></rss>