[Bug c++/12710] New: conversion function and subscript operator
andre dot maute at gmx dot de
gcc-bugzilla@gcc.gnu.org
Tue Oct 21 18:34:00 GMT 2003
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12710
Summary: conversion function and subscript operator
Product: gcc
Version: 3.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: andre dot maute at gmx dot de
CC: gcc-bugs at gcc dot gnu dot org
perhaps i need some language lawyers here,
why does the section with comments not compile?
i searched the standard but found nothing, but that may also mean nothing.
i want to simulate an array, in order not to change many lines of code.
so i extracted the following code snippet.
best regards
andre
-------------------------------------------------------------------------
#include <iostream>
class A {
public:
int operator[]( int n ) {
return 42;
}
};
class B {
public:
A a;
public:
operator A&() {return a;};
};
int main() {
B b;
// // does not compile
// std::cout << b[1] << std::endl;
A& aa = b;
std::cout << aa[1] << std::endl;
return 0;
}
More information about the Gcc-bugs
mailing list