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++/14571] New: Templates typedef:ed to a name still take template arguments.


g++ --version gives "g++ (GCC) 3.3.3 (Debian 20040306)"

If you give a template with template given, and typdef it to a name, this new
name can still be used like a template! It can take template parameters that
replace those given in the typedef. The following code will print print out 0.1,
which shows that the vector now is of type vector<float> and not vector<int>.

#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char *argv[])
{
  typedef vector<int> intvector;
  intvector<float> weird(1);

  weird[0] = 0.1;
  cerr << weird[0] << endl;
}

-- 
           Summary: Templates typedef:ed to a name still take template
                    arguments.
           Product: gcc
           Version: 3.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: d00freed at dtek dot chalmers dot se
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14571


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