Re: A Newbie Question about template template template

Discussion in 'C++' started by Chris Theis, Jul 22, 2003.

  1. Chris Theis

    Chris Theis Guest

    "DarkSpy" <> wrote in message
    news:...
    > #include <vector>
    > using namespace std;
    >
    > template <template <typename T> class B1,
    > template <template<typename T> class B2> class B3> class CX
    > {};
    > main()
    > {
    > CX<vector, vector<vector> > c;


    Just to make sure - what you want to achieve is a template class with 2
    template parameters like this code should indicate?

    > }
    >

    [SNIP]

    > can i make 2 arguments with template class ?

    Yes.

    > is this code correct ?


    No!

    If you want to have a class with 2 template parameters you have to write:

    template< typename T1, typename T2 >
    class CX
    {
    };

    This means you can do the following for example:

    int main()
    {
    CX<vector<int>, vector<vector<int> > > c;

    return true;
    }

    HTH
    Chris
     
    Chris Theis, Jul 22, 2003
    #1
    1. Advertising

  2. Chris Theis

    DarkSpy Guest

    thanx Chris

    maybe my question is not explicitly.

    i means:

    can i wrote template arguments in template template argument like my code.

    template <template <template <typename> class T> class U>
    class CX {};
    ......

    how many nested template arguments in template template argument ?

    thank you.

    "Chris Theis" <> wrote in message news:<bfjabs$fk2$>...
    > "DarkSpy" <> wrote in message
    > news:...
    > > #include <vector>
    > > using namespace std;
    > >
    > > template <template <typename T> class B1,
    > > template <template<typename T> class B2> class B3> class CX
    > > {};
    > > main()
    > > {
    > > CX<vector, vector<vector> > c;

    >
    > Just to make sure - what you want to achieve is a template class with 2
    > template parameters like this code should indicate?
    >
    > > }
    > >

    > [SNIP]
    >
    > > can i make 2 arguments with template class ?

    > Yes.
    >
    > > is this code correct ?

    >
    > No!
    >
    > If you want to have a class with 2 template parameters you have to write:
    >
    > template< typename T1, typename T2 >
    > class CX
    > {
    > };
    >
    > This means you can do the following for example:
    >
    > int main()
    > {
    > CX<vector<int>, vector<vector<int> > > c;
    >
    > return true;
    > }
    >
    > HTH
    > Chris
     
    DarkSpy, Jul 23, 2003
    #2
    1. Advertising

  3. Chris Theis

    Chris Theis Guest

    "DarkSpy" <> wrote in message
    news:...
    > thanx Chris
    >
    > maybe my question is not explicitly.
    >
    > i means:
    >
    > can i wrote template arguments in template template argument like my code.
    >
    > template <template <template <typename> class T> class U>
    > class CX {};
    > .....
    >
    > how many nested template arguments in template template argument ?
    >
    > thank you.
    >


    You can use template arguments in template template declarations. I tried
    this up to 5 levels of complexity though the question that arises is if it
    makes sense! Furthermore you should be aware that not all compilers support
    this feature yet!

    HTH
    Chris
     
    Chris Theis, Jul 24, 2003
    #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. tom_usenet
    Replies:
    0
    Views:
    540
    tom_usenet
    Jul 24, 2003
  2. Jerry C.
    Replies:
    8
    Views:
    252
    Uri Guttman
    Nov 23, 2003
  3. Kruno Saho
    Replies:
    0
    Views:
    147
    Kruno Saho
    Apr 7, 2013
  4. Dave Angel
    Replies:
    0
    Views:
    128
    Dave Angel
    Apr 7, 2013
  5. rusi
    Replies:
    0
    Views:
    115
Loading...

Share This Page