This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/12710] New: conversion function and subscript operator
- From: "andre dot maute at gmx dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Oct 2003 18:03:57 -0000
- Subject: [Bug c++/12710] New: conversion function and subscript operator
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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;
}