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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:03:21+00:00 2026-05-20T06:03:21+00:00

I want to specialize a class template for char, short, long and long long.

  • 0

I want to specialize a class template for char, short, long and long long. This specializations should also holds good for the signed and unsigned variants of the integral types.

I know boost library and std::tr1 / C++0x implements is_signed/is_unsigned and make_signed/make_unsigned type_traits. But how can I remove any signed specification from the char type (note: the only integral type where signed itype != itype)?

  • 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-20T06:03:22+00:00Added an answer on May 20, 2026 at 6:03 am

    The “sign-ness” of char is implementation defined. It doesn’t have to be able to store negative numbers. In strict standardese, char even is never a signed integer type, even if it can store negative numbers on an implementation. Still, the class template is_signed will report true for char if it can store negative numbers, because that’s a useful thing for it to do.

    Anyway, the boost docs say the following about make_unsigned, making it look like you can use it for your purpose.

    If T is a unsigned integer type then the same type as T, if T is an signed integer type then the corresponding unsigned type. Otherwise if T is an enumerated or character type (char or wchar_t) then an unsigned integer type with the same width as T

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

Sidebar

Related Questions

I want to specialize a class template with the following function: template <typename T>
I want to specialize following member function: class foo { template<typename T> T get()
I want to specialize a template for STL's vector template arguments. Something like this:
i want a specialize template in a pointer-to-member-function case. Is there a way to
I want to make this specialized w/o changing main. Is it possible to specialize
I want to template the >> and << operators in a class, but I
I have a templated function which I want to specialize foo to const char[N]
I can't seem to find the right syntax to specialize this template : template
Consider this overly simple test: class foo { public: foo(int i); template< typename T
in a C program I have an long* that I want to serialize (thus

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.