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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:02:37+00:00 2026-05-26T07:02:37+00:00

This error: error C2678: binary ‘=’ : no operator found which takes a left-hand

  • 0

This error:

error C2678: binary '=' : no operator found which takes a left-hand operand of type 'const std::string' (or there is no acceptable conversion)  c:\program files (x86)\microsoft visual studio 10.0\vc\include\utility  216

occurs on this function’s only line:

void Animation::AddAnimation(std::string name, AnimationFrameSet& animation) {
    _animations.insert(std::make_pair(name, animation));
}

_animations is a std::map<std::string, AnimationFrameSet>

AnimationFrameSet declares an operator=(…) and a copy constructor, but weirdly enough, the compiler says it fails on the attempted copying of const std::string…even though the string isn’t even being passed in as a const.

I can’t for the life of me figure out (or even remember! :P) why this is/should throwing/throw an error.

Thanks.

EDIT

The reason I’m a little confused why this is not working is that a different class uses a very similar implementation and it does not throw an error:

BITMAP* BitmapCache::GetBitmap(std::string filename) {
    //Return NULL if a bad filename was passed.
    if(filename.empty()) return NULL;
    if(exists(filename.c_str()) == false) return NULL;

    //Reduce incorrect results by forcing slash equality.
    filename = fix_filename_slashes(&filename[0]);

    //Clean the cache if it's dirty.
    CleanCache();

    //Search for requested BITMAP.
    MapStrBmpIter _iter = _cache.find(filename);

    //If found, return it.
    if(_iter != _cache.end()) return _iter->second;

    //Otherwise, create it, store it, then return it.
    BITMAP* result = load_bmp(filename.c_str(), NULL);
    if(result == NULL) return NULL;
    /*Similar insert line, a non-const std::string that was passed in is passed to a std::make_pair(...) function*/
    _cache.insert(std::make_pair(filename, result));
    return result;
}

typedefs:

typedef std::map<std::string, BITMAP*> MapStrBmp;
typedef MapStrBmp::iterator MapStrBmpIter;
  • 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-26T07:02:38+00:00Added an answer on May 26, 2026 at 7:02 am

    The reason why this is failing is because the std::map container you are using expects a const value as key value.

    Check the documentation of std::map here.

    Example:

    class TestClass
    {
    };
    
    std::map< const std::string, TestClass > myMap;
    std::pair< const std::string, TestClass > firstElement = std::make_pair("test", TestClass() );
    myMap.insert( firstElement );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Error: error C2678: binary '==' : no operator found which takes a left-hand operand
I have code like this: class Base { public: void operator = (const Base&
I have a std::map called 'prompts' which is declared like this: std::map<const int, wstring,
How do I fix this error? error C2668: 'std::_Tree<_Traits>::end' : ambiguous call to overloaded
This error just started popping up all over our site. Permission denied to call
This error seems to just pop up now and again. It is not restricted
This error message appears on a colleague's machine when he tries to launch a
This error message is driving me nuts. I'm getting it when using Html.ListBox and
Getting this error: 2009-09-03 12:44:02.307 xcodebuild[307:10b] warning: compiler 'com.apple.compilers.llvm.clang.1_0.analyzer' is based on missing compiler
Getting this error with jquery & jquery.form. Site has been live for awhile..upgraded to

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.