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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:25:41+00:00 2026-06-13T02:25:41+00:00

I have tried to implement a template template template – template class to fullfill

  • 0

I have tried to implement a “template template template” – template class to fullfill my needs ( I am quite new in using template metaprogramming). Unfortunately, I have found the following topic too late:
Template Template Parameters

Nevertheless, I need to implement something like listed below.

According to the compiler the last typedef is not working. I am not sure, but I think this is due to the limitation of 3x template restriction. Is there any possibility to bypass a 3xtemplate definition in this simple example?

template < typename TValueType >
class ITTranslator
{
public:
    ITTranslator() = 0;
    virtual ~ITTranslator() = 0;
    virtual void doSomething() = 0;
}

template < typename TValueType >
class TConcreteTranslator1 : public ITTranslator<TValueType>
{
public:
    TConcreteTranslator1(){}
    ~TConcreteTranslator1(){}
    void doSomething() {}
}

template < typename TValueType >
class TConcreteTranslator2 : public ITTranslator<TValueType>
{
public:
    TConcreteTranslator2(){}
    ~TConcreteTranslator2(){}
    void doSomething() {}
}

template < 
    typename TValueType, 
    template < typename TValueType > class TTranslatorValueType 
    >
class ITClassifier
{
public:
    ITClassifier() = 0;
    virtual ~ITClassifier() = 0;
}

template < 
    typename TValueType, 
    template < typename TValueType > class TTranslatorValueType 
    >
class TConcreteClassifier1 : public ITClassifier<TValueType,TTranslatorValueType >
{
public:
    TConcreteClassifier1() {}
    ~TConcreteClassifier1() {}
    void dodo(){}
}


template < 
    typename TValueType,
    template <typename TValueType> class TTranslatorValueType,
    template <template<typename TValueType> class TTranslatorValueType> class TClassifierValueType
 >
class ITAlgorithm
{
public:
    ITAlgorithm()=0;
    virtual ~TAlgorithm()=0;
    virtual run() = 0;
}


template < 
    typename TValueType,
    template <typename TValueType> class TTranslatorValueType,
    template <template<typename TValueType> class TTranslatorValueType> class TClassifierValueType
 >
class TConcreteAlgorithm1 : public ITAlgorithm<TValueType,TTranslatorValueType,TTranslatorValueType>
{
public:
    TConcreteAlgorithm1 (){}
    ~TConcreteAlgorithm1 (){}
    run()
    {
        TClassifierValueType< TTranslatorValueType>* l_classifier_pt = new TClassifierValueType< TTranslatorValueType>( );
        // add this object to a internal list...
    }
}



int main()
{
    typedef TConcreteTranslator1< cvbase::uint32_t > translator_t;
    typedef TConcreteClassifier1< cvbase::uint32_t, TConcreteTranslator1> classifier_t;
    typedef TConcreteAlgorithm1 < cvbase::uint32_t, TConcreteTranslator1, TConcreteClassifier1> algorithm_t; // not possible
    return 0;
}

Thanks a lot, I really appreciate any help!

EDIT:
I have extended my listing (I am pretty sure it will not compile :)) to show the motivation why I am using my weird concept 🙂

  • 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-13T02:25:42+00:00Added an answer on June 13, 2026 at 2:25 am

    There is really no need to pass template template parameter around
    here. Usually you can just take a normal template argument and provide
    a reasonable default:

    template<typename ValueType>
    struct translator {};
    
    template<typename ValueType, typename Translator = translator<ValueType>>
    struct Classifier {};
    
    template<typename ValueType, 
             typename Translator = translator<ValueType>, 
             typename Classifier = classifier<ValueType, Translator>
             >
    struct Algorithm {};
    

    This is done the same way for allocator aware containers.

    And please do away with the horrible hungarian-notation prefixes.

    NB: It seems from your usage of constructors and destructors that you
    don’t really have a grasp of basic C++. You might want to stay away
    from templates before you have understood easier concepts.

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

Sidebar

Related Questions

I have the following class template: template<class T, unsigned N> class MyClass; where T
I tried to implement an SFINAE using bool (unlike popular void_ trick ): template<typename
I have a class template Foo<T> . I'd like to implement a non-member function
I have to implement a non-member function isHomogenous(Triple triple) for a template class defined
I have tried to implement css sticky footer on my page but it doesn't
I have been looking around for solutions, and tried to implement what is often
I have tried a variety of different solutions found on stack and other places
I am trying to implement a leftist tree using heaps as a base class.
I have an assignment that requires us to implement a doubly linked list class.
I am trying to implement a template function with handles void differently using template

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.