usage of keyword template / standard

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alexander Stippler

    usage of keyword template / standard

    Hi,

    I'm not quite sure if I have to use the keyword template in a situation,
    where my compiler enforces it, though I think it is not neccessary. My
    question is: Who is wrong with respect to the standard - the compiler or I?

    template <typename T>
    struct A
    {
    template <typename C>
    bool
    test();

    static size_t value = sizeof(A<T>::te st<T>());
    };

    Do I need to qualify test by 'template'. IMO no.
    It would be different in a context like
    sizeof(T::templ ate test<T>())
    Am I wrong?

    regards,
    alex
  • Attila Feher

    #2
    Re: usage of keyword template / standard

    Alexander Stippler wrote:[color=blue]
    > Hi,
    >
    > I'm not quite sure if I have to use the keyword template in a
    > situation, where my compiler enforces it, though I think it is not
    > neccessary. My question is: Who is wrong with respect to the standard
    > - the compiler or I?
    >
    > template <typename T>
    > struct A
    > {
    > template <typename C>
    > bool
    > test();
    >
    > static size_t value = sizeof(A<T>::te st<T>());
    > };
    >
    > Do I need to qualify test by 'template'. IMO no.
    > It would be different in a context like
    > sizeof(T::templ ate test<T>())
    > Am I wrong?[/color]

    You are. A<T> is also dependent on T.

    --
    Attila aka WW


    Comment

    • Attila Feher

      #3
      Re: usage of keyword template / standard

      Attila Feher wrote:
      [SNIP][color=blue][color=green]
      >> template <typename T>
      >> struct A
      >> {
      >> template <typename C>
      >> bool
      >> test();
      >>
      >> static size_t value = sizeof(A<T>::te st<T>());
      >> };
      >>
      >> Do I need to qualify test by 'template'. IMO no.
      >> It would be different in a context like
      >> sizeof(T::templ ate test<T>())
      >> Am I wrong?[/color]
      >
      > You are. A<T> is also dependent on T.[/color]

      From the standard, where it says what is dependent:

      — a templateid in which either the template name is a template parameter or
      any of the template arguments is a dependent type or an expression that is
      typedependent
      or valuedependent.

      Clearly A is a template ID and the template argument is clearly a dependent
      type.

      --
      Attila aka WW


      Comment

      Working...