When submitting a solution in C++, please select either C++14 (GCC 6-32) or C++17 (GCC 7-32) as your compiler. ×

robell's blog

By robell, history, 3 years ago, In English
Recently, I came across this snippet of code:
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

which implements a policy based data structure. Yet when I ran it on VS code on my Mac(pls don't judge), the code kept on giving me errors stating that "assoc_container.hpp not found" ect.. I searched online for the source code for the ext folder that assoc_container is located in yet the only thing that I could find is this link which doesn't contain a pb_ds folder. For the people who use policy based data structures, do you guys know whether there is anything I can do so that I'm able to implement these policy based data structures?

PS:I've looked at this blog post Post,but I wasn't gain a verifiable answer on what to do since I'm small brained. I also compile my code with "gcc --std=c++17 $x -o $lol" where $x is the file name of the cpp file and $lol is the output file name.

  • Vote: I like it
  • +1
  • Vote: I do not like it

| Write comment?
»
3 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

brew install gcc

And alias the newly downloaded g++ (if you do it now, it's g++-11) in use/local/bin to g++ and run g++ A.cpp and you should be fine.

If things go crazy and it still doesn't work, go to usr/local/bin and delete g++/c++ directories and re run the command.