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 986061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:15:34+00:00 2026-05-16T05:15:34+00:00

Is there an C++ casting operator (or combination thereof) equivalent to the old-style cast

  • 0

Is there an C++ casting operator (or combination thereof) equivalent to the old-style cast below:

struct MyStruct {
   int i;
   int j;
   int k;
};

void do_something_with_mystruct( MyStruct ms ) {
   ...
};

int main( int argc, char** argv ) {
   do_something_with_mystruct( (MyStruct){1,2,3} );
};
  • 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-16T05:15:35+00:00Added an answer on May 16, 2026 at 5:15 am

    The construct

    (MyStruct) {1,2,3}
    

    is not actually a cast! It’s an ISO C99 “compound literal”. There is no equivalent using any of the C++ *_cast<> operators, because C++ (even C++0x) does not include this construct. Some compilers implement it as an extension to C++, but you still have to write it this way. See for instance http://gcc.gnu.org/onlinedocs/gcc-4.4.4/gcc/Compound-Literals.html.

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

Sidebar

Related Questions

See edits below There is no casting going on with the termination check. I
Having being taught during my C++ days about evils of the C-style cast operator
Is there any difference between type casting & type conversion in c++.
Are there any generally-accepted coding standards (naming, casting etc) that apply specifically to iPhone/Cocoa/Objective-C?
Are there any reasons one would prefer to use Math.Floor vs casting to an
Does casting double to float always produce same result, or can there be some
Is there a way to avoid casting to a non-string type when reading data
How come there is no compiler error casting Number to List? I thought the
I want to templatize the casting operator with a specialization for bool, but it's
Are there any cases where we do down casting of objects? If we do,

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.