template func in class question

From: Active8 (reply2group_at_ndbbm.net)
Date: 02/27/05

  • Next message: Jonathan Turkanis: "Re: template func in class question"
    Date: Sun, 27 Feb 2005 02:34:36 -0500
    
    

    I have an STL vector I pass to a function and I need to know what
    type data is in the vector when I'm in the fuction.

    class MyClass
    {
    template class<T>
            int Myfunc(T&){int i = sizeof(T);// oops - I want sizeof(float) }
    };

    vector<float> vec;
    MyClass mc;
    mc.Myfunc(vec)

    Is there any way to do this without writing separate functions for
    each type of data the vector might contain? And without a 2
    parameter template *class* like "template class<V, T>" ?

    Thanks in advance.

    -- 
    Best Regards,
    Mike
    

  • Next message: Jonathan Turkanis: "Re: template func in class question"

    Relevant Pages

    • Re: template func in class question
      ... Active8 wrote: ... > I have an STL vector I pass to a function and I need to know what ... > type data is in the vector when I'm in the fuction. ... > class MyClass ...
      (comp.lang.cpp)
    • Re: template func in class question
      ... >> I have an STL vector I pass to a function and I need to know what ... >> type data is in the vector when I'm in the fuction. ... I wish I could find my Osbourne C++ ref. ...
      (comp.lang.cpp)