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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:24:35+00:00 2026-06-03T23:24:35+00:00

Could somebody guide me through what gets called in this scenario? template<class T> class

  • 0

Could somebody guide me through what gets called in this scenario?

template<class T>
class mat4 {
public :

T matrix[4][4];

    mat4();
    mat4(vec4<T> i, vec4<T> j, vec4<T> k, vec4<T> t);
    mat4(const T input_matrix[4][4]);

    //~mat4();

    mat4<T> Transposed() const;
    void Transpose();

    mat4<T> Inversed() const;
    void Inverse();

};

With the above code if i call

mat4<float> matrix;
float mf[4][4];

//fill the float matrix here

matrix = mf;

Then i know that the 3rd constructor gets called (it’s not explicit), but what is called beside that? A copy constructor for matrix that takes the temporary object created from the assignment operation? I’m debating whether or not i should create a custom assign operator for it or just let it handle itself. The custom operator would only copy the matrix into the mat4 and return a reference to the mat4, but if there’s no overhead in the automaticly created assignment operator then i’d rather stick to that.

  • 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-03T23:24:37+00:00Added an answer on June 3, 2026 at 11:24 pm

    Any decent return value optimization should reduce this to just a call to the third constructor. As long as you’re compiling with optimization, there’s no need to reduce readability to reduce overhead in this case.

    Also, I don’t see how a custom copy constructor and/or assignment operator will have less overhead than the compiler-generated ones; they may even complicate the optimization.

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

Sidebar

Related Questions

Could somebody suggest a technique or class library to read up on for XML
Could somebody please explain the meaning of this error? INFO: Scanning for root resource
This is probably very simple, but could somebody tell me how to get the
Could somebody please advise how to call post method on load? <!DOCTYPE html PUBLIC
Could somebody please explain this to me. It seems to me that the number
Could somebody please name a few. I could given time, but this is for
could somebody please tell me why this code fails. url is nil after calling
Could somebody be kind to explain why in the world this gives me a
Could somebody help me with this. I would like to know how to read
Could somebody point me in the right direction of how I could read 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.