This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/12710] New: conversion function and subscript operator


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; 
 
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]