implementing a templated struct within a templated struct

Discussion in 'C++' started by RA Scheltema, Jan 6, 2004.

  1. RA Scheltema

    RA Scheltema Guest

    hi all,


    Basically I have the following situation in my header-file:

    ---
    ....

    template <typename ta_type>
    struct A
    {
    template<size_t ta_size>
    struct B
    {
    inline void do_something_big();
    };
    };

    #include "A.inl"

    ....
    ---


    The function do_something_big contains quite a lot of code and for obvious
    keeping it clean reasons I want to implement this function in the .inl file.

    My question is, how would I do this. First of all I'm thinking I will get
    stuck with the

    A::B::do_something_big

    definition, but next to this I have two template definitions to make before
    I can even start with typing this !

    Is this at all possible ?



    kind regards,
    richard
     
    RA Scheltema, Jan 6, 2004
    #1
    1. Advertising

  2. RA Scheltema

    Jeff Schwab Guest

    RA Scheltema wrote:
    > hi all,
    >
    >
    > Basically I have the following situation in my header-file:
    >
    > ---
    > ...
    >
    > template <typename ta_type>
    > struct A
    > {
    > template<size_t ta_size>
    > struct B
    > {
    > inline void do_something_big();
    > };
    > };
    >
    > #include "A.inl"
    >
    > ...
    > ---
    >
    >
    > The function do_something_big contains quite a lot of code and for obvious
    > keeping it clean reasons I want to implement this function in the .inl file.
    >
    > My question is, how would I do this. First of all I'm thinking I will get
    > stuck with the
    >
    > A::B::do_something_big
    >
    > definition, but next to this I have two template definitions to make before
    > I can even start with typing this !
    >
    > Is this at all possible ?
    >
    >
    >
    > kind regards,
    > richard
    >
    >


    If you know it's "big," why are you declaring it inline?

    Anyway, it's worse than A::B::do_something_big( ). Try this:

    template< typename ta_type >
    template< size_t ta_size >
    void A<ta_type>::B<ta_size>::do_something_big( )
    {
    // ...
    }
     
    Jeff Schwab, Jan 6, 2004
    #2
    1. Advertising

  3. template <typename T>

    template <size_t size>

    void A<T>::B<size>::do_something_big()
     
    Gerrit Gruben, Jan 6, 2004
    #3
  4. RA Scheltema

    RA Scheltema Guest

    hi there,

    been reading some visual c++ docs (the compiler of my choice :( ...) and
    just found out that this construction isn't possible there. stupid of me to
    expect that visual c++ could do something useful :). anyway, the largeness
    of the code is of course relative. I just thought it cleaner to put it in
    some outside implementation as not to clutter up my header, but alas


    thanks for the reactions
    richard


    "RA Scheltema" <r.a.scheltema[viral][p]@[m]dacolian.nl> schreef in
    bericht news:3ffa916f$0$314$4all.nl...
    > hi all,
    >
    >
    > Basically I have the following situation in my header-file:
    >
    > ---
    > ...
    >
    > template <typename ta_type>
    > struct A
    > {
    > template<size_t ta_size>
    > struct B
    > {
    > inline void do_something_big();
    > };
    > };
    >
    > #include "A.inl"
    >
    > ...
    > ---
    >
    >
    > The function do_something_big contains quite a lot of code and for obvious
    > keeping it clean reasons I want to implement this function in the .inl

    file.
    >
    > My question is, how would I do this. First of all I'm thinking I will get
    > stuck with the
    >
    > A::B::do_something_big
    >
    > definition, but next to this I have two template definitions to make

    before
    > I can even start with typing this !
    >
    > Is this at all possible ?
    >
    >
    >
    > kind regards,
    > richard
    >
    >
     
    RA Scheltema, Jan 6, 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. Marijn
    Replies:
    5
    Views:
    465
    Marijn
    Feb 13, 2004
  2. Jef Driesen
    Replies:
    6
    Views:
    445
    Jef Driesen
    Oct 21, 2004
  3. Chris Jefferson
    Replies:
    0
    Views:
    329
    Chris Jefferson
    Feb 26, 2005
  4. Replies:
    0
    Views:
    2,235
  5. David
    Replies:
    5
    Views:
    274
    Jeffrey Tan[MSFT]
    Feb 18, 2004
Loading...

Share This Page