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

  • Home
  • SEARCH
  • 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 8286599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:49:16+00:00 2026-06-08T11:49:16+00:00

I am making a library that involves 3-D coordinates, and discovered that there are

  • 0

I am making a library that involves 3-D coordinates, and discovered that there are two names for the components of a 3-D angle: yaw-pitch-roll and heading-elevation-bank

So I made the following (done in c++11):

struct Angle {
    float heading;
    float elevation;
    float bank;
    float &yaw = heading;
    float &pitch = elevation;
    float &roll = bank;

     // Some Constructors (copy and assignment have to be made manually)
 }

Which has the benefit of keeping the notation equivalent between the two name-schemes. For example:

Angle angle;
rotate(angle.yaw); // this is equivalent to rotate(angle.heading)

I was wondering if the compiler would figure out the references were unnecessary, or if it would keep the pointers in the structure.

Also, is there a better way to have two names for one member?

  • 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-06-08T11:49:18+00:00Added an answer on June 8, 2026 at 11:49 am

    I was wondering if the compiler would figure out the references were unnecessary, or if it would keep the pointers in the structure.

    In 99.9% of the cases, the pointers will be kept in the structure. I don’t see a way for the compiler to exclude them over translation units. Esp since your syntax is invalid, and you’d have to initialize the references in the constructor, which could very well be hidden. So there would be no way for it to know which reference references which member.

    There could be some performance overhead as well. For example:

      float x = a.elevation;
    013F13E0  fld         dword ptr [ebp-18h] 
    013F13E3  fstp        dword ptr [x] 
      float y = a.pitch;
    013F13E6  mov         eax,dword ptr [ebp-0Ch] 
    013F13E9  fld         dword ptr [eax] 
    013F13EB  fstp        dword ptr [y] 
    

    Indeed, internally, references act like pointers. So the extra mov makes up for dereferencing that pointer.

    I wouldn’t worry about it though, would instead care about the style. And having two member accounting for the same thing…just seems wrong.

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

Sidebar

Related Questions

While making some final tests of a class-library that I'm writing for Windows Mobile
I'm in the process of making some changes to a library that I'm using.
Is there an standard output library that knows that php outputs to html? For
I have an html helper library that I am making and one of my
I'm making a small userControl library that searches for active server on a specific
I am making a simple wrapper for a c library that needs to have
In this case, I'm working on a project that involves a database of library
Is there any Java open source library that supports multi-character (i.e., String with length
I am making a library that accept Views as input. I want to rotate
I'm making a android library app that can download and show special files. now

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.