Under the (false?) Impression that boost::container::flat_set was a replacement for std::set , I replaced set with flat_set where I expected the number of elements to be small and search performance more critical than inserts.
At a later stage, I was alerted by a confusing compilation error, which I eventually traced back to using flat_set as a member of the class.
For instance:
class Room { private: boost::container::flat_set<int> v; };
The following code will not compile, but works fine if I replace flat_set with std::set .
Room a; Room b = Room();
I see a compilation error:
error: no match for 'operator =' in 'a = Room ()'
note: candidate is:
note: Room & Room :: operator = (Room &)
note: no known conversion for argument 1 from 'Room' to 'Room &'
My questions:
- Is this error expected? If so, how do I get around it?
- How do the three operators in the code example differ from each other, and why only the last occurs?
- Why does the compiler complain about the assignment operator
Room , and not about flat_set ? Has flat_set used for the default operators generated for the class?
Full sample program:
source share