<?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[Javas byte in C++(11) - ein char-Wrapper]]></title><description><![CDATA[<p>Hi!</p>
<p>Ich war letztens sehr traurig <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> , dass es in C++ nicht sowas schönes gibt wie <code>byte</code> (Java). Ich fand es also umso lustiger, mal was auszuprobieren und hab schließlich das hier herausbekommen:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;

template&lt;typename a, typename b, bool AorB&gt;
struct base_byte_helper{};

template&lt;typename a, typename b&gt;
struct base_byte_helper&lt;a, b, true&gt;
{
      typedef a type;
};
template&lt;typename a, typename b&gt;
struct base_byte_helper&lt;a, b, false&gt;
{
      typedef b type;
};

template&lt;bool&gt;
class base_byte;

template&lt;bool si&gt;
std::istream&amp; operator&gt;&gt;(std::istream&amp; is, base_byte&lt;si&gt;&amp; b);

template&lt;bool signed_&gt;
class base_byte
{
public:

      typedef typename base_byte_helper&lt;int8_t, uint8_t, signed_&gt;::type underlying_type;

      base_byte(underlying_type t) throw():
      value(t) {}

      base_byte() throw() {}

      operator underlying_type&amp;() throw()
      {
            return value;
      }
      operator underlying_type() const throw()
      {
            return value;
      }

      friend std::istream&amp; operator&gt;&gt;&lt;&gt;(std::istream&amp; is, base_byte&amp; b);

private:

       underlying_type value;
};

template&lt;bool si&gt;
std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, base_byte&lt;si&gt; const&amp; b)
{
      return os &lt;&lt; short(typename base_byte&lt;si&gt;::underlying_type(b));
}

template&lt;bool si&gt;
std::istream&amp; operator&gt;&gt;(std::istream&amp; is, base_byte&lt;si&gt;&amp; b)
{
      return is &gt;&gt; reinterpret_cast&lt;typename base_byte_helper&lt;short&amp;, unsigned short&amp;, si&gt;::type&gt;(b.value);
}

typedef base_byte&lt;true&gt; byte;
typedef base_byte&lt;true&gt; signed_byte;
typedef base_byte&lt;false&gt; unsigned_byte;
</code></pre>
<p>Hier meine Fragen:</p>
<ul>
<li>Ist der Code vollständig standardkonform (bspw. der <code>reinterpret_cast</code> )?<br />
Von <code>reinterprect_cast</code> kenne ich Paragraph 5.2.10, Klausel 11 (N3337):</li>
</ul>
<blockquote>
<p>An lvalue expression of type T1 can be cast to the type “reference to T2” if an expression of type “pointer to<br />
T1” can be explicitly converted to the type “pointer to T2” using a reinterpret_cast. That is, a reference<br />
cast reinterpret_cast&lt;T&amp;&gt;(x) has the same effect as the conversion *reinterpret_cast&lt;T*&gt;(&amp;x) with<br />
the built-in &amp; and * operators (and similarly for reinterpret_cast&lt;T&amp;&amp;&gt;(x)). The result refers to the same<br />
object as the source lvalue, but with a different type. The result is an lvalue for an lvalue reference type or<br />
an rvalue reference to function type and an xvalue for an rvalue reference to object type. No temporary is<br />
created, no copy is made, and constructors (12.1) or conversion functions (12.3) are not called.</p>
</blockquote>
<p>Also ist dieser Type pun legal?</p>
<ul>
<li>Verhalten sich <code>byte</code> , <code>signed_byte</code> und <code>unsigned_byte</code> jetzt genau wie <code>int8_t (char)</code> / <code>uint8_t (unsigned char)</code> , abgesehen vom I/O?</li>
<li>Und natürlich, ob man das noch besser/kürzer machen kann.</li>
<li>Und noch eine nebenfrage, nähmlich ob es sowas wie <code>base_byte_helper</code> in den Type-Traits oder irgendwo schon gibt.</li>
</ul>
<p>MfG, Hacker</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/305104/javas-byte-in-c-11-ein-char-wrapper</link><generator>RSS for Node</generator><lastBuildDate>Wed, 24 Jun 2026 06:24:05 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/305104.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 21 Jun 2012 07:30:47 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Javas byte in C++(11) - ein char-Wrapper on Thu, 21 Jun 2012 07:31:34 GMT]]></title><description><![CDATA[<p>Hi!</p>
<p>Ich war letztens sehr traurig <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> , dass es in C++ nicht sowas schönes gibt wie <code>byte</code> (Java). Ich fand es also umso lustiger, mal was auszuprobieren und hab schließlich das hier herausbekommen:</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;

template&lt;typename a, typename b, bool AorB&gt;
struct base_byte_helper{};

template&lt;typename a, typename b&gt;
struct base_byte_helper&lt;a, b, true&gt;
{
      typedef a type;
};
template&lt;typename a, typename b&gt;
struct base_byte_helper&lt;a, b, false&gt;
{
      typedef b type;
};

template&lt;bool&gt;
class base_byte;

template&lt;bool si&gt;
std::istream&amp; operator&gt;&gt;(std::istream&amp; is, base_byte&lt;si&gt;&amp; b);

template&lt;bool signed_&gt;
class base_byte
{
public:

      typedef typename base_byte_helper&lt;int8_t, uint8_t, signed_&gt;::type underlying_type;

      base_byte(underlying_type t) throw():
      value(t) {}

      base_byte() throw() {}

      operator underlying_type&amp;() throw()
      {
            return value;
      }
      operator underlying_type() const throw()
      {
            return value;
      }

      friend std::istream&amp; operator&gt;&gt;&lt;&gt;(std::istream&amp; is, base_byte&amp; b);

private:

       underlying_type value;
};

template&lt;bool si&gt;
std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, base_byte&lt;si&gt; const&amp; b)
{
      return os &lt;&lt; short(typename base_byte&lt;si&gt;::underlying_type(b));
}

template&lt;bool si&gt;
std::istream&amp; operator&gt;&gt;(std::istream&amp; is, base_byte&lt;si&gt;&amp; b)
{
      return is &gt;&gt; reinterpret_cast&lt;typename base_byte_helper&lt;short&amp;, unsigned short&amp;, si&gt;::type&gt;(b.value);
}

typedef base_byte&lt;true&gt; byte;
typedef base_byte&lt;true&gt; signed_byte;
typedef base_byte&lt;false&gt; unsigned_byte;
</code></pre>
<p>Hier meine Fragen:</p>
<ul>
<li>Ist der Code vollständig standardkonform (bspw. der <code>reinterpret_cast</code> )?<br />
Von <code>reinterprect_cast</code> kenne ich Paragraph 5.2.10, Klausel 11 (N3337):</li>
</ul>
<blockquote>
<p>An lvalue expression of type T1 can be cast to the type “reference to T2” if an expression of type “pointer to<br />
T1” can be explicitly converted to the type “pointer to T2” using a reinterpret_cast. That is, a reference<br />
cast reinterpret_cast&lt;T&amp;&gt;(x) has the same effect as the conversion *reinterpret_cast&lt;T*&gt;(&amp;x) with<br />
the built-in &amp; and * operators (and similarly for reinterpret_cast&lt;T&amp;&amp;&gt;(x)). The result refers to the same<br />
object as the source lvalue, but with a different type. The result is an lvalue for an lvalue reference type or<br />
an rvalue reference to function type and an xvalue for an rvalue reference to object type. No temporary is<br />
created, no copy is made, and constructors (12.1) or conversion functions (12.3) are not called.</p>
</blockquote>
<p>Also ist dieser Type pun legal?</p>
<ul>
<li>Verhalten sich <code>byte</code> , <code>signed_byte</code> und <code>unsigned_byte</code> jetzt genau wie <code>int8_t (char)</code> / <code>uint8_t (unsigned char)</code> , abgesehen vom I/O?</li>
<li>Und natürlich, ob man das noch besser/kürzer machen kann.</li>
<li>Und noch eine nebenfrage, nähmlich ob es sowas wie <code>base_byte_helper</code> in den Type-Traits oder irgendwo schon gibt.</li>
</ul>
<p>MfG, Hacker</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2225636</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2225636</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Thu, 21 Jun 2012 07:31:34 GMT</pubDate></item><item><title><![CDATA[Reply to Javas byte in C++(11) - ein char-Wrapper on Thu, 21 Jun 2012 07:33:21 GMT]]></title><description><![CDATA[<p>std::conditional</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2225637</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2225637</guid><dc:creator><![CDATA[Kellerautomat]]></dc:creator><pubDate>Thu, 21 Jun 2012 07:33:21 GMT</pubDate></item><item><title><![CDATA[Reply to Javas byte in C++(11) - ein char-Wrapper on Thu, 21 Jun 2012 07:37:05 GMT]]></title><description><![CDATA[<p>Kellerautomat schrieb:</p>
<blockquote>
<p>std::conditional</p>
</blockquote>
<p>Ich wusste, ich hab das gesehen. Danke schon mal für den Tipp <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /><br />
Das Problem ist halt, ich wollte den Code nicht nur für C++11 schreiben. Aber was solls...</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;

template&lt;bool&gt;
class base_byte;

template&lt;bool si&gt;
std::istream&amp; operator&gt;&gt;(std::istream&amp; is, base_byte&lt;si&gt;&amp; b);

template&lt;bool signed_&gt;
class base_byte
{
public:

      typedef typename std::conditional&lt;signed_, int8_t, uint8_t&gt;::type underlying_type;

      base_byte(underlying_type t) noexcept:
      value(t) {}

      base_byte() noexcept {}

      operator underlying_type&amp;() noexcept
      {
            return value;
      }
      operator underlying_type() const noexcept
      {
            return value;
      }

      friend std::istream&amp; operator&gt;&gt;&lt;&gt;(std::istream&amp; is, base_byte&amp; b);

private:

       underlying_type value;
};

template&lt;bool si&gt;
std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, base_byte&lt;si&gt; const&amp; b)
{
      return os &lt;&lt; short(typename base_byte&lt;si&gt;::underlying_type(b));
}

template&lt;bool si&gt;
std::istream&amp; operator&gt;&gt;(std::istream&amp; is, base_byte&lt;si&gt;&amp; b)
{
      return is &gt;&gt; reinterpret_cast&lt;typename std::conditional&lt;si, short&amp;, unsigned short&amp;&gt;::type&gt;(b.value);
}

typedef base_byte&lt;true&gt; byte;
typedef base_byte&lt;true&gt; signed_byte;
typedef base_byte&lt;false&gt; unsigned_byte;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2225638</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2225638</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Thu, 21 Jun 2012 07:37:05 GMT</pubDate></item><item><title><![CDATA[Reply to Javas byte in C++(11) - ein char-Wrapper on Thu, 21 Jun 2012 07:44:32 GMT]]></title><description><![CDATA[<p>Hacker schrieb:</p>
<blockquote>
<p>Ich war letztens sehr traurig <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> , dass es in C++ nicht sowas schönes gibt wie <code>byte</code> (Java).</p>
</blockquote>
<p>Was ist an byte in Java so besonders?</p>
<p>Dir gehts nur ums IO oder?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2225644</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2225644</guid><dc:creator><![CDATA[Shade Of Mine]]></dc:creator><pubDate>Thu, 21 Jun 2012 07:44:32 GMT</pubDate></item><item><title><![CDATA[Reply to Javas byte in C++(11) - ein char-Wrapper on Thu, 21 Jun 2012 07:46:01 GMT]]></title><description><![CDATA[<p>Shade Of Mine schrieb:</p>
<blockquote>
<p>Hacker schrieb:</p>
<blockquote>
<p>Ich war letztens sehr traurig <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> , dass es in C++ nicht sowas schönes gibt wie <code>byte</code> (Java).</p>
</blockquote>
<p>Was ist an byte in Java so besonders?</p>
<p>Dir gehts nur ums IO oder?</p>
</blockquote>
<p>Das sieht man doch. <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="🙄"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2225645</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2225645</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Thu, 21 Jun 2012 07:46:01 GMT</pubDate></item><item><title><![CDATA[Reply to Javas byte in C++(11) - ein char-Wrapper on Thu, 21 Jun 2012 07:50:28 GMT]]></title><description><![CDATA[<p>Ehrlich gesagt, ich sehe auch nicht welches Problem geloest werden soll.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2225648</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2225648</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Thu, 21 Jun 2012 07:50:28 GMT</pubDate></item><item><title><![CDATA[Reply to Javas byte in C++(11) - ein char-Wrapper on Thu, 21 Jun 2012 07:55:01 GMT]]></title><description><![CDATA[<p>Hat er doch gesagt:<br />
Problem: Er war traurig<br />
Lösung: Er hat was programmiert</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2225650</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2225650</guid><dc:creator><![CDATA[Belli]]></dc:creator><pubDate>Thu, 21 Jun 2012 07:55:01 GMT</pubDate></item><item><title><![CDATA[Reply to Javas byte in C++(11) - ein char-Wrapper on Thu, 21 Jun 2012 07:59:52 GMT]]></title><description><![CDATA[<p>Hacker schrieb:</p>
<blockquote>
<p>Das sieht man doch. <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="🙄"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
</blockquote>
<p>Ehrlich gesagt, nein.<br />
Man sieht dass du zuviel Zeit hast - aber nicht welches Problem hier gelöst werden soll.</p>
<p>Du willst einfach immer nur einen cast beim output haben?</p>
<p>Und dein input klappt natürlich nicht, weil short &gt;1byte ist <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2225651</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2225651</guid><dc:creator><![CDATA[Shade Of Mine]]></dc:creator><pubDate>Thu, 21 Jun 2012 07:59:52 GMT</pubDate></item><item><title><![CDATA[Reply to Javas byte in C++(11) - ein char-Wrapper on Thu, 21 Jun 2012 08:02:40 GMT]]></title><description><![CDATA[<p>Wofür genau soll das gut sein? Wieso benutzt du nicht einfach signed bzw. unsigned char?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2225652</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2225652</guid><dc:creator><![CDATA[dot]]></dc:creator><pubDate>Thu, 21 Jun 2012 08:02:40 GMT</pubDate></item><item><title><![CDATA[Reply to Javas byte in C++(11) - ein char-Wrapper on Thu, 21 Jun 2012 08:11:01 GMT]]></title><description><![CDATA[<p>dot schrieb:</p>
<blockquote>
<p>Wofür genau soll das gut sein? Wieso benutzt du nicht einfach signed bzw. unsigned char?</p>
</blockquote>
<p>Das ist doch nicht der Punkt! Es war nur zum Spaß (weil ich nix zu tun hab), und ich wollte wissen ob das so geht und ob es richtig Programmiert wurde.</p>
<p>Shade's Vorschlag war hilfreich. Der Input ist also nicht äquivalent, daran muss ich also noch pfeilen.</p>
<p>Mit &quot;Problem&quot; hat das nix zu tun. Ich würde nie im Leben in einem richtigen Projekt sowas benötigen, geschweige benutzen.<br />
<img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>Verdammt nochmal, Leute, es sind Sommerferien und ich hab einfach nix zum Programmieren. Ich könnte locker 10 Stunden am Tag dafür nehmen. Aber ich weiß nicht wofür. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/27a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--right_arrow"
      title=":arrow_right:"
      alt="➡"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/27a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--right_arrow"
      title=":arrow_right:"
      alt="➡"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f4a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--light_bulb"
      title=":bulb:"
      alt="💡"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/27a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--right_arrow"
      title=":arrow_right:"
      alt="➡"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/26a0.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--warning"
      title=":warning:"
      alt="⚠"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2225653</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2225653</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Thu, 21 Jun 2012 08:11:01 GMT</pubDate></item><item><title><![CDATA[Reply to Javas byte in C++(11) - ein char-Wrapper on Thu, 21 Jun 2012 08:16:09 GMT]]></title><description><![CDATA[<p>Man kann sich kaum mehr vorstellen, wie sich meine Generation vor 35 Jahren in den Sommerferien gelangweilt haben muss ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2225654</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2225654</guid><dc:creator><![CDATA[Belli]]></dc:creator><pubDate>Thu, 21 Jun 2012 08:16:09 GMT</pubDate></item><item><title><![CDATA[Reply to Javas byte in C++(11) - ein char-Wrapper on Thu, 21 Jun 2012 08:20:56 GMT]]></title><description><![CDATA[<p>Gibt es denn tatsächlich nichts, was dich interessiert, was du dir immer schonmal anschauen wolltest oder was du immer schonmal machen wolltest?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2225655</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2225655</guid><dc:creator><![CDATA[dot]]></dc:creator><pubDate>Thu, 21 Jun 2012 08:20:56 GMT</pubDate></item><item><title><![CDATA[Reply to Javas byte in C++(11) - ein char-Wrapper on Thu, 21 Jun 2012 08:23:13 GMT]]></title><description><![CDATA[<p>Ich könnte ein Praktikum in einer SE-Firma machen, das wär doch was. Kennt da jemand eine gute (Hamburg)?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2225657</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2225657</guid><dc:creator><![CDATA[Sone]]></dc:creator><pubDate>Thu, 21 Jun 2012 08:23:13 GMT</pubDate></item><item><title><![CDATA[Reply to Javas byte in C++(11) - ein char-Wrapper on Thu, 21 Jun 2012 08:32:20 GMT]]></title><description><![CDATA[<p>Fällt dir ja früh' ein ...</p>
<p>Ne, schreib' lieber weiterhin Code, den die Welt nicht braucht. <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="👍"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f921.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--clown_face"
      title=":clown:"
      alt="🤡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2225664</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2225664</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Thu, 21 Jun 2012 08:32:20 GMT</pubDate></item><item><title><![CDATA[Reply to Javas byte in C++(11) - ein char-Wrapper on Thu, 21 Jun 2012 08:54:21 GMT]]></title><description><![CDATA[<p>Projektideen gibt es wie Sand am mehr. Z.b. billige Webkam kaufen und und auf das Aquarium richten. Bewegung der Fische verfolgen lassen. Alternativ auf die Strasse richten und Autos tracken. Idee stammt nicht von mir, das Thema kam hier im Forum mal auf.</p>
<p>Alternativ Handgestenerkennenung, oder erstmal bis zum Punkt: Livestream einlesen, Hand und Fingerkuppen extrahieren, etc. ....</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2225672</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2225672</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Thu, 21 Jun 2012 08:54:21 GMT</pubDate></item><item><title><![CDATA[Reply to Javas byte in C++(11) - ein char-Wrapper on Thu, 21 Jun 2012 11:06:17 GMT]]></title><description><![CDATA[<p>Ich finde auch, dass nicht deutlich rauskommt (abgesehen vom Spaßfaktor), warum du das gemacht hast.</p>
<p>Hacker schrieb:</p>
<blockquote>
<p>Ist der Code vollständig standardkonform (bspw. der reinterpret_cast)?</p>
</blockquote>
<p>Sieht auf den ersten Blick falsch aus. Der interessante Teil ist doch:</p>
<pre><code class="language-cpp">signed char some_byte;
some_inputstream &gt;&gt; reinterpret_cast&lt;short&amp;&gt;(some_byte);
</code></pre>
<p>bzw</p>
<pre><code class="language-cpp">unsigned char some_byte;
some_inputstream &gt;&gt; reinterpret_cast&lt;unsigned short&amp;&gt;(some_byte);
</code></pre>
<p>Erklär mal, wie kommst du drauf, dass das okay wäre. Du versaust dir hier ja den automatischen Speicher, da sizeof(char) <em>typischerweise</em> kleiner als sizeof(short) ist.</p>
<p>Ich denke, du wolltest eher so etwas schreiben:</p>
<pre><code class="language-cpp">int value;
some_inputstream &gt;&gt; value;
if (value&lt;SCHAR_MIN || value&gt;SCHAR_MAX) {
  Überlauf irgendwie abfangen/signalisieren
  da die Zuweisung im else-Teil sonst UB hervorrufen würde
} else {
  signed char some_byte = value;
  ...
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2225677</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2225677</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Thu, 21 Jun 2012 11:06:17 GMT</pubDate></item><item><title><![CDATA[Reply to Javas byte in C++(11) - ein char-Wrapper on Thu, 21 Jun 2012 09:57:01 GMT]]></title><description><![CDATA[<p>Es geht ihm darum dass beim &quot;Rausschiften&quot; eines <code>char/signed char/unsigned char</code> mit Wert 50 nicht 50 am Schirm steht sondern irgend ein blöder Buchstabe.</p>
<p>Ich finde das übrigens auch immer wieder sehr bekloppt, vor allem weil es auch <code>signed char</code> und <code>unsigned char</code> betrifft.<br />
Fragt man sich wozu es <code>char</code> dann überhaupt als 3. Typen gibt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2225704</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2225704</guid><dc:creator><![CDATA[hustbaer]]></dc:creator><pubDate>Thu, 21 Jun 2012 09:57:01 GMT</pubDate></item><item><title><![CDATA[Reply to Javas byte in C++(11) - ein char-Wrapper on Thu, 21 Jun 2012 10:27:53 GMT]]></title><description><![CDATA[<p>Das einfachste dürfte wohl sein, die Operatoren selbst für signed char und unsigned char zu überladen. Ich glaube, die sind laut Standard nicht definiert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2225722</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2225722</guid><dc:creator><![CDATA[Kellerautomat]]></dc:creator><pubDate>Thu, 21 Jun 2012 10:27:53 GMT</pubDate></item><item><title><![CDATA[Reply to Javas byte in C++(11) - ein char-Wrapper on Thu, 21 Jun 2012 10:35:48 GMT]]></title><description><![CDATA[<p>Kellerautomat schrieb:</p>
<blockquote>
<p>Das einfachste dürfte wohl sein, die Operatoren selbst für signed char und unsigned char zu überladen. Ich glaube, die sind laut Standard nicht definiert.</p>
</blockquote>
<p>Leider doch. 27.6.1.2.3§10, 27.6.2.5.4 (C++98)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2225724</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2225724</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Thu, 21 Jun 2012 10:35:48 GMT</pubDate></item><item><title><![CDATA[Reply to Javas byte in C++(11) - ein char-Wrapper on Thu, 21 Jun 2012 10:45:00 GMT]]></title><description><![CDATA[<p>Hacker schrieb:</p>
<blockquote>
<p>Verdammt nochmal, Leute, es sind Sommerferien und ich hab einfach nix zum Programmieren. Ich könnte locker 10 Stunden am Tag dafür nehmen. Aber ich weiß nicht wofür. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/27a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--right_arrow"
      title=":arrow_right:"
      alt="➡"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/27a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--right_arrow"
      title=":arrow_right:"
      alt="➡"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f4a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--light_bulb"
      title=":bulb:"
      alt="💡"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/27a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--right_arrow"
      title=":arrow_right:"
      alt="➡"
    /> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/26a0.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--warning"
      title=":warning:"
      alt="⚠"
    /></p>
</blockquote>
<p>renn 200km</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2225725</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2225725</guid><dc:creator><![CDATA[asdfasf]]></dc:creator><pubDate>Thu, 21 Jun 2012 10:45:00 GMT</pubDate></item><item><title><![CDATA[Reply to Javas byte in C++(11) - ein char-Wrapper on Thu, 21 Jun 2012 10:57:36 GMT]]></title><description><![CDATA[<p>Sollte das nicht per manipulator lösbar sein?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2225731</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2225731</guid><dc:creator><![CDATA[Shade Of Mine]]></dc:creator><pubDate>Thu, 21 Jun 2012 10:57:36 GMT</pubDate></item><item><title><![CDATA[Reply to Javas byte in C++(11) - ein char-Wrapper on Thu, 21 Jun 2012 13:41:16 GMT]]></title><description><![CDATA[<p>Das ist mit static_cast&lt;int&gt; lösbar.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2225801</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2225801</guid><dc:creator><![CDATA[seldon]]></dc:creator><pubDate>Thu, 21 Jun 2012 13:41:16 GMT</pubDate></item><item><title><![CDATA[Reply to Javas byte in C++(11) - ein char-Wrapper on Thu, 21 Jun 2012 15:00:01 GMT]]></title><description><![CDATA[<p>Bashar schrieb:</p>
<blockquote>
<p>Leider doch. 27.6.1.2.3§10, 27.6.2.5.4 (C++98)</p>
</blockquote>
<p>Dann dürfte das hier doch eigentlich nicht kompilieren, oder? <a href="http://ideone.com/aU6po" rel="nofollow">http://ideone.com/aU6po</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2225837</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2225837</guid><dc:creator><![CDATA[Kellerautomat]]></dc:creator><pubDate>Thu, 21 Jun 2012 15:00:01 GMT</pubDate></item><item><title><![CDATA[Reply to Javas byte in C++(11) - ein char-Wrapper on Thu, 21 Jun 2012 15:07:05 GMT]]></title><description><![CDATA[<p>Wieso sollte das nicht kompilieren? Das tut genau das, was es laut Standard soll (char, signed char und unsigned char sind verschiedene Typen)...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2225844</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2225844</guid><dc:creator><![CDATA[dot]]></dc:creator><pubDate>Thu, 21 Jun 2012 15:07:05 GMT</pubDate></item><item><title><![CDATA[Reply to Javas byte in C++(11) - ein char-Wrapper on Thu, 21 Jun 2012 15:21:02 GMT]]></title><description><![CDATA[<p>Mehrfachdefinition und so...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2225849</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2225849</guid><dc:creator><![CDATA[Kellerautomat]]></dc:creator><pubDate>Thu, 21 Jun 2012 15:21:02 GMT</pubDate></item><item><title><![CDATA[Reply to Javas byte in C++(11) - ein char-Wrapper on Thu, 21 Jun 2012 15:25:48 GMT]]></title><description><![CDATA[<p>Wo siehst du da eine Mehrfachdefinition? Deine operator &lt;&lt; liegen im global Namespace...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2225851</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2225851</guid><dc:creator><![CDATA[dot]]></dc:creator><pubDate>Thu, 21 Jun 2012 15:25:48 GMT</pubDate></item></channel></rss>