3

I have:

auto my_vec2 = boost::fusion::make_vector(42,false,42);
auto my_set2 = boost::fusion::as_set(my_vec2);

and when I go to debug I was expecting my_set2 to only contain 42 and false, however it contained 42 twice. Why is this? If its a set surely the "keys" should be unique?

user997112
  • 29,025
  • 43
  • 182
  • 361

1 Answers1

5

It’s your responsibility:

Precondition: There may be no duplicate key types.

(from this doc)

Nate
  • 18,752
  • 8
  • 48
  • 54
  • Ok just got one small question i forgot to ask- a set stores sorted values. If the fusion set contained different types, say an int and then a reference to an object- how would it sort the object reference, based on the memory address? – user997112 Dec 18 '13 at 00:15
  • 1
    They just aren’t sorted. “Like associative sequences in MPL, and unlike associative containers in STL, Fusion associative sequences have no implied ordering relation.” (and the Fusion `set` is defined as an Associative Sequence). Confusion understandable because it works differently than STL! – Nate Dec 18 '13 at 00:17
  • Ok so my confusion is this- what is the purpose of using a set which doesn't guarantee uniqueness and doesn't sort the values? (Sorry not being ignorant, just genuinely puzzled) – user997112 Dec 18 '13 at 00:22
  • 1
    Not sure? The set does seem crippled, but it may be the best they could do given the constraint that it has to support heterogeneous data types. – Nate Dec 18 '13 at 00:25