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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:28:30+00:00 2026-06-15T09:28:30+00:00

On my system, wchar_t and int are distinct types with the same properties: #include

  • 0

On my system, wchar_t and int are distinct types with the same properties:

#include <type_traits>
sizeof(wchar_t) == sizeof(int) == 4
std::is_signed<wchar_t> == std::is_signed<int> == std::true_type
std::is_same<wchar_t, int> == std::false_type

In contrast, ptrdiff_t and long int are identical types (same properties, and is_same is true).

Is this distinctness of wchar_t guaranteed? Is it safe to overload for wchar_t and int on all systems? Is there any property in or elsewhere that distinguishes wchar_t and the corresponding int property besides is_same?

(System info: I’m interested in the general case, but my tests so far have been on an OS X machine running g++ 4.8.0 and Apple clang++ 4.1, both with -std=c++11.)

  • 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-15T09:28:31+00:00Added an answer on June 15, 2026 at 9:28 am

    Yes, wchar_t is guaranteed to be a distinct type (§3.9.1/5):

    Type wchar_t is a distinct type whose values can represent distinct codes for all members of the largest extended character set specified among the supported locales (22.3.1).

    So yes, it’s safe to overload for wchar_t and int on all systems.

    However, wchar_t is also guaranteed to have the same size, signedness and alignment requirements as another integral type, which is its underlying type. This isn’t necessarily int but in your case appears to be. This means wchar_t is probably implemented using one of the integral types, but as far as you are concerned, they are treated as completely distinct types.

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

Sidebar

Related Questions

code: #include <windows.h> int main() { SetConsoleOutputCP(CP_UTF8); system(echo Ιλιάδα); } prints on console: Ιλιάδα
String^ Source = System::IO::Directory::GetCurrentDirectory()+ \\DeleteFolder.exe\ ; String^ Destination = C:\\Windows\\DeleteFolder.exe; pin_ptr<const wchar_t> WSource =
C#: char z = '\u201D'; int i = (int)z; C++/CLI: wchar_t z = '\u201D';
I have some trouble using decltype for member function pointers: #include <iostream> #include <type_traits>
compiler : http://sourceforge.net/projects/mingwbuilds/files/ #include <iostream> #include <string.h> #include <windows.h> using namespace std; const wchar_t*
System.err.println() in Eclipse doesn't print in red. I checked preferences > Run/Debug > console
System: rails 3.2.3 1.9.2p320 ubuntu 12.04 32 bit I am trying to split up
/System/Library/Services/ImageCaptureService.app - what is it? Evernote uses it for importing the images from scanners
System.out.println(1+2+3); System.out.println(1+2+3); output:- 33 123 First case is understood but the second case is
System.Type contains an UnderlyingSystemType property. MSDN states that it: Indicates the type provided by

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.