<?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[Illegal?]]></title><description><![CDATA[<p>Hi!</p>
<pre><code class="language-cpp">void fill_string ( char* s, int n )
{
	memset ( s, 'a', n );
}

int main() 
{ 
	string str;
	int n = 10;
	str.resize(n);
	fill_string( &amp;str[0], 10 );
	cout &lt;&lt; str &lt;&lt; endl;

	return 0;
}
</code></pre>
<p>Hab ne Frage zur Adressierung eines string. Speziell geht es mir um dieses Fützelchen:</p>
<blockquote>
<p>&amp;str[0]</p>
</blockquote>
<p>Ist das legaler C++ Code?</p>
<p>Ich möchte nämlich für eine UTF-8 -&gt; UTF-16LE Konversion die Windowsfunktion MultiByteToWideChar benutzen, und meine Strings auf diese Weise als Parameter übergeben.</p>
<p>LG.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/250500/illegal</link><generator>RSS for Node</generator><lastBuildDate>Sun, 05 Apr 2026 05:33:15 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/250500.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 18 Sep 2009 22:14:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Illegal? on Fri, 18 Sep 2009 22:14:31 GMT]]></title><description><![CDATA[<p>Hi!</p>
<pre><code class="language-cpp">void fill_string ( char* s, int n )
{
	memset ( s, 'a', n );
}

int main() 
{ 
	string str;
	int n = 10;
	str.resize(n);
	fill_string( &amp;str[0], 10 );
	cout &lt;&lt; str &lt;&lt; endl;

	return 0;
}
</code></pre>
<p>Hab ne Frage zur Adressierung eines string. Speziell geht es mir um dieses Fützelchen:</p>
<blockquote>
<p>&amp;str[0]</p>
</blockquote>
<p>Ist das legaler C++ Code?</p>
<p>Ich möchte nämlich für eine UTF-8 -&gt; UTF-16LE Konversion die Windowsfunktion MultiByteToWideChar benutzen, und meine Strings auf diese Weise als Parameter übergeben.</p>
<p>LG.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1781288</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1781288</guid><dc:creator><![CDATA[legal&#x2F;illegal schei...]]></dc:creator><pubDate>Fri, 18 Sep 2009 22:14:31 GMT</pubDate></item><item><title><![CDATA[Reply to Illegal? on Fri, 18 Sep 2009 22:21:40 GMT]]></title><description><![CDATA[<p>funzt auch so:</p>
<pre><code class="language-cpp">void fill_string ( const char* s, int n )
{
	memset ( (void*)s, 'a', n );
}

int main() 
{ 
	string str;
	int n = 10;
	str.resize(n);
	fill_string( str.c_str(), 10 );
	cout &lt;&lt; str &lt;&lt; endl;
</code></pre>
<p>aber ob das legal ist, k.a.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1781292</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1781292</guid><dc:creator><![CDATA[funz0r]]></dc:creator><pubDate>Fri, 18 Sep 2009 22:21:40 GMT</pubDate></item><item><title><![CDATA[Reply to Illegal? on Fri, 18 Sep 2009 22:34:19 GMT]]></title><description><![CDATA[<p>legal/illegal schei... schrieb:</p>
<blockquote>
<p>Hab ne Frage zur Adressierung eines string. Speziell geht es mir um dieses Fützelchen:</p>
<blockquote>
<p>&amp;str[0]</p>
</blockquote>
<p>Ist das legaler C++ Code?</p>
</blockquote>
<p>Soviel ich weiss, garantiert der Standard nicht (zumindest nicht explizit wie bei <code>std::vector</code> ), dass <code>std::string</code> intern ein Array speichern muss und man per <code>&amp;str[0]</code> darauf zugreifen kann. Von daher würde ich mich nicht unbedingt darauf verlassen. Du kannst ja direkt über <code>std::string::operator[]</code> auf die einzelnen Zeichen zugreifen. Oder <code>std::fill()</code> verwenden. Oder <code>std::string::assign()</code> . Oder...</p>
<p>funz0r schrieb:</p>
<blockquote>
<p>aber ob das legal ist, k.a.</p>
</blockquote>
<p><strong>Auf gar keinen Fall!</strong> Alleine das versteckte Wegcasten der Constness ist böse. Und dann noch <code>memset()</code> auf einen Speicher anwenden, bei dem du gar nicht weisst, wem er gehört oder wie lange er existiert. Mach das nicht, es gibt wie erwähnt bessere Möglichkeiten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1781296</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1781296</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Fri, 18 Sep 2009 22:34:19 GMT</pubDate></item><item><title><![CDATA[Reply to Illegal? on Fri, 18 Sep 2009 22:41:58 GMT]]></title><description><![CDATA[<p>Nexus schrieb:</p>
<blockquote>
<p>Du kannst ja direkt über <code>std::string::operator[]</code> auf die einzelnen Zeichen zugreifen. Oder <code>std::fill()</code> verwenden. Oder <code>std::string::assign()</code> . Oder...</p>
</blockquote>
<p>Das Füllen übernimmt die Windowsfunktion MultiByteToWideChar. Ich dachte mir, ich könnte so ein bisschen Code sparen, wenn ich nicht über dynamische char* gehe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1781300</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1781300</guid><dc:creator><![CDATA[l.i.s]]></dc:creator><pubDate>Fri, 18 Sep 2009 22:41:58 GMT</pubDate></item><item><title><![CDATA[Reply to Illegal? on Fri, 18 Sep 2009 22:44:51 GMT]]></title><description><![CDATA[<p>Hm.<br />
Ist bei std::string denn überhaupt garantiert, dass <code>&amp;str[0]</code> einen Zeiger auf eine Array-Repräsentation des Strings liefert? Soweit ich weiss <strong>nicht</strong>.<br />
Genau dafür gibt es nämlich die Memberfunktion <code>c_str</code> . (Die dann allerdings nur nen const-Zeiger zurückgibt.)</p>
<blockquote>
<p>Alleine das versteckte Wegcasten der Constness ist böse</p>
</blockquote>
<p>Welches const?<br />
Siehe: <a href="http://www.cplusplus.com/reference/string/string/operator%5B%5D/" rel="nofollow">http://www.cplusplus.com/reference/string/string/operator[]/</a></p>
<p>Man darf sogar ganz offiziell Änderungen über den operator [] machen. Bloss fehlt bei std::string eben die Garantie, wie es sie bei std::vector gibt, dass <code>&amp;str[0]</code> der Anfang eines zusammenhängenden Speicherbereichs ist, wo alle Elemente hintereinander abgelegt sind.<br />
Etwas formaler: die Garantie dass <code>(&amp;str[N]) == (&amp;str[0]) + N</code></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1781301</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1781301</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Fri, 18 Sep 2009 22:44:51 GMT</pubDate></item><item><title><![CDATA[Reply to Illegal? on Fri, 18 Sep 2009 22:49:51 GMT]]></title><description><![CDATA[<p>l.i.s schrieb:</p>
<blockquote>
<p>Nexus schrieb:</p>
<blockquote>
<p>Du kannst ja direkt über <code>std::string::operator[]</code> auf die einzelnen Zeichen zugreifen. Oder <code>std::fill()</code> verwenden. Oder <code>std::string::assign()</code> . Oder...</p>
</blockquote>
<p>Das Füllen übernimmt die Windowsfunktion MultiByteToWideChar. Ich dachte mir, ich könnte so ein bisschen Code sparen, wenn ich nicht über dynamische char* gehe.</p>
</blockquote>
<p>Verwende einen std::vector&lt;char&gt; (bzw. wchar_t) als Puffer, und mach dann so nen String draus:</p>
<pre><code class="language-cpp">std::wstring lala()
{
    std::vector&lt;wchar_t&gt; buffer;
    buffer.resize(initial_size);

    // ... das ganze MultiByteToWideChar gedöns ...

    return std::wstring(buffer.begin(), buffer.begin() + result_length);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1781302</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1781302</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Fri, 18 Sep 2009 22:49:51 GMT</pubDate></item><item><title><![CDATA[Reply to Illegal? on Fri, 18 Sep 2009 22:52:52 GMT]]></title><description><![CDATA[<p>hustbaer schrieb:</p>
<blockquote>
<p>Bloss fehlt bei std::string eben die Garantie, wie es sie bei std::vector gibt, dass <code>&amp;str[0]</code> der Anfang eines zusammenhängenden Speicherbereichs ist, wo alle Elemente hintereinander abgelegt sind.<br />
Etwas formaler: die Garantie dass <code>(&amp;str[N]) == (&amp;str[0]) + N</code></p>
</blockquote>
<p>oh! bedeutet also, das auch wenn ich c_str als parameter übergebe, nicht sicher sein kann, das alle elemente hintereinander liegen?<br />
hmm... dann sollte ich wohl lieber doch ein char* array zwischenschalten`?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1781304</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1781304</guid><dc:creator><![CDATA[l.i.s]]></dc:creator><pubDate>Fri, 18 Sep 2009 22:52:52 GMT</pubDate></item><item><title><![CDATA[Reply to Illegal? on Fri, 18 Sep 2009 22:55:26 GMT]]></title><description><![CDATA[<p>hustbaer schrieb:</p>
<blockquote>
<p>Verwende einen std::vector&lt;char&gt; (bzw. wchar_t) als Puffer, und mach</p>
</blockquote>
<p>ah, ok. ist zwar auch ne ganz schöne konvertierungsorgie, aber vermutlich der sicherste weg.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1781306</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1781306</guid><dc:creator><![CDATA[l.i.s]]></dc:creator><pubDate>Fri, 18 Sep 2009 22:55:26 GMT</pubDate></item><item><title><![CDATA[Reply to Illegal? on Fri, 18 Sep 2009 23:00:57 GMT]]></title><description><![CDATA[<p>hustbaer schrieb:</p>
<blockquote>
<blockquote>
<p>Alleine das versteckte Wegcasten der Constness ist böse</p>
</blockquote>
<p>Welches const?</p>
</blockquote>
<p>Das hier, wie gesagt versteckt:</p>
<pre><code class="language-cpp">//                 const
//                   |
//                   v
void fill_string ( const char* s, int n )
{
//       versteckter const_cast!
//              |
//              v
	memset ( (void*)s, 'a', n );
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1781307</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1781307</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Fri, 18 Sep 2009 23:00:57 GMT</pubDate></item><item><title><![CDATA[Reply to Illegal? on Sat, 19 Sep 2009 00:04:31 GMT]]></title><description><![CDATA[<p>string bzw wstring ist doch sowieso nur ein Container wie vector für char/wchar_t mit etwas erweiterten Möglichkeiten. Natürlich geht das.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1781314</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1781314</guid><dc:creator><![CDATA[Icematix]]></dc:creator><pubDate>Sat, 19 Sep 2009 00:04:31 GMT</pubDate></item><item><title><![CDATA[Reply to Illegal? on Sat, 19 Sep 2009 01:31:50 GMT]]></title><description><![CDATA[<p>Nexus schrieb:</p>
<blockquote>
<p>hustbaer schrieb:</p>
<blockquote>
<blockquote>
<p>Alleine das versteckte Wegcasten der Constness ist böse</p>
</blockquote>
<p>Welches const?</p>
</blockquote>
<p>Das hier, wie gesagt versteckt:</p>
<pre><code class="language-cpp">//                 const
//                   |
//                   v
void fill_string ( const char* s, int n )
{
//       versteckter const_cast!
//              |
//              v
	memset ( (void*)s, 'a', n );
}
</code></pre>
</blockquote>
<p>oops, sorry <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="🙂"
    /><br />
hab nur im kopfposting geguckt.</p>
<p>p.S.: ja, die C-style casts sind die schlimmsten!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1781316</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1781316</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Sat, 19 Sep 2009 01:31:50 GMT</pubDate></item><item><title><![CDATA[Reply to Illegal? on Sat, 19 Sep 2009 00:59:16 GMT]]></title><description><![CDATA[<p>l.i.s schrieb:</p>
<blockquote>
<p>hustbaer schrieb:</p>
<blockquote>
<p>Bloss fehlt bei std::string eben die Garantie, wie es sie bei std::vector gibt, dass <code>&amp;str[0]</code> der Anfang eines zusammenhängenden Speicherbereichs ist, wo alle Elemente hintereinander abgelegt sind.<br />
Etwas formaler: die Garantie dass <code>(&amp;str[N]) == (&amp;str[0]) + N</code></p>
</blockquote>
<p>oh! bedeutet also, das auch wenn ich c_str als parameter übergebe, nicht sicher sein kann, das alle elemente hintereinander liegen?<br />
hmm... dann sollte ich wohl lieber doch ein char* array zwischenschalten`?</p>
</blockquote>
<p>nene, c_str() garantiert schon dass alles hintereinander liegt. als input kannst du nen std::(w)string jederzeit verwenden.</p>
<p>bloss als output nicht, da c_str() ja einen const-zeiger zurückgibt. und wegcasten solltest du das const wirklich nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1781317</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1781317</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Sat, 19 Sep 2009 00:59:16 GMT</pubDate></item><item><title><![CDATA[Reply to Illegal? on Sat, 19 Sep 2009 01:06:13 GMT]]></title><description><![CDATA[<p>Ok, danke! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1781318</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1781318</guid><dc:creator><![CDATA[l.i.s]]></dc:creator><pubDate>Sat, 19 Sep 2009 01:06:13 GMT</pubDate></item><item><title><![CDATA[Reply to Illegal? on Sat, 19 Sep 2009 04:07:27 GMT]]></title><description><![CDATA[<p>legal/illegal schei... schrieb:</p>
<blockquote>
<p>Ich möchte nämlich für eine UTF-8 -&gt; UTF-16LE Konversion die Windowsfunktion MultiByteToWideChar benutzen, und meine Strings auf diese Weise als Parameter übergeben.</p>
</blockquote>
<p>Nimm liber gleich nen besseren String als das std::string zeugs</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1781328</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1781328</guid><dc:creator><![CDATA[www]]></dc:creator><pubDate>Sat, 19 Sep 2009 04:07:27 GMT</pubDate></item><item><title><![CDATA[Reply to Illegal? on Sat, 19 Sep 2009 04:08:16 GMT]]></title><description><![CDATA[<p>*lieber</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1781329</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1781329</guid><dc:creator><![CDATA[www]]></dc:creator><pubDate>Sat, 19 Sep 2009 04:08:16 GMT</pubDate></item><item><title><![CDATA[Reply to Illegal? on Sat, 19 Sep 2009 05:49:47 GMT]]></title><description><![CDATA[<p>Ok, dieser Beitrag beantwortet nicht die Frage der Legalität. Aber wozu stellt man die Frage überhaupt?!!!</p>
<pre><code class="language-cpp">int main() 
{ 
	string str (10,'a');
	cout &lt;&lt; str &lt;&lt; endl;
	return 0;
}
</code></pre>
<p>Es gibt auch noch<a href="http://www.cplusplus.com/reference/algorithm/fill/" rel="nofollow"> <code>std::fill</code> </a>aus<a href="http://www.cplusplus.com/reference/algorithm/" rel="nofollow"> <code>&lt;algorithm&gt;</code> </a>.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1781333</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1781333</guid><dc:creator><![CDATA[viel besserer]]></dc:creator><pubDate>Sat, 19 Sep 2009 05:49:47 GMT</pubDate></item><item><title><![CDATA[Reply to Illegal? on Sat, 19 Sep 2009 06:09:19 GMT]]></title><description><![CDATA[<p>viel besserer schrieb:</p>
<blockquote>
<p>Ok, dieser Beitrag beantwortet nicht die Frage der Legalität. Aber wozu stellt man die Frage überhaupt?!!!</p>
</blockquote>
<p>einfach mal alles lesen was er schreibt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1781335</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1781335</guid><dc:creator><![CDATA[er stau n lich]]></dc:creator><pubDate>Sat, 19 Sep 2009 06:09:19 GMT</pubDate></item><item><title><![CDATA[Reply to Illegal? on Sat, 19 Sep 2009 14:44:24 GMT]]></title><description><![CDATA[<p>beantwortet zwar auch nicht die frage nach der legalität, aber die ist ja auch schon geklärt<br />
aber ich glaube nicht (mehr ^^), dass man eine wirklich standard-konforme und effektive string-klasse ohne vector hinbekommt - also wird (obwohl es implementation defined ist) imho der code aus dem TO-post funktionieren.</p>
<p>aber ich hab noch immer nicht verstanden, warum der TO nicht mit dem op[] bzw mit iteratoren arbeiten möchte...</p>
<p>bb</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1781444</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1781444</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Sat, 19 Sep 2009 14:44:24 GMT</pubDate></item><item><title><![CDATA[Reply to Illegal? on Sat, 19 Sep 2009 15:09:26 GMT]]></title><description><![CDATA[<p>huestbar schrieb:</p>
<blockquote>
<p>Man darf sogar ganz offiziell Änderungen über den operator [] machen. Bloss fehlt bei std::string eben die Garantie, wie es sie bei std::vector gibt, dass &amp;str[0] der Anfang eines zusammenhängenden Speicherbereichs ist, wo alle Elemente hintereinander abgelegt sind.<br />
Etwas formaler: die Garantie dass <code>(&amp;str[N]) == (&amp;str[0]) + N</code></p>
</blockquote>
<p>Die Garantie steht in den letzten Working Drafts drin. Und zwar fast genauso:</p>
<p>WD §21.3.1/3 basic_string general requirements schrieb:</p>
<blockquote>
<p>The char-like objects in a <code>basic_string</code> object shall be stored contiguously. That is, for any <code>basic_string</code> object <code>s</code> , the identity <code>&amp;*(s.begin() + n) == &amp;*s.begin() + n</code> shall hold for all values of n such that <code>0 &lt;= n &lt; s.size()</code> .</p>
</blockquote>
<p>Und <code>operator[n]</code> ist definiert über <code>*(begin() + n)</code> . Also darf man das inzwischen. Ich weiß aber nicht, wann diese Garantie aufgenommen wurde, sie kam auf jeden Fall später als die für <code>std::vector&lt;T&gt;</code> . Es ist auch noch nicht lange her, dass ich zufällig über diese Stelle im Working Draft gestolpert bin.</p>
<p>Deswegen habe ich auch einmal vor kurzem an anderer Stelle geschrieben, dass <code>std::basic_string&lt;T&gt;</code> nur noch ein auf Zeichenketten optimierter, monolithischer Vektor ist. Der Umweg über <code>std::vector&lt;T&gt;</code> ist also nicht mehr notwendig.</p>
<p>Also: Der Code müsste valides C++0x sein, ist aber undefined behaviour in C++98 und C++03.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1781460</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1781460</guid><dc:creator><![CDATA[Old McDonald]]></dc:creator><pubDate>Sat, 19 Sep 2009 15:09:26 GMT</pubDate></item><item><title><![CDATA[Reply to Illegal? on Sat, 19 Sep 2009 16:34:24 GMT]]></title><description><![CDATA[<p>Danke für den Hinweis!</p>
<blockquote>
<p>Der Umweg über std::vector&lt;T&gt; ist also nicht mehr notwendig.</p>
<p>Also: Der Code müsste valides C++0x sein, ist aber undefined behaviour in C++98 und C++03.</p>
</blockquote>
<p>Naja. Genaugenommen ist der C++03 Standard immer noch der aktuell gültige.<br />
Werd's mir aber für die Zukunft merken <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>
]]></description><link>https://www.c-plusplus.net/forum/post/1781486</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1781486</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Sat, 19 Sep 2009 16:34:24 GMT</pubDate></item><item><title><![CDATA[Reply to Illegal? on Sat, 19 Sep 2009 17:49:32 GMT]]></title><description><![CDATA[<p>Old McDonald schrieb:</p>
<blockquote>
<p>Und <code>operator[n]</code> ist definiert über <code>*(begin() + n)</code> . Also darf man das inzwischen.</p>
</blockquote>
<p>Das allein (also ohne das, was Du vorher geschrieben hast) garantiert allerdings nicht, dass die Elemente hintereinander im Speicher liegen. basic_string&lt;&gt;::begin() muss ja keinen Zeiger zurückgeben.</p>
<p>BTW: Die <code>&amp;*(s.begin() + n) == &amp;*s.begin() + n</code> -Garantie gibt es scheinbar nicht in C++03 -- sie ist zumindest nicht in N1804 von 2005 drin, wenn ich nichts übersehen habe.</p>
<p>Gruß,<br />
SP</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1781513</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1781513</guid><dc:creator><![CDATA[Sebastian Pizer]]></dc:creator><pubDate>Sat, 19 Sep 2009 17:49:32 GMT</pubDate></item><item><title><![CDATA[Reply to Illegal? on Sat, 19 Sep 2009 19:03:59 GMT]]></title><description><![CDATA[<p>Ja, das allein nicht. Aber zusammengenommen mit der Garantie, dass <code>&amp;*begin() + n == &amp;*(begin() + n)</code> , folgt natürlich <code>&amp;s[n] == &amp;s[0] + n</code> .</p>
<p>In C++03 gab's die Garantie nicht, das ist mir auch aufgefallen, als ich ein wenig gesucht habe. Also ist die Garantie bei <code>std::vector</code> älter.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1781538</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1781538</guid><dc:creator><![CDATA[Old McDonald]]></dc:creator><pubDate>Sat, 19 Sep 2009 19:03:59 GMT</pubDate></item></channel></rss>