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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:42:59+00:00 2026-05-28T17:42:59+00:00

So far, so good. However, a few issues have arisen. First and foremost, is

  • 0

So far, so good. However, a few issues have arisen.

First and foremost, is that when I call the following:

const bool bppExists = CheckMapForExistingEntry< std::string, int >( mConfigValues, "bpp" );

I get the following:

error: undefined reference to `bool CheckMapForExistingEntry<std::string, int>(std::map<std::string, int, std::less<std::string>, std::allocator<std::pair<std::string const, int> > > const&, std::string const&)'

There are three other instances of where this is happening. The function looks as follows:

Declaration

template < class Key, class Value >
bool CheckMapForExistingEntry( const std::map< Key, Value >& map, const std::string& key );

Definition

template < class Key, class Value >
bool CheckMapForExistingEntry( const std::map< Key, Value >& map, const std::string& key )
{

    typename std::map< Key, Value >::iterator it = map.lower_bound( key );

    bool keyExists = ( it != map.end && !( map.key_comp() ( key, it->first ) ) );

    if ( keyExists )
    {
        return true;
    }

    return false;
}

Thus, what is happening here? I have the header file included which contains the declaration of the function, and yet it still doesn’t work. According to this, I’m supposed to leave out the value of the template argument and just pass the key_type, however that refuses to work as well.

For example:

CheckMapForExistingEntry< std::string >( someMap, "somekey" ); //error
  • 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-28T17:42:59+00:00Added an answer on May 28, 2026 at 5:42 pm

    You can’t just easily split the declaration and the definition of templates between header and source file; thus templates are usually defined in headers. See e.g. “Why can templates only be implemented in the header file?”.

    Also you don’t need to explicitly provide any type parameters in this case:

    CheckMapForExistingEntry(m, "x");
    

    The types Key and Value can be automatically deduced from the map type.

    Note that your function can be significantly shortened, e.g.:

    template < class Key, class Value >
    bool contains(const std::map<Key, Value>& map, const std::string& key) {
        return map.find(key) != map.end();
    }
    

    Additionally you could generalize the type of the key parameter, making the function more reusable.

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

Sidebar

Related Questions

I m just starting using gwt and so far so good, however after reading
I'm developing a Mahjong-solitaire solver and so far, I'm doing pretty good. However, it
I have a book called Spring Recipes which seems very good so far, but
I have, in a div, a few hyperlinks. The number of hyperlinks, however, varies.
We started to use MongoDB at work. So far so good however I was
Quaternions are good for interpolate rotations between them. so far so good. If I
I've been cleaning up my code and so far so good, and I only
I am developing a website using asp.net, So far so good. the functionality does
I've been implementing MS Search Server 2010 and so far its really good. Im
As far as I understand WebRequest.PreAuthenticate is almost always good. If I enable it

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.