templated class implementation in C

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Default User

    #16
    Re: templated class implementation in C

    jamihuq wrote:
    [color=blue]
    > Oops, I meant Marcus[/color]

    What is this supposed to mean? Read the information in my .sig.



    Brian

    --
    Please quote enough of the previous message for context. To do so from
    Google, click "show options" and use the Reply shown in the expanded
    header.

    Comment

    • benben

      #17
      Re: templated class implementation in C

      > Try this guy. I think he tried it once upon a time.[color=blue]
      >
      > http://public.research.att.com/~bs/homepage.html
      >[/color]

      I thought he tried it before templates came into C++ :)

      Ben

      Comment

      • jamihuq

        #18
        Re: templated class implementation in C

        Oh, and here is the answer from Stroustrup himself:
        *************** *************** *************** *************** *************** ***********
        template<class T> struct X { T a; void f(T); };

        X<int> x; f(x);

        struct X_int { int a; void f(int); };
        X_int x; f(x);

        You might be interested in the C++ standard committee's report on
        performance (see my C++ page). I explains some of the implementation
        techniques.
        *************** *************** *************** *************** *************** *************** *
        I figured this is a way to implement templates, but I just wanted to
        make sure from the man that wrote C++. Goes to show, the ones that
        shout the most and use profanity are usually the monkeys that can't
        even peel a banana.

        ..

        Comment

        • Ben Pope

          #19
          Re: templated class implementation in C

          jamihuq wrote:[color=blue]
          > Oh, and here is the answer from Stroustrup himself:
          > *************** *************** *************** *************** *************** ***********
          > template<class T> struct X { T a; void f(T); };
          >
          > X<int> x; f(x);
          >
          > struct X_int { int a; void f(int); };
          > X_int x; f(x);
          >
          > You might be interested in the C++ standard committee's report on
          > performance (see my C++ page). I explains some of the implementation
          > techniques.
          > *************** *************** *************** *************** *************** *************** *
          > I figured this is a way to implement templates, but I just wanted to
          > make sure from the man that wrote C++. Goes to show, the ones that
          > shout the most and use profanity are usually the monkeys that can't
          > even peel a banana.[/color]

          The whole purpose of templates is so that you don't have to repeat the
          same thing for each type.

          If you class manually repeating the same code for each type templates in
          C, then yes. Well done.

          C does not have language support for templates. C does not have support
          for classes.

          Yes, with effort (lots of it) you can mimic some of the concepts, but
          that's not the point.

          Ben Pope
          --
          I'm not just a number. To many, I'm known as a string...

          Comment

          • jamihuq

            #20
            Re: templated class implementation in C

            In real life, everything is not supposed to be straight forward. If you
            are programming in an embedded environment, sometimes you don't have
            the luxury of getting an OS that supports C++. And if the OS does
            support C++, it is incomplete.

            Comment

            Working...