<?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[mehrdeutige konstruktoren]]></title><description><![CDATA[<p>hallo</p>
<p>ich hab ein kleines problem bei meinem code. ich habe eine klasse geschrieben, die man - ähnlich wie die stl container - mit range+fill oder mit 2 iteratoren initialisieren kann:</p>
<pre><code>explicit myclass(SizeType Size, ConstReferenceType Default = ValueType())
		{
		}
		template&lt;class InputIteratorType&gt;
        myclass(InputIteratorType First, InputIteratorType Last)
		{
		}
</code></pre>
<p>mein problem zeigt sich wenn ich folgendes mache:</p>
<pre><code>myclass&lt;int&gt; foo(5, 4); //hier wird der iterator-konstruktor aufgerufen, wtf?
</code></pre>
<p>ideen zur behebung des problems?</p>
<p>mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/321159/mehrdeutige-konstruktoren</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Jul 2026 01:25:42 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/321159.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 26 Oct 2013 01:13:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to mehrdeutige konstruktoren on Sat, 26 Oct 2013 01:13:12 GMT]]></title><description><![CDATA[<p>hallo</p>
<p>ich hab ein kleines problem bei meinem code. ich habe eine klasse geschrieben, die man - ähnlich wie die stl container - mit range+fill oder mit 2 iteratoren initialisieren kann:</p>
<pre><code>explicit myclass(SizeType Size, ConstReferenceType Default = ValueType())
		{
		}
		template&lt;class InputIteratorType&gt;
        myclass(InputIteratorType First, InputIteratorType Last)
		{
		}
</code></pre>
<p>mein problem zeigt sich wenn ich folgendes mache:</p>
<pre><code>myclass&lt;int&gt; foo(5, 4); //hier wird der iterator-konstruktor aufgerufen, wtf?
</code></pre>
<p>ideen zur behebung des problems?</p>
<p>mfg</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2363009</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2363009</guid><dc:creator><![CDATA[sagfsgsaga]]></dc:creator><pubDate>Sat, 26 Oct 2013 01:13:12 GMT</pubDate></item><item><title><![CDATA[Reply to mehrdeutige konstruktoren on Sat, 26 Oct 2013 06:11:28 GMT]]></title><description><![CDATA[<p>Caste 5 mal nach SizeType, der Templatekonstruktorvist offenbar bess weil keine Konvertierung notwendig.<br />
Notfalls enable_if.</p>
<p>Edit: template &lt;typename Iter, typename = typename std::iterator_trairs&lt;Iter&gt;::value_type&gt; reicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2363012</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2363012</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Sat, 26 Oct 2013 06:11:28 GMT</pubDate></item><item><title><![CDATA[Reply to mehrdeutige konstruktoren on Sat, 26 Oct 2013 09:43:15 GMT]]></title><description><![CDATA[<p>Nathan schrieb:</p>
<blockquote>
<p>Edit: template &lt;typename Iter, typename = typename std::iterator_trairs&lt;Iter&gt;::value_type&gt; reicht.</p>
</blockquote>
<p>geht nicht, funktionstemplates und standard-templateargumente und so <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2363036</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2363036</guid><dc:creator><![CDATA[sagfsgsaga]]></dc:creator><pubDate>Sat, 26 Oct 2013 09:43:15 GMT</pubDate></item><item><title><![CDATA[Reply to mehrdeutige konstruktoren on Sat, 26 Oct 2013 10:58:32 GMT]]></title><description><![CDATA[<p>Ging das nicht in C++11?</p>
<p>Trotzdem, man kann den Konstruktor immernoch in ein traditionelles</p>
<pre><code>template&lt;class InputIterator&gt;
        myclass(InputIterator First, InputIterator Last,
         typename std::iterator_traits&lt;InputIterator&gt;::value_type* = 0)
        {
        }
</code></pre>
<p>ändern. Das sollte eigentlich funktionieren, wenn auch ungetestet.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2363058</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2363058</guid><dc:creator><![CDATA[Flashyput]]></dc:creator><pubDate>Sat, 26 Oct 2013 10:58:32 GMT</pubDate></item><item><title><![CDATA[Reply to mehrdeutige konstruktoren on Sat, 26 Oct 2013 11:03:10 GMT]]></title><description><![CDATA[<p>Standard-Techniken:<br />
- Selektion per enable_if<br />
1. mit Default-Templateargument, oder<br />
2. per Default-Konstruktorargument<br />
- tag dispatching</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2363059</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2363059</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Sat, 26 Oct 2013 11:03:10 GMT</pubDate></item><item><title><![CDATA[Reply to mehrdeutige konstruktoren on Sat, 26 Oct 2013 11:52:21 GMT]]></title><description><![CDATA[<blockquote>
<p>funktionstemplates und standard-templateargumente und so</p>
</blockquote>
<p>Das ist völlig in Ordnung. (Edit) Also seit C++11, das habe ich aber vorausgesetzt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2363069</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2363069</guid><dc:creator><![CDATA[Columbo]]></dc:creator><pubDate>Sat, 26 Oct 2013 11:52:21 GMT</pubDate></item><item><title><![CDATA[Reply to mehrdeutige konstruktoren on Sat, 26 Oct 2013 13:10:38 GMT]]></title><description><![CDATA[<p>ja habe keinen c++11 support, hätte ich vll dazu sagen sollen, sorry.</p>
<p>daher bleibt mir nur das mit dem default-funktionsargument übrig. bringt hoffentlich keinen runtime-overhead mit sich...</p>
<p>gruss</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2363073</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2363073</guid><dc:creator><![CDATA[sagfsgsaga]]></dc:creator><pubDate>Sat, 26 Oct 2013 13:10:38 GMT</pubDate></item></channel></rss>