template

Discussion in 'C++' started by Fraser Ross, Sep 12, 2005.

  1. Fraser Ross

    Fraser Ross Guest

    I cannot compile this:
    template <typename T1=char,
    template <typename, typename> class T2=std::basic_ifstream>
    struct X {
    T2<T1, std::char_traits<T1> > inputFileStream_;
    T2<T1, std::char_traits<T1> >& UseInputFileStream() {
    return inputFileStream_;
    };
    };

    I get an internal compiler error with the function. Have I missed the word
    typename anywhere? The compiler would probably accept code without typename
    anyway. Is this a compiler bug?

    Fraser.
     
    Fraser Ross, Sep 12, 2005
    #1
    1. Advertising

  2. Fraser Ross

    Kai-Uwe Bux Guest

    Fraser Ross wrote:

    > I cannot compile this:
    > template <typename T1=char,
    > template <typename, typename> class T2=std::basic_ifstream>
    > struct X {
    > T2<T1, std::char_traits<T1> > inputFileStream_;
    > T2<T1, std::char_traits<T1> >& UseInputFileStream() {
    > return inputFileStream_;
    > };
    > };
    >


    Compiles fine with g++ after adding #include<iostream>.


    > I get an internal compiler error with the function. Have I missed the
    > word
    > typename anywhere? The compiler would probably accept code without
    > typename
    > anyway. Is this a compiler bug?


    "Internal compiler error" usually says the compiler died on you. In my book,
    that qualifies as a compiler bug.


    Best

    Kai-Uwe Bux
     
    Kai-Uwe Bux, Sep 12, 2005
    #2
    1. Advertising

  3. Fraser Ross

    Fraser Ross Guest

    "Kai-Uwe Bux"
    > "Internal compiler error" usually says the compiler died on you. In my

    book,
    > that qualifies as a compiler bug.


    Thats what I said too. I've had to put a workaround in my class templates.

    I was wondering why std::vector for instance has an allocator as a type
    parameter and not a template template parameter. Is it merely because
    template template parameters were not in the language or weren't widely
    supported?

    Fraser.
     
    Fraser Ross, Sep 12, 2005
    #3
    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. Chris Theis
    Replies:
    2
    Views:
    487
    Chris Theis
    Jul 24, 2003
  2. tom_usenet
    Replies:
    0
    Views:
    552
    tom_usenet
    Jul 24, 2003
  3. Replies:
    1
    Views:
    2,129
    Gianni Mariani
    Jun 8, 2007
  4. Peng Yu
    Replies:
    3
    Views:
    793
    Thomas J. Gritzan
    Oct 26, 2008
  5. nguillot
    Replies:
    5
    Views:
    539
Loading...

Share This Page