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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:29:48+00:00 2026-06-12T12:29:48+00:00

I declared std: map below: std::map<std::string, std::set<unsigned char*>> FilesMap; int InsertData(unsigned char* name) {

  • 0

I declared std: map below:

std::map<std::string, std::set<unsigned char*>> FilesMap;

int InsertData(unsigned char* name)
{
  // here i try to insert pair with name above and clear std::set
   FilesMap.insert(std::pair<std::string, std::set<unsigned char*>>(std::string((char*)name), std::set<unsigned char*>()));
}

But I have many errors like:

Error 16 error C2676: binary ‘<‘: ‘const std::string’ does not define
this operator or a conversion to a type acceptable to the predefined
operator c: \program files (x86)\microsoft Visual Studio
10.0\vc\include\xfunctional

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-06-12T12:29:49+00:00Added an answer on June 12, 2026 at 12:29 pm

    First of all, this horribly long line

    FilesMap.insert(std::pair<std::string, std::set<unsigned char*>>(std::string((char*)name), std::set<unsigned char*>()));
    

    can be simplified if you use std::make_pair function, which will deduce template arguments.

    FilesMap.insert(std::make_pair(std::string(reinterpret_cast<char*>name)), std::set<unsigned char*>()));
    

    Second, you could make a typedef for your set so as to simplify the above line even more

    typedef std::set<unsigned char*> mySetType;
    std::map<std::string, mySetType>> FilesMap;
     FilesMap.insert(std::make_pair(std::string(reinterpret_cast<char*>name)), MySetType()));
    

    And lastly, and most importantly, I believe the reason that the compiler is unable to find a suitable operator < for std::string is that you forgot to #include<string>

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

Sidebar

Related Questions

I have a map of pointer to member declared as : std::map<char, T (Operand::*)(const
I have a structure like struct category { int id,newID; std::string name; }; and
I am trying to insert into an unordered_map with a std::set value declared as
I have a std::map called 'prompts' which is declared like this: std::map<const int, wstring,
I have a multimap declared as: typedef multimap <int, std::string> MM; I was having
unordered_map<std::string,unordered_map<std::string, std::string> >* storing_vars; I have this variable in the scope declared in the
I have the following cyclic dependency problem I am trying to solve: typedef std::map<int,
When I try to compile this: #include <map> #include <string> template <class T> class
So, I'm using a std::map as an associative array. The map is declared as
I have something like this: #include <iostream> #include <map> int main() { std::map<int, int*>

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.