Implementation of forward_list (and compressed_pair)

Chris Fairles chris.fairles@gmail.com
Sun Oct 12 10:56:00 GMT 2008


>
> Well, admittedly, I had hoped a smaller, simpler, implementation...
>

With the spec where the two types are different, both not empty, what
happens to ctor overloading in this situation:

struct X {
  operator int() { return 1; }
  operator double() { return 2.0; }
};
int i;
X x;
__compressed_pair<int, double> p(i); // <- ok
__compressed_pair<int, double> p(x, x); // <- ok
__compressed_pair<int, double> p(x); // <- ambiguous

Is this the intended behavior? Could get rid of a whole specialization
(same type, not empty) if you take out the single-argument ctors that
cause the ambiguity (also brings it closer to matching the std::pair
interface).

Speaking of interfaces, should tuple's get, tuple_element, tuple_size
etc. be extended for __compressed_pair like they are for std::pair?

Chris



More information about the Libstdc++ mailing list