<?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[Mehrfachverwendung von Bezeichnern]]></title><description><![CDATA[<p>In dieses Datentypen sollen Grundlage fuer JSON-Objekte sein. Wie zu sehen ist, werden Bezeichner wie array mehrfach verwendet, als Typ, Enum oder Member. Ich wuerde Compilerfehler erstmal erwarten, wobei es keine Mehrdeutigkeiten geben sollte. Leider uebersetzt es VS 2012 anstandslos, waehrend gcc 4.7.1 (<a href="http://ideone.com" rel="nofollow">ideone.com</a>) Fehler anzeigt. Leider stehen mir grad keine weiteren Testcompiler zur Verfuegung. Die Frage: Ist folgendes gueltiges C++11?</p>
<pre><code class="language-cpp">#include &lt;map&gt;
#include &lt;vector&gt;
#include &lt;string&gt;

namespace json {

class value;

typedef std::vector&lt;value&gt; array;
typedef std::map&lt;std::string, value&gt; object;
typedef std::string string;

enum class type
{
    null,
    boolean,
    integer,
    number,
    string,
    object,
    array
};

class value
{
public:
    type type;
    union
    {
        int integer;
        double number;
        bool boolean;
        string* string;
        array* array;
    };
};

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/318194/mehrfachverwendung-von-bezeichnern</link><generator>RSS for Node</generator><lastBuildDate>Mon, 27 Jul 2026 11:52:26 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/318194.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 04 Jul 2013 08:57:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Mehrfachverwendung von Bezeichnern on Thu, 04 Jul 2013 08:59:35 GMT]]></title><description><![CDATA[<p>In dieses Datentypen sollen Grundlage fuer JSON-Objekte sein. Wie zu sehen ist, werden Bezeichner wie array mehrfach verwendet, als Typ, Enum oder Member. Ich wuerde Compilerfehler erstmal erwarten, wobei es keine Mehrdeutigkeiten geben sollte. Leider uebersetzt es VS 2012 anstandslos, waehrend gcc 4.7.1 (<a href="http://ideone.com" rel="nofollow">ideone.com</a>) Fehler anzeigt. Leider stehen mir grad keine weiteren Testcompiler zur Verfuegung. Die Frage: Ist folgendes gueltiges C++11?</p>
<pre><code class="language-cpp">#include &lt;map&gt;
#include &lt;vector&gt;
#include &lt;string&gt;

namespace json {

class value;

typedef std::vector&lt;value&gt; array;
typedef std::map&lt;std::string, value&gt; object;
typedef std::string string;

enum class type
{
    null,
    boolean,
    integer,
    number,
    string,
    object,
    array
};

class value
{
public:
    type type;
    union
    {
        int integer;
        double number;
        bool boolean;
        string* string;
        array* array;
    };
};

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2336464</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2336464</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Thu, 04 Jul 2013 08:59:35 GMT</pubDate></item><item><title><![CDATA[Reply to Mehrfachverwendung von Bezeichnern on Thu, 04 Jul 2013 09:09:17 GMT]]></title><description><![CDATA[<p>knivil schrieb:</p>
<blockquote>
<p>Ist folgendes gueltiges C++11?</p>
<pre><code class="language-cpp">#include &lt;map&gt;
#include &lt;vector&gt;
#include &lt;string&gt;

namespace json {

class value;

typedef std::vector&lt;value&gt; array;
typedef std::map&lt;std::string, value&gt; object;
typedef std::string string;

enum class type
{
    null,
    boolean,
    integer,
    number,
    string,
    object,
    array
};

class value
{
public:
    type type;
    union
    {
        int integer;
        double number;
        bool boolean;
        string* string;
        array* array;
    };
};

}
</code></pre>
</blockquote>
<p>nein.</p>
<p>n3337 schrieb:</p>
<blockquote>
<p>3.3.7 Class scope [basic.scope.class]<br />
The following rules describe the scope of names declared in classes.</p>
<ol>
<li>The potential scope of a name declared in a class consists not only of the declarative region following<br />
the name’s point of declaration, but also of all function bodies, brace-or-equal-initializers of non-static<br />
data members, and default arguments in that class (including such things in nested classes).</li>
<li><strong>A name N used in a class S shall refer to the same declaration in its context and when re-evaluated in<br />
the completed scope of S. No diagnostic is required for a violation of this rule.</strong></li>
<li>If reordering member declarations in a class yields an alternate valid program under (1) and (2), the<br />
program is ill-formed, no diagnostic is required.</li>
<li>A name declared within a member function hides a declaration of the same name whose scope extends<br />
to or past the end of the member function’s class.<br />
...</li>
</ol>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/2336466</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2336466</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Thu, 04 Jul 2013 09:09:17 GMT</pubDate></item><item><title><![CDATA[Reply to Mehrfachverwendung von Bezeichnern on Thu, 04 Jul 2013 09:26:40 GMT]]></title><description><![CDATA[<p>Besagte Zeile sagt, folgendes ist Mist</p>
<pre><code class="language-cpp">type type; 
bool boolean; 
string* string; 
array* array;
</code></pre>
<p>Eigentlich klar ... aber was ist mit dem ersten Teil?</p>
<pre><code class="language-cpp">typedef std::vector&lt;value&gt; array; 
typedef std::map&lt;std::string, value&gt; object; 
typedef std::string string; 

enum class type 
{
    ...
    string, 
    object, 
    array 
};
</code></pre>
<p>Es wird zumindest vom gcc 4.7.1 geschluckt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2336471</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2336471</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Thu, 04 Jul 2013 09:26:40 GMT</pubDate></item><item><title><![CDATA[Reply to Mehrfachverwendung von Bezeichnern on Thu, 04 Jul 2013 09:26:33 GMT]]></title><description><![CDATA[<p>Ginge es nicht so?</p>
<pre><code class="language-cpp">class value
  {
  public:
    json::type type;
    union
    {
      int integer;
      double number;
      bool boolean;
      json::string* string;
      json::array* array;
    };
  };
</code></pre>
<p>Damit dürfte doch im Scope von <code>value</code> alles eindeutig sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2336473</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2336473</guid><dc:creator><![CDATA[Furble Wurble]]></dc:creator><pubDate>Thu, 04 Jul 2013 09:26:33 GMT</pubDate></item><item><title><![CDATA[Reply to Mehrfachverwendung von Bezeichnern on Thu, 04 Jul 2013 09:56:00 GMT]]></title><description><![CDATA[<p>knivil schrieb:</p>
<blockquote>
<p>was ist mit dem ersten Teil?</p>
<pre><code class="language-cpp">typedef std::vector&lt;value&gt; array; 
typedef std::map&lt;std::string, value&gt; object; 
typedef std::string string; 
  
enum class type 
{
    ...
    string, 
    object, 
    array 
};
</code></pre>
<p>Es wird zumindest vom gcc 4.7.1 geschluckt.</p>
</blockquote>
<p>Verschiedene Scopes, also kein Problem.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2336478</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2336478</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Thu, 04 Jul 2013 09:56:00 GMT</pubDate></item><item><title><![CDATA[Reply to Mehrfachverwendung von Bezeichnern on Thu, 04 Jul 2013 12:23:06 GMT]]></title><description><![CDATA[<p>@Furble Wurble: Ja, werde ich so machen. Ich war nur sehr verwirrt, warum ohne Warnung oder Fehler VS 2012 das uebersetzte.</p>
<p>Dank auch dir camper.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2336519</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2336519</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Thu, 04 Jul 2013 12:23:06 GMT</pubDate></item><item><title><![CDATA[Reply to Mehrfachverwendung von Bezeichnern on Fri, 05 Jul 2013 12:25:12 GMT]]></title><description><![CDATA[<p>Der MSVC ist bei vielen Dingen etwas toleranter und schreit den User nicht sofort an. Ist ganz angenehm, wenn man nur auf dem schreibt, aber sobald man Standardkonformen Code scheiben will und den Compiler auch mal wechselt, muss man öfters mal aufpassen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2336762</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2336762</guid><dc:creator><![CDATA[Skym0sh0]]></dc:creator><pubDate>Fri, 05 Jul 2013 12:25:12 GMT</pubDate></item><item><title><![CDATA[Reply to Mehrfachverwendung von Bezeichnern on Fri, 05 Jul 2013 13:19:20 GMT]]></title><description><![CDATA[<p>Toleranter nicht, aber genauer. Wenn eine Typebezeichnung erwartet wird, dann sucht er auch nur nach Bezeichnern fuer Datentypen. Aber genau darum geht es, ich will portabel entwickeln.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2336792</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2336792</guid><dc:creator><![CDATA[knivil]]></dc:creator><pubDate>Fri, 05 Jul 2013 13:19:20 GMT</pubDate></item></channel></rss>