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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T21:08:16+00:00 2026-05-12T21:08:16+00:00

I’m trying really hard to made this work, but I’m having no luck. I’m

  • 0

I’m trying really hard to made this work, but I’m having no luck. I’m sure there is a work around, but I haven’t run across it yet. Alright, let’s see if I can describe the problem and the needs simply enough:

I have a RGB template class that can take typenames as one of its template parameters. It takes the typename and sends it into another template that creates a classification of its basic type. For example:

struct float_type {};
struct bit_type {};
struct fixed_pt_type {};

template <typename T> struct type_specification { typedef float_type type; };

template <> struct type_specification<char>      { typedef bit_type type; };
template <> struct type_specification<short>     { typedef bit_type type; };
template <> struct type_specification<int>       { typedef bit_type type; };
template <> struct type_specification<long>      { typedef bit_type type; };
template <> struct type_specification<long long> { typedef bit_type type; };

Then with this, I have a template that calculates Max Values for each of the RGB values based on its bit count:

template <int Bits, typename T> struct Max_Values { enum { MaxValue = (1 << Bits) - 1; }; };
template <int Bits> struct MaxValues<float_type>  { enum { MaxValue = 1.0; }; };

Then in the actual RGB template class, I have:

enum
{
     RMax = Max_Values<RBits, type_specification<T>::type>::MaxValue;
     GMax = Max_Values<GBits, type_specification<T>::type>::MaxValue;
     BMax = Max_Values<BBits, type_specification<T>::type>::MaxValue;
};

This works really well for me, until I got into the fixed-pt needs. The max value is a bit different and I don’t know how to create a type-specification specialization to isolate it out. The only work around I have is the process of elimination and creating specializations for float and double and assuming the general case will be fixed-pt. But there has to be a better way to do this. Here is what I want to do with incorrect code:

template <> struct type_specification<fixed_pt_t> { typedef fixed_pt_type type; };

However, fixed-pt-t is a template class that looks like:

template <int N, typename T, template <class> class Policy> struct fixed_pt_t

So the compiler does not like the specialization without template parameters.
Is there a way to specialize my type-specification class to work with fixed-pt-t?
It works fine for the general case, just can’t isolate it.

  • 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-12T21:08:16+00:00Added an answer on May 12, 2026 at 9:08 pm

    Perhaps I’m missing some bigger complication, but is there any reason why you can’t just partially specialize the type_specification template?

    Something like this:

    template <int N, typename T, template <class> class Policy>
    struct type_specification< fixed_pt_t<N, T, Policy> >
    {
        typedef fixed_pt_type type;
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.