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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:51:56+00:00 2026-05-18T01:51:56+00:00

I originally had a number of signal processing filter classes that were identical apart

  • 0

I originally had a number of signal processing filter classes that were identical apart from a few constants defining the filter characteristic, so I decided to change these to a template class for maintainability and extensibility. There are performance and memory management reasons for preferring a template over constructor arguments in this case; it is for an embedded system.

Consequently I have a template class of the form:

template <int SIZE, int SCALE_MULTIPLIER, int SCALE_SHIFT>
class cBoxcarFilter
{
public:
    // Allow access to SIZE at runtime.
    static const int FILTER_SIZE = SIZE ;
    ...
}

Which I explicitly instantiate thus, for example:

template class cBoxcarFilter<8, 1, 3>

The problem is when I need to access the FILTER_SIZE member it requires:

cBoxcarFilter<8, 1, 3>::FILTER_SIZE

which rather makes access to FILTER_SIZE redundant since it must be repeated in the arguments. My solution to this problem is this:

// Create an alias for filter
#define cSpecialistBoxcarFilter cBoxcarFilter<8, 1, 3>
template class cSpecialistBoxcarFilter ;

then I can access FILTER_SIZE thus:

cSpecialistBoxcarFilter::FILTER_SIZE

this also has the advantage of meaningful unique names for each filter instance as in the original non-templated versions, but it seems somewhat smelly to me using a macro that looks like a class since it has different scope semantics.

Is there a better way of creating alias class names for a template instance?

  • 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-18T01:51:57+00:00Added an answer on May 18, 2026 at 1:51 am

    Yes, typedef!

    typedef cBoxcarFilter<8, 1, 3> cSpecialistBoxcarFilter;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A co-worker asked about some code like this that originally had templates in it.
I originally had a function that uses pow(), and I noticed it was returning
Edit: Originally I had a simple form Ajax script that wasn't working, turns out
Well, I had built an application intended for MSSQL, and originally ran it that
Originally I had a design problem where I needed five subclasses of a superclass,
Originally I had two tables in my DB, [Property] and [Employee]. Each employee can
I had a problem that was making the original array to change, the curious
Originally, I just want to verify that session_start locks on session. So, I create
I originally started this question in another thread, but that thread was sorta, kinda
What's an effective way to handle data validation, say, from a form submission? Originally

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.