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

  • Home
  • SEARCH
  • 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 8831837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:24:00+00:00 2026-06-14T08:24:00+00:00

I’m trying to get a STL map in C++ working with custom scalar objects

  • 0

I’m trying to get a STL map in C++ working with custom scalar objects so that I can use the scalar class in a map for OpenCV. I’m getting the following error:

error: ‘template class std::map’ used without template parameters

and this is the template im using:

template<typename _Tp> class MyScalar_ : public Scalar_<_Tp>{
public:
    MyScalar_();
    MyScalar_(Scalar_<_Tp>& s){
        _s = s;
    };
    _Tp& operator[](const int idx){
        return _s[idx];
    }
    //std::less<_Tp>::operator()(const _Tp&, const _Tp&) const
    //this wont work if scalars are using doubles
    bool operator < (const MyScalar_<_Tp>& obj) const {
        double lhs,rhs;
        lhs = _s[0] + _s[1] + _s[2] + _s[3];
        rhs = _s[0] + _s[1] + _s[2] + _s[3];
        return lhs > rhs;
    }
    bool operator == (const MyScalar_<_Tp>& obj) const{
        bool valid = true;
        for(int i = 0;i<_s.size();i++){
            if(_s[i] != obj[i])
                return false;
        }
        return valid;
    }
    private:
        Scalar_<_Tp> _s;
};

I have std::map< MyScalar,Point > edgeColorMap; in my header file as well

the error above states that the line:

auto tempit = edgeColorMap.find(s);
    if(tempit != std::map::end){//found a color that this pixel relates to

fails at the if statement and I can’t figure out why??

  • 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-14T08:24:01+00:00Added an answer on June 14, 2026 at 8:24 am

    You need to use an iterator from the actual map instance:

    if(tempit != edgeColorMap.end()) {
    

    std::map::end() is just a normal function which returns an iterator or const_iterator to the element following the last element of the container.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.