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.

Questions and answers begin here Logo Questions and answers begin here Logo
Sign InSign Up

Questions and answers begin here

Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Blog
  • Contact Us

error: ‘unordered_set’ is not a member of ‘std’

Home/ Questions/Q 266
Next
Answered
error: 'unordered_set' is not a member of 'std'
edouardmanche
edouardmanche Begginer

I am a newbie programmer trying to implement an unordered set data structure in my C++ code. However, I keep getting an “unordered_set is not a member of std” error message, preventing me from progressing any further. I have included the necessary header file of “unordered_set”, yet the error persists.
Here’s a sample of my code:

using namespace std;
int main()
{
unordered_set s;
s.insert(3);
s.insert(4);
s.insert(7);
cout << s.size() << endl; return 0; }

I expected this code to compile and print the size of the unordered set as 3. However, when I try to compile it using my compiler, I get the error message "unordered_set is not a member of std". What could be causing this error?
I have tried using a different compiler and even installing a new version of C++ on my computer, but the error message remains the same. Is there something I am missing or doing wrong? Any help would be greatly appreciated.

c#errorsstdSTLunordered_set
  • 58
  • 0 Followers
  • 1
  • Report
Leave an answer

Leave an answer
Cancel reply

Browse

2 Answers

  • Voted
  • Oldest
  • Recent
  • Random
  1. yuhyeon.k Teacher
    2018-06-21T22:32:29+00:00Added an answer about 5 years ago

    One possible approach to solve the issue of ‘unordered_set is not a member of std’ error is to include the proper header file that supports the unordered_set and other STL containers. The header file that needs to be included is . If this header file is not included in the code, then the compiler will not recognize any of the unordered_set functionalities and will throw an error.
    Sometimes, the error may also be due to using an older version of C++ standard that does not support unordered_set or other STL containers. In such cases, updating to a newer version of the C++ standard or using a different container type might be necessary.

    In any case, it is important to ensure that the correct header files are included, and the correct version of C++ standard is used to avoid such errors in the future.

    • 98
    • Reply
    • Share
      Share
      • Share onFacebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  2. Best Answer
    rixa666 Teacher
    2018-06-17T12:07:27+00:00Added an answer about 5 years ago

    Hello there!
    I understand that you’re having trouble with the error message you received saying ‘unordered_set’ is not a member of ‘std’. This error message generally appears when there is a problem with the code trying to use the unordered_set container type.
    In order to use the unordered_set, you must include the header file ``. This header provides the implementation of the unordered_set type as a part of the standard template library (STL). If this is already done, make sure that there are no typos or mistakes in the code.
    It’s also important to confirm that you’re compiling your code with a compiler that supports C++11 or higher. The unordered set was added in C++11, so if you are using an older version of C++, it will not work.
    If you are still experiencing problems after taking the above mentioned steps, it’s possible that there is some issue with the compiler or the environment you are working in. In this case, you should try to reinstall or update the compiler and also try to run the code on a different environment.
    Additionally, it’s possible that other parts of your code may be interfering with the proper usage of the unordered_set type. Therefore, it’s important to make sure your code is well-structured, properly implemented and free of syntax errors.
    I hope this answer helps you solve your problem with the ‘unordered_set’ error. If you have any further questions or concerns, feel free to ask. Good luck with your coding journey!

    • 35
    • Reply
    • Share
      Share
      • Share onFacebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  3. feersaantoss Begginer
    2018-06-26T17:39:24+00:00Added an answer about 5 years ago

    To resolve this issue, I suggest checking that the version of the C++ standard library you are using supports the `std::unordered_set` container. If you are using an older version that does not support it, you can upgrade to a newer version or use a different container that is supported by your library.

    Another possible reason for this error could be a typo in the name of the container. Double-check to make sure that you have spelled it correctly and included the necessary headers.

    In my experience, similar errors can be caused by conflicting headers or preprocessor directives. Try removing any unnecessary includes or directives and check that there are no naming conflicts.

    It may also be helpful to review the documentation and examples for the `std::unordered_set` container to ensure that you are using it correctly. Sometimes a small syntax error or misunderstanding of a concept can cause unexpected issues.

    • 34
    • Reply
    • Share
      Share
      • Share onFacebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  4. lavilena1028 Begginer
    2018-06-17T14:40:39+00:00Added an answer about 5 years ago

    If you are facing the issue of the “unordered_set” not being recognized, then you might be missing the header file where it is defined. You need to include the appropriate header file with the correct syntax in order to use this data structure. The header file you might need is if you are using C++ from version 11 onwards.

    It is a common mistake to forget to include the proper header files, especially if you are dealing with a large codebase. Moreover, different compilers might require some additional header files to be included to recognize certain features of the language. So, make sure that you are using the right version of the programming language and the correct compiler where “unordered_set” is recognized.

    In summary, to use unordered_set in your code, you need to include the header file, and use the syntax that is appropriate for the version of C++ you are using. Once you fix this issue, the “unordered_set” data structure should become available for use in your code.

    • 16
    • Reply
    • Share
      Share
      • Share onFacebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

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.