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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:00:41+00:00 2026-05-28T05:00:41+00:00

There is a class with three templates. #if defined(USE_CACHE_FALRU) template class Cache<FALRU>; #endif #if

  • 0

There is a class with three templates.

#if defined(USE_CACHE_FALRU)
template class Cache<FALRU>;
#endif

#if defined(USE_CACHE_IIC)
template class Cache<IIC>;
#endif

#if defined(USE_CACHE_LRU)
template class Cache<LRU>;
#endif

These template has common function:

FALRUBlk* accessBlock(Addr addr, int &lat, int context_src, int *inCache = 0);
IICTag* accessBlock(Addr addr, int &lat, int context_src);
BlkType* accessBlock(Addr addr, int &lat, int context_src);

As you can see, number of arguments for one of the templates differs from others.

Now in Cache(), there is a function which call accessBlock()

template<class TagStore>
bool Cache<TagStore>::access(PacketPtr pkt, BlkType *&blk, int &lat, PacketList &writebacks)
{ 
 ...
 blk = tags->accessBlock(pkt->getAddr(), lat, id);
 ...
}

In a confing file, all templates are defined

#define USE_CACHE_LRU 1
#define USE_CACHE_FALRU 1
#define USE_CACHE_IIC 1 

I wonder how this file is compiled. As you can see, FALRUBlk::accessBlock() takes 4 arguments. However in Cache::access(), only three arguments are passed.
So Can someone explain how this function compiled without problem?

  • 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-28T05:00:42+00:00Added an answer on May 28, 2026 at 5:00 am

    It compiles fine, because the default value for the 4th is used :

    FALRUBlk* accessBlock(Addr addr, int &lat, int context_src, int *inCache = 0);
    

    Other 2 have only 3 arguments :

    IICTag* accessBlock(Addr addr, int &lat, int context_src);
    BlkType* accessBlock(Addr addr, int &lat, int context_src);
    

    Therefore, you can always call that method like in your example :

    blk = tags->accessBlock(pkt->getAddr(), lat, id);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following use case: There's a class called Template and with that
Is there a C++ Standard Template Library class that provides efficient string concatenation functionality,
Is there a way for taking type of a template class, for example //i
Is there a way to have the compile deduce the template parameter automatically? template<class
I have a class template where some methods are defined as virtual to give
So in writing a C++ template class, I have defined a method that returns
I have a dll that contains a templated class. Is there a way to
There are three tables, Students, Classes, Student_Class Is it possible to select students who
I have a License class.There are 50 boolean properties and some timestamp properties. I
I'm currently trying to draw shapes with 2D Arrays. In my class there is

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.