Re: C++ templates

From: Mike Nordell (tamlin_at_algonet.se)
Date: Thu Mar 11 2004 - 13:57:45 EST

  • Next message: Dom Lachowicz: "Re: C++ templates"

    Martin wrote:

    > Can an MSVC developer test a fraction of what you attempt first?

    VC6 handles templates reasonably well, so long as one stays out of some more
    esoteritc aspects of it.

    What worries me a bit is that I just now (only a few minutes ago) checked
    what kind of code GCC generates for template functions, and I must say what
    I found will probably haunt me in my dreams tonight. No matter what
    combination of flags I gave the compiler could it seemingly produce anything
    that even reminded of sensible, inlined code. More on this below.

    > There is folklore that says MSVC doesn't do templates. I just want to be
    > sure before you launch into this.

    IIRC VC5 had some serious problems. I've been using templates in VC6 for
    over half a decade now.

    > But as a general point I really like the idea. C++ is a type-safe
    > language. It sucks that we spend so much effort deliberately not using
    > this feature because we cast to void * for vectors.

    Then I must ask - why reinvent the wheel over and over again, and not just
    start using e.g. std::vector? If that's not suitable, at least give the
    current vector class a standard C++ container interface? Need a stack?
    std::stack. Just an idea.

    Hub, before embarking on this journey, would you mind making a small test.
    I've already thrown away the test code, but it went something like:

      extern const int* src1;
      extern const int* src2;
      extern int* dest;
      extern size_t count;
      std::transform(src1, src1+count, src2, dest, std::plus<int>());

    It theoretically could have been me not throwing enough flags at GCC (but
    at -O3 I don't think I should have to), but the code generated was ... If I
    try to be polite I could define it as "suboptimal".

    /Mike



    This archive was generated by hypermail 2.1.4 : Thu Mar 11 2004 - 13:58:08 EST