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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:54:13+00:00 2026-05-19T02:54:13+00:00

Section 4.5 of the C++ standard (integer promotion) talks about specific cases of converting

  • 0

Section 4.5 of the C++ standard (integer promotion) talks about specific cases of converting integral types to types with a higher rank.

Section 4.7 of the C++ standard (integral conversions) begins with (bullet 4.7.1):

An rvalue of an integer type can be converted to an rvalue of another integer type. An rvalue of an enumeration type can be converted to an rvalue of an integer type.

As far as I understand conversions described in 4.5 (maybe except for the bullet 4.5.3 (enums)) can be performed by using the techniques from 4.7 section alone: 4.5.1 and 4.5.2 are completely covered by 4.7.1; 4.5.4 is covered by 4.7.4. So what’s the purpose of the entire 4.5 section? What additional conversions does it enable? Maybe I’m missing some restrictions?

P.S. I’m reading C++03 version of the standard.

  • 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-19T02:54:13+00:00Added an answer on May 19, 2026 at 2:54 am

    I think that the distinction is important because both do not fall in the same conversion category and have different rank (see 13.3.3.1.1, Standard conversion sequences). The rank makes a difference when it comes to overload resolution :

    Standard conversion sequences are ordered by their ranks: an Exact Match is a better conversion than a Promotion,
    which is a better conversion than a Conversion.

    In the end, I believe it is the distinction between 4.5 and 4.7 that makes the following code unambiguous :

    #include <iostream>
    
    void foo(int i)            { std::cout << "foo(int)" << std::endl; }
    void foo(unsigned short i) { std::cout << "foo(unsigned short)" << std::endl; }
    
    int main()
    {
        foo(static_cast<short>(1));
    }
    
    • short to int is a promotion (thus having promotion rank)
    • short to unsigned short is a conversion (thus having conversion rank)

    In the end, this code calls foo(int) because it is a better candidate.

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

Sidebar

Related Questions

Is it reasonable to put custom headers higher in include section than standard headers?
The C++0x standard working draft states (section 6.5.4) the following about the begin() and
Section 7.1 of the C++ Standard mentions about 'extern' as a storage class specifier.
See section /* Common Classes */ of this page. http://webdesign.about.com/od/css/a/master_stylesht_2.htm are these css classes
In the section covering setlocale, the ANSI C standard states in a footnote that
quoting from The C++ Standard Library by N M Jousttis, Section 5.9 #include <
ISO 98/03 standard (section 14.3.1) seems to forbid using a type with internal linkage
C++ standard says in section 4.12, An rvalue of arithmetic, enumeration, pointer, or pointer
The C99 standard document has the following example in the section related to the
I was looking over section 7.3.1.1 in the C++03 standard expecting to find some

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.