<?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[boost::split mit boost::to_lower_copy]]></title><description><![CDATA[<p>Hi,</p>
<p>folgendes Programm wird nicht compiliert (g++):</p>
<pre><code>#include &lt;boost/algorithm/string.hpp&gt;
#include &lt;iostream&gt;
#include &lt;vector&gt;
#include &lt;string&gt;

int main()
{
   std::vector&lt;std::string&gt; splitted_line;
   boost::split(splitted_line,boost::to_lower_copy(std::string(&quot;Test Test&quot;)); , boost::is_any_of(&quot; &quot;));
   return 0;
}
</code></pre>
<p>Folgendes program wird compiliert:</p>
<pre><code>#include &lt;boost/algorithm/string.hpp&gt;
#include &lt;iostream&gt;
#include &lt;vector&gt;
#include &lt;string&gt;

int main()
{
   std::vector&lt;std::string&gt; splitted_line;
   std::string s = boost::to_lower_copy(std::string(&quot;Test Test&quot;));
   boost::split(splitted_line, s , boost::is_any_of(&quot; &quot;));
   return 0;
}
</code></pre>
<p>Der Fehler im ersten Programm ist:</p>
<pre><code>: error: invalid initialization of non-const reference of type ‘std::basic_string&lt;char&gt;&amp;’ from an rvalue of type ‘std::basic_string&lt;char&gt;’
    boost::split(splitted_line, boost::to_lower_copy(std::string(&quot;Test Test&quot;)) , boost::is_any_of(&quot; &quot;));
</code></pre>
<p>Warum muss ich den Rueckgabewert von &quot;to_lower_copy&quot; erst einer anderen Variable zuweisen?</p>
<p>Compiler: g++</p>
<p>Unter Windows mit dem MSVC wurde das erste Programm ohne Probleme kompiliert. Wollte es jetzt aber auch unter Linux benutzten und bin auf den Fehler gestossen.</p>
<p>mfg<br />
<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/topic/332881/boost-split-mit-boost-to_lower_copy</link><generator>RSS for Node</generator><lastBuildDate>Mon, 27 Apr 2026 09:29:23 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/332881.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 28 May 2015 02:48:13 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to boost::split mit boost::to_lower_copy on Thu, 28 May 2015 02:48:13 GMT]]></title><description><![CDATA[<p>Hi,</p>
<p>folgendes Programm wird nicht compiliert (g++):</p>
<pre><code>#include &lt;boost/algorithm/string.hpp&gt;
#include &lt;iostream&gt;
#include &lt;vector&gt;
#include &lt;string&gt;

int main()
{
   std::vector&lt;std::string&gt; splitted_line;
   boost::split(splitted_line,boost::to_lower_copy(std::string(&quot;Test Test&quot;)); , boost::is_any_of(&quot; &quot;));
   return 0;
}
</code></pre>
<p>Folgendes program wird compiliert:</p>
<pre><code>#include &lt;boost/algorithm/string.hpp&gt;
#include &lt;iostream&gt;
#include &lt;vector&gt;
#include &lt;string&gt;

int main()
{
   std::vector&lt;std::string&gt; splitted_line;
   std::string s = boost::to_lower_copy(std::string(&quot;Test Test&quot;));
   boost::split(splitted_line, s , boost::is_any_of(&quot; &quot;));
   return 0;
}
</code></pre>
<p>Der Fehler im ersten Programm ist:</p>
<pre><code>: error: invalid initialization of non-const reference of type ‘std::basic_string&lt;char&gt;&amp;’ from an rvalue of type ‘std::basic_string&lt;char&gt;’
    boost::split(splitted_line, boost::to_lower_copy(std::string(&quot;Test Test&quot;)) , boost::is_any_of(&quot; &quot;));
</code></pre>
<p>Warum muss ich den Rueckgabewert von &quot;to_lower_copy&quot; erst einer anderen Variable zuweisen?</p>
<p>Compiler: g++</p>
<p>Unter Windows mit dem MSVC wurde das erste Programm ohne Probleme kompiliert. Wollte es jetzt aber auch unter Linux benutzten und bin auf den Fehler gestossen.</p>
<p>mfg<br />
<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/2454970</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2454970</guid><dc:creator><![CDATA[Boost-Wust]]></dc:creator><pubDate>Thu, 28 May 2015 02:48:13 GMT</pubDate></item><item><title><![CDATA[Reply to boost::split mit boost::to_lower_copy on Thu, 28 May 2015 04:46:47 GMT]]></title><description><![CDATA[<p>Hallo<br />
Sicher das der obere Teil kopiert ist. Wenn Ja ist der Fehler nach:</p>
<pre><code>... Test&quot;)); ...
</code></pre>
<p>Entferne hier bitte denn Strichpunkt.</p>
<p>Mfg Marco</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2454973</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2454973</guid><dc:creator><![CDATA[Marc-O]]></dc:creator><pubDate>Thu, 28 May 2015 04:46:47 GMT</pubDate></item><item><title><![CDATA[Reply to boost::split mit boost::to_lower_copy on Thu, 28 May 2015 04:56:05 GMT]]></title><description><![CDATA[<p>Du kannst keinen temporären Wert an boost::split übergeben. split ist insofern optimiert, dass man als Ergebnis auch Referenzen auf das Original erhalten kann. Das geht logischerweise nicht mit einem temporären Wert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2454974</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2454974</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Thu, 28 May 2015 04:56:05 GMT</pubDate></item><item><title><![CDATA[Reply to boost::split mit boost::to_lower_copy on Thu, 28 May 2015 05:08:48 GMT]]></title><description><![CDATA[<p>SeppJ schrieb:</p>
<blockquote>
<p>Du kannst keinen temporären Wert an boost::split übergeben. split ist insofern optimiert, dass man als Ergebnis auch Referenzen auf das Original erhalten kann. Das geht logischerweise nicht mit einem temporären Wert.</p>
</blockquote>
<p>Verstehe, aber wieso wurde das Programm dann unter MSVC 2013 ohne Probleme kompiliert ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2454975</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2454975</guid><dc:creator><![CDATA[Boost-Wust]]></dc:creator><pubDate>Thu, 28 May 2015 05:08:48 GMT</pubDate></item><item><title><![CDATA[Reply to boost::split mit boost::to_lower_copy on Thu, 28 May 2015 07:37:39 GMT]]></title><description><![CDATA[<p>Boost-Wust schrieb:</p>
<blockquote>
<p>Verstehe, aber wieso wurde das Programm dann unter MSVC 2013 ohne Probleme kompiliert ?</p>
</blockquote>
<p>Da ist VS nicht standardkonform.<br />
Wenn Du das Warninglevel erhöhst, dann sollte das hier kommen:</p>
<p><a href="https://msdn.microsoft.com/en-us/library/186yxbac.aspx" rel="nofollow">https://msdn.microsoft.com/en-us/library/186yxbac.aspx</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2454995</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2454995</guid><dc:creator><![CDATA[__cu]]></dc:creator><pubDate>Thu, 28 May 2015 07:37:39 GMT</pubDate></item></channel></rss>