Templates: Members Vs. non-members

Discussion in 'C++' started by Dave, Aug 10, 2004.

  1. Dave

    Dave Guest

    Hello all,

    Are the rules for templated member functions different in any way than the
    rules for templated non-member functions?

    How about templated member classes Vs. templated non-member classes?

    Thanks,
    Dave
     
    Dave, Aug 10, 2004
    #1
    1. Advertising

  2. "Dave" <> wrote...
    > Are the rules for templated member functions different in any way than the
    > rules for templated non-member functions?


    Rules? Different? I can't recall any, really.

    > How about templated member classes Vs. templated non-member classes?


    Hmm... No.

    Why do you ask? Have you run into a problem?

    V
     
    Victor Bazarov, Aug 10, 2004
    #2
    1. Advertising

  3. Dave

    Dave Guest

    "Victor Bazarov" <> wrote in message
    news:CRURc.120348$eM2.35007@attbi_s51...
    > "Dave" <> wrote...
    > > Are the rules for templated member functions different in any way than

    the
    > > rules for templated non-member functions?

    >
    > Rules? Different? I can't recall any, really.
    >
    > > How about templated member classes Vs. templated non-member classes?

    >
    > Hmm... No.
    >
    > Why do you ask? Have you run into a problem?
    >
    > V
    >
    >


    Nope. I'm just preparing a presentation and am checking multiple sources to
    make sure I'm giving accurate information.
     
    Dave, Aug 10, 2004
    #3
  4. Dave

    tom_usenet Guest

    On Mon, 9 Aug 2004 16:04:31 -0700, "Dave" <>
    wrote:

    >Hello all,
    >
    >Are the rules for templated member functions different in any way than the
    >rules for templated non-member functions?


    Well, of course, since the rules for member functions are different
    from the rules for non-member functions, in terms of overloading,
    constness, declarations and definitions, etc.

    >How about templated member classes Vs. templated non-member classes?


    You can't specialize a member template of a class template without
    fully specializing the class template, but I'm not sure you'd call
    that a difference.

    When specifying member templates that are dependent names, you need to
    use "template" to disambiguate. e.g. to call a template member
    function specialization "foo" of a dependently typed object t you need
    to do this:

    t.template foo<int>();

    Tom
     
    tom_usenet, Aug 10, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fred
    Replies:
    1
    Views:
    605
    Neredbojias
    Sep 26, 2005
  2. John Harrison

    using templates in templates

    John Harrison, Jul 31, 2003, in forum: C++
    Replies:
    8
    Views:
    386
    Torsten Curdt
    Jul 31, 2003
  3. JKop
    Replies:
    3
    Views:
    479
  4. Derek
    Replies:
    3
    Views:
    437
    Derek
    Jan 20, 2005
  5. recover
    Replies:
    2
    Views:
    813
    recover
    Jul 25, 2006
Loading...

Share This Page