help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: %union with STL


From: Luca
Subject: Re: %union with STL
Date: Mon, 25 May 2009 22:11:59 +0200
User-agent: Thunderbird 2.0.0.21 (Windows/20090302)

Hans Aberg ha scritto:
On 24 May 2009, at 16:13, Luca wrote:

C++ dont allow unions containing c++ classes
I think you're wrong. The size of a pointer is always known at compile time, pair<const string,int>* it; is a pointer and not an object. The size is 4 bytes using a 32 bit OS.

The problem is what the C++ standard really defines. I recall 'union's can only contains POD (plain old data), which is defined as types built from the C subset. The new C++ will extend this definition.

But you can use void* and cast to this type. The Bison type-system does not work with proper C++ casting involving function calls anyway.

  Hans



I successfully compiled a union containing pair<const string,int>* it; using bison 2.4.1. I think you can use pointers to C++ class inside a union without any trouble. Just try it.

Luca




reply via email to

[Prev in Thread] Current Thread [Next in Thread]