implementing a templated struct within a templated struct

R

RA Scheltema

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
 
J

Jeff Schwab

RA said:
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( )
{
// ...
}
 
G

Gerrit Gruben

template <typename T>

template <size_t size>

void A<T>::B<size>::do_something_big()
 
R

RA Scheltema

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top