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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:03:07+00:00 2026-06-04T02:03:07+00:00

This is likely very simple. I have added an std::set<int> my_set; to my header

  • 0

This is likely very simple. I have added an std::set<int> my_set; to my header file for some class. Then, in that classes implementation, I try to insert into this set. As an example, just doing my_set.insert(1); This is not compiling, which is very strange behaviour. Here is my compiler error:

error C2663: 'std::_Tree<_Traits>::insert' : 4 overloads have no legal conversion for 'this' pointer

The file I included to use set is #include <set>. What have I done wrong? I have not called the set anywhere else in the code.

  • 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-04T02:03:08+00:00Added an answer on June 4, 2026 at 2:03 am

    Since you’re getting an error about this, but you’re trying to insert an int, I’m gonna go out on a limb here and guess you’re trying to do this in a const method.

    class A
    {
        std::set<int> my_set;
        void foo() 
        {
           my_set.insert(1); //OK
        }
        void foo() const
        {
           my_set.insert(1); //not OK, you're trying to modify a member
                             //std::set::insert is not const, so you can't call it
        }
    };
    

    Remove the const. It seems like the logical thing to do, since you’re modifying members.

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

Sidebar

Related Questions

This is more then likely a very simple question but I am completely stumped
I've been stuck on this likely very simple problem, but haven't gotten anywhere with
I realize this question is very likely to have been asked before, but I've
Since in log4j javadoc is WARNING: This version of JDBCAppender is very likely to
,This question is likely subjective, but a lot of grid Javascript plugins have come
I know this is most-likely a simple question but when you restore a database
Having coded JavaScript since 1996, I have a very simple issue which I could
I'm very new to Rails, so it's likely there's a simple concept here that
There is this simple function which I have used with C++ in the past
Summarization: (1) This is very likely to be a bug. However, I cannot say

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.