Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6130699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:53:20+00:00 2026-05-23T16:53:20+00:00

How can I provide a class that has constructors as part of a union?

  • 0

How can I provide a class that has constructors as part of a union?

I’ve read that any class that has a trivial constructor can be part of a union. Especially with c++0x, I thought unions are supposed to be unrestricted. Why is this float4 class not suitable? How can I do this?

struct float4
{
    union
    {
        struct { float z, y, x, w; };
        float v[4];
        __m128 xmm;
    };

    inline float4() { }
    inline float4(float x, float y, float z, float w) :
        xmm(_mm_setr_ps(z, y, x, w)) { }
};

struct float44
{
    union
    {
        float v[16];
        __m128 xmm[4];
        struct { __m128 xmm1, xmm2, xmm3, xmm4; };
        struct { float4 row1, row2, row3, row4; };
    };
};
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:53:21+00:00Added an answer on May 23, 2026 at 4:53 pm

    VC2010 doesn’t implement that part of the C++0x spec yet.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

interfaces provide a useful abstraction capability. One can have a class Foo implement some
The simplest example that I can provide for what I want to do is
I am looking for a library or database that can provide guesses about whether
I'm developing an application in .NET where the user can provide Regular Expressions that
i was thinking about designing a service that can provide my subscribers feed updates
I have renamed a python class that is part of a library. I am
I recently noticed a class in C++0x that calls for an explicit default constructor.
Example: I have a class called ParentClass. ParentClass has a constructor like this: function
Let's say I have a class Foo in Java that has immutable data: class
For the purposes of interoperability with Java, I need a class that has a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.