On Wed, Nov 12, 2008 at 2:10 PM, Lawrence Crowl [EMAIL PROTECTED] wrote:
Now would be a good time to mention Google's bit_cast.
And here is a simple portable implementation (still implementation
defined really) of that:
#include cstring
templatetypename to, typename from to bit_cast(from a)
{
On 11/11/08, James Dennett [EMAIL PROTECTED] wrote:
On Tue, Nov 11, 2008 at 8:04 PM, Mark Tall [EMAIL PROTECTED] wrote:
On 12/11/2008, James Dennett [EMAIL PROTECTED] wrote:
In a union only one field can be active at one time, hence
initializing more than one makes no sense
...
If all members of the union are const, why don't you just make the union
itself const?
class my_class_2
{
const union
{
int x;
int y;
};
my_class_2() : x(0) {}
};
--
René Bürgel
Software Engineer
Unicontrol Systemtechnik GmbH
OT Dittersbach
Sachsenburger Weg 34
09669
On 11/12/08, René Bürgel [EMAIL PROTECTED] wrote:
Mark Tall schrieb:
On 12/11/2008, René Bürgel [EMAIL PROTECTED] wrote:
If all members of the union are const, why don't you just
make the union itself const?
The const for the union seems to be ignored
I'd say, that's the real bug,
On Wed, Nov 12, 2008 at 12:53:54PM +1000, Mark Tall wrote:
Hello,
I've come across an oddity in C++, involving anonymous unions and
const variables. Neither of the two classes below will compile using
gcc 4.3.0. Is this a bug in gcc or the C++ standard itself ?
class my_class_1
{
On Tue, Nov 11, 2008 at 08:43:40PM -0800, James Dennett wrote:
(There are secondary uses of unions for type punning. Most such uses
are not valid portable C++, but g++ supports them because they're so
common in real code.)
On the contrary: the uses of unions for type-punning, while not
On Wed, Nov 12, 2008 at 11:29 AM, Joe Buck [EMAIL PROTECTED] wrote:
On Tue, Nov 11, 2008 at 08:43:40PM -0800, James Dennett wrote:
(There are secondary uses of unions for type punning. Most such uses
are not valid portable C++, but g++ supports them because they're so
common in real code.)
Mark Tall schrieb:
On 12/11/2008, René Bürgel [EMAIL PROTECTED] wrote:
If all members of the union are const, why don't you just make the union
itself const?
The const for the union seems to be ignored
I'd say, that's the real bug, at least from my point of view. I don't
know, if
On 12/11/2008, René Bürgel [EMAIL PROTECTED] wrote:
If all members of the union are const, why don't you just make the union
itself const?
The const for the union seems to be ignored (code below). The
original reason behind the union shenanigans was to provide a
compile-time alias to another
On 11/12/08, James Dennett [EMAIL PROTECTED] wrote:
On Wed, Nov 12, 2008 at 11:29 AM, Joe Buck [EMAIL PROTECTED] wrote:
On Tue, Nov 11, 2008 at 08:43:40PM -0800, James Dennett wrote:
(There are secondary uses of unions for type punning. Most such uses
are not valid portable C++, but g++
Hello,
I've come across an oddity in C++, involving anonymous unions and
const variables. Neither of the two classes below will compile using
gcc 4.3.0. Is this a bug in gcc or the C++ standard itself ?
class my_class_1
{
union
{
const int x;
const int y;
};
my_class_1()
On Tue, Nov 11, 2008 at 6:53 PM, Mark Tall [EMAIL PROTECTED] wrote:
Hello,
I've come across an oddity in C++, involving anonymous unions and
const variables. Neither of the two classes below will compile using
gcc 4.3.0. Is this a bug in gcc or the C++ standard itself ?
No...
class
On 12/11/2008, James Dennett [EMAIL PROTECTED] wrote:
In a union only one field can be active at one time, hence
initializing more than one makes no sense
...
However, const items need to be initialized, hence potting two in a
union makes no sense.
Conceptually there is nothing wrong with
On Tue, Nov 11, 2008 at 8:04 PM, Mark Tall [EMAIL PROTECTED] wrote:
On 12/11/2008, James Dennett [EMAIL PROTECTED] wrote:
In a union only one field can be active at one time, hence
initializing more than one makes no sense
...
However, const items need to be initialized, hence potting two in
14 matches
Mail list logo