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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:41:40+00:00 2026-05-11T19:41:40+00:00

I’m going to extend the existing std::map class and add a new function to

  • 0

I’m going to extend the existing std::map class and add a new function to it:

template<typename key_type, typename value_type>
class CleanableMap : public Cleanable, public std::map<key_type, value_type> 
{
    CleanableMap(const CleanableMap& in); //not implemented
    CleanableMap& operator=(const CleanableMap& in); //not implemented
public:
    CleanableMap() {}
    CleanableMap(const std::map<key_type, value_type>& in) { *this = in; }
    virtual ~CleanableMap() {}
    std::map<key_type, value_type>& operator=(const std::map<key_type, value_type>& in)
    {
        *((std::map<key_type, value_type>*)this) = in;
        return *this;
    }
};

I’ve got a copy constructor and assignment operator such that I can simply assign an existing std::map of the same type to my new map:

CleanableMap<DWORD, DWORD> cm;
std::map<DWORD, DWORD> stdm;
cm = stdm;

The problem is, the compiler is complaining with an error that doesn’t make sense — I’ve explicitly coded for what it’s complaining about:

1>c:\dev\proj\commonfunc.cpp(399) : error C2679: binary '=' : no operator found which takes a right-hand operand of type 'std::map<_Kty,_Ty>' (or there is no acceptable conversion)
1>        with
1>        [
1>            _Kty=DWORD,
1>            _Ty=DWORD
1>        ]
1>        c:\dev\proj\templates.h(245): could be 'CleanableMap<key_type,value_type> &CleanableMap<key_type,value_type>::operator =(const CleanableMap<key_type,value_type> &)'
1>        with
1>        [
1>            key_type=DWORD,
1>            value_type=DWORD
1>        ]
1>        c:\dev\proj\templates.h(250): or       'std::map<_Kty,_Ty> &CleanableMap<key_type,value_type>::operator =(const std::map<_Kty,_Ty> &)'
1>        with
1>        [
1>            _Kty=unsigned long,    <--- where did it come up with that?
1>            _Ty=std::pair<const DWORD,DWORD>,  <--- where did it come up with that?
1>            key_type=DWORD,
1>            value_type=DWORD
1>        ]
1>        while trying to match the argument list '(CleanableMap<key_type,value_type>, std::map<_Kty,_Ty>)'
1>        with
1>        [
1>            key_type=DWORD,
1>            value_type=DWORD
1>        ]
1>        and
1>        [
1>            _Kty=DWORD,
1>            _Ty=DWORD
1>        ]

There ‘could be’ it mentions on line 245 doesn’t make sense — there is no assignment operator like that (well, it’s private. Removing it completely doesn’t change anything).

The ‘could be’ it mentions on line 250 is the assignment operator that I defined, but it was somehow deduced some other non-matching template types. Where did it get those??

Help!!! 🙂

  • 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-11T19:41:40+00:00Added an answer on May 11, 2026 at 7:41 pm

    Adding onto Neil’s answer.

    One concrete reason you should not be deriving from std::map is that it does not have a virtual destructor. This means you simply cannot guarantee any resources you allocate as a part of your map will be freed during the destruction of your implementation via a std::map pointer.

    std::map<int,int>* pMap = GetCleanableMap();
    ...
    delete pMap; // does not call your destructor
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 149k
  • Answers 149k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Also getting the same problem Code: Intent emailIntent = new… May 12, 2026 at 9:31 am
  • Editorial Team
    Editorial Team added an answer Try overflow-x: auto; It even works in IE6! May 12, 2026 at 9:31 am
  • Editorial Team
    Editorial Team added an answer To start you could take a look at this post… May 12, 2026 at 9:31 am

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am currently running into a problem where an element is coming back from
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.