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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:43:35+00:00 2026-05-11T12:43:35+00:00

I am new to C++ style casts and I am worried that using C++

  • 0

I am new to C++ style casts and I am worried that using C++ style casts will ruin the performance of my application because I have a real-time-critical deadline in my interrupt-service-routine.

I heard that some casts will even throw exceptions!

I would like to use the C++ style casts because it would make my code more ‘robust’. However, if there is any performance hit then I will probably not use C++ style casts and will instead spend more time testing the code that uses C-style casts.


Has anyone done any rigorous testing/profiling to compare the performance of C++ style casts to C style casts?

What were your results?

What conclusions did you draw?

  • 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. 2026-05-11T12:43:36+00:00Added an answer on May 11, 2026 at 12:43 pm

    If the C++ style cast can be conceptualy replaced by a C-style cast there will be no overhead. If it can’t, as in the case of dynamic_cast, for which there is no C equivalent, you have to pay the cost one way or another.

    As an example, the following code:

    int x; float f = 123.456;  x = (int) f; x = static_cast<int>(f); 

    generates identical code for both casts with VC++ – code is:

    00401041   fld         dword ptr [ebp-8] 00401044   call        __ftol (0040110c) 00401049   mov         dword ptr [ebp-4],eax 

    The only C++ cast that can throw is dynamic_cast when casting to a reference. To avoid this, cast to a pointer, which will return 0 if the cast fails.

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

Sidebar

Related Questions

I have a Marionette.ItemView that uses a CSS class to style new items differently:
I'm using new style classes in Python 2.6 and am having trouble with __getattr__
I have been working on a new style for my list boxes but I
Totally new to Obj-C, so thanks for patience. :P Because I'm beginner, I will
I'm currently working on a new web application and it's being developed using Oracle
I'm pretty new to CSS and have found a nuance that I don't understand.
I am concerned with using CSS classes that are defined in style sheets with
(Using PHP style code) Lest imagine we have Controller within which we have array
There is a new style of implemention menues which I see around stylish web
I am currently building a new style ecommerce shopping cart to test various scenarios

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.