default template

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

    default template

    Let's say I have a template

    template<int S = 4096>
    struct A {
    ....
    }

    why can't be used as just A? For example, see the following program (which
    doesn't compile because "A" is used instead, of A<10>, for instance):

    template <int S=4096struct A { enum {size = S}; };

    int main(int argc, char* argv[]) {
    printf("%d\n",A ::size);
    }

    Thanks, Kev



  • White Wolf

    #2
    Re: default template

    "kvnil" <kvnil@mail.ruw rote:
    Let's say I have a template
    >
    template<int S = 4096>
    struct A {
    ...
    }
    >
    why can't be used as just A? For example, see the following program (which
    doesn't compile because "A" is used instead, of A<10>, for instance):
    >
    template <int S=4096struct A { enum {size = S}; };
    >
    int main(int argc, char* argv[]) {
    printf("%d\n",A ::size);
    }
    A template instance's name always have to have those angle brackets. I may
    write now something completely stupid (I have never needed a template with
    all params defaulted), but I think that the instance of that template should
    be called: A<>, so your expression is A<>::size...

    Attila


    Comment

    Working...