<?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 parameter-übergabe]]></title><description><![CDATA[<p>wenn ich sowas habe :</p>
<pre><code class="language-cpp">template &lt;class T&gt;
class BeispielContainer
{

void addItem(const t&amp; item) // per reference to const
{
m_cont.add(item);
}

};
</code></pre>
<p>dann stehe ich irgendwie vor dem dilemma, das es bei integralen typen langsamer<br />
werden kann, weil man die nicht als reference übergeben sollte,<br />
aber ich grosse Objekte auch nicht per-value übergeben kann // möchte</p>
<p>gibts dafür eine eine Lösung?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/205281/template-parameter-übergabe</link><generator>RSS for Node</generator><lastBuildDate>Thu, 08 Oct 2026 22:13:48 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/205281.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 12 Feb 2008 15:07:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to template parameter-übergabe on Tue, 12 Feb 2008 15:07:04 GMT]]></title><description><![CDATA[<p>wenn ich sowas habe :</p>
<pre><code class="language-cpp">template &lt;class T&gt;
class BeispielContainer
{

void addItem(const t&amp; item) // per reference to const
{
m_cont.add(item);
}

};
</code></pre>
<p>dann stehe ich irgendwie vor dem dilemma, das es bei integralen typen langsamer<br />
werden kann, weil man die nicht als reference übergeben sollte,<br />
aber ich grosse Objekte auch nicht per-value übergeben kann // möchte</p>
<p>gibts dafür eine eine Lösung?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1454496</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1454496</guid><dc:creator><![CDATA[Treb]]></dc:creator><pubDate>Tue, 12 Feb 2008 15:07:04 GMT</pubDate></item><item><title><![CDATA[Reply to template parameter-übergabe on Tue, 12 Feb 2008 15:09:15 GMT]]></title><description><![CDATA[<p>Spielt Dir das wirklich eine Rolle wegen der Performance?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1454497</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1454497</guid><dc:creator><![CDATA[simon.gysi]]></dc:creator><pubDate>Tue, 12 Feb 2008 15:09:15 GMT</pubDate></item><item><title><![CDATA[Reply to template parameter-übergabe on Tue, 12 Feb 2008 15:16:28 GMT]]></title><description><![CDATA[<p>obwohl es schon eine rolle spielt,<br />
ist es wohl eher interesse-halber</p>
<p>darf zB der Compiler sowas nach &quot;per-value&quot; optimieren,<br />
so weit ich das überblicke gibt es keine semantischen<br />
unterschiede zwischen &quot;per-value&quot; und &quot;per reference to const&quot;<br />
(jedenfalls bei der parameter-übergabe)</p>
<p>oder mir fehlt da der weitblick</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1454501</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1454501</guid><dc:creator><![CDATA[Treb]]></dc:creator><pubDate>Tue, 12 Feb 2008 15:16:28 GMT</pubDate></item><item><title><![CDATA[Reply to template parameter-übergabe on Tue, 12 Feb 2008 15:18:09 GMT]]></title><description><![CDATA[<p>const_cast?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1454503</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1454503</guid><dc:creator><![CDATA[Fellhuhn]]></dc:creator><pubDate>Tue, 12 Feb 2008 15:18:09 GMT</pubDate></item><item><title><![CDATA[Reply to template parameter-übergabe on Tue, 12 Feb 2008 15:24:40 GMT]]></title><description><![CDATA[<p>verwende type_traits und partielle spezialisierung oder SFINAE.</p>
<pre><code class="language-cpp">//SFINAE mit boost
#include &lt;boost/utility/enable_if.hpp&gt;
#include &lt;boost/type_traits/is_fundamental.hpp&gt;

template &lt;class T&gt;
void do_sth (T t , typename boost::enable_if&lt;boost::is_fundamental&lt;T&gt; &gt;::type* = 0)
{
}

template &lt;class T&gt;
void do_sth (T const &amp;t, typename boost::disable_if&lt;boost::is_fundamental&lt;T&gt; &gt;::type* = 0)
{
}

//partielle spezialisierung mit TR1
#include &lt;tr1/type_traits&gt;

template &lt;class T, bool fund = std::tr1::is_fundamental&lt;T&gt;::value&gt;
struct Foo;

template &lt;class T&gt;
struct Foo&lt;T, true&gt;
{
void out (T t);
};

template &lt;class T&gt;
struct Foo&lt;T, false&gt;
{
void out (T const&amp; t);
};
</code></pre>
<p>/edit: es gibt noch eine möglichkeit, aber das überlasse ich jemand anderem.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1454506</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1454506</guid><dc:creator><![CDATA[queer_boy]]></dc:creator><pubDate>Tue, 12 Feb 2008 15:24:40 GMT</pubDate></item><item><title><![CDATA[Reply to template parameter-übergabe on Tue, 12 Feb 2008 18:54:44 GMT]]></title><description><![CDATA[<p>Der Compiler darf Optimieren was er möchte.<br />
Das Programm muss nur das erwartete Verhalten zeigen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1454646</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1454646</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Tue, 12 Feb 2008 18:54:44 GMT</pubDate></item></channel></rss>