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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:40:44+00:00 2026-05-27T08:40:44+00:00

I have been hitting my head against a brick wall for a bit and

  • 0

I have been hitting my head against a brick wall for a bit and decided to submit and just post my error.

I have a template (shown below) that passes a std::map, which is inside a namespace. This compiles fine.

My problem occurs when trying to call the function template. I get the below error:

error: no matching function for call to 
    'getValuePointer(Muon*&, std::map<int, MET*, std::less<int>, 
                     std::allocator<std::pair<const int, MET*> > >*&)'

What am I doing wrong?

Here is the template code:

#ifndef OBJECTMAPMATCH_H
#define OBJECTMAPMATCH_H

#include <map>
#include <utility>
#include <typeinfo>
#include <iostream>
#include <stdlib.h>

using namespace std;

namespace ObjectMapMatch {


  template< class A, class B, class C >
    C  getValuePointer( A &x , map< B,C> &y )
  {

    if( y.find(x.Index()) != y.end() ){

      return y.find(x.Index()).second;

    }else{
      cout << "ERROR:ObjectMapMatch::getValuePointer:Can not Find " 
           <<  typeid(y).name() << " FOR " << typeid(x).name() << endl;
      exit(1);
    }

  }

}
#endif

Here is an example call to the template function

C = ObjectMapMatch::getValuePointer<ClassC*, int, ClassD*>(A, B);

Where:

C is ClassC*
A is ClassC*
B is std::map<int,ClassD*>*  

What am I doing wrong?

  • 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-27T08:40:45+00:00Added an answer on May 27, 2026 at 8:40 am

    According to the error message, you passed a pointer to a map as the second parameter, while the function expects a reference to a map.

    You can see this because of the * at the end here:

    no matching function for call to 
        'getValuePointer(Muon*&, std::map<...>*&)'
                                              ^
    

    There will be additional issues once you fix this though: Since x is of type ClassC*, calling x.Index() will give an error. Maybe the first template parameter should be ClassC instead of ClassC*.

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

Sidebar

Related Questions

Is there? I don't know. I've been hitting my head against a brick wall
I have been hitting my head against the wall with this one for few
I have been hitting my head against the wall trying to figure this out
Been hitting my head on the wall before as I don't make any test
I'm creating a 30-35 page comic book and just have been hitting roadblock after
I have been hitting my head on the desk attempting to wrack my brain
I am using OpenTK in C# and I have been hitting a wall for
I have been hitting a dead end with this program. I am trying to
I have been slowly learning iPhone development and seem to keep hitting walls where
I have been using ASIHTTPRequest to do a simple POST upload of a Scores

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.