|
|
|
Casting and inheritance, oh my. | |
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] | |
If I feed the following to gcc 4.6.3:
#include <sstream>
class Y : public std::ostringstream {
public:
using std::ostringstream::operator<<;
};
Y y;
template<typename x> void cast(const x &z)
{
(std::ostringstream &)y << z;
}
template<typename x> void inherit(const x &z)
{
y << z;
}
int int_type;
char char_array[10];
I get the following results:
cast(int_type); // This compiles
inherit(int_type); // This compiles
cast(char_array); // This compiles
inherit(char_array); // Failure, gcc complains about an ambiguous overload.
Why does it matter, how the operator gets resolved?
Attachment:
pgp4to7xkiilh.pgp
Description: PGP signature