Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > implementing a templated struct within a templated struct

Reply
Thread Tools

implementing a templated struct within a templated struct

 
 
RA Scheltema
Guest
Posts: n/a
 
      01-06-2004
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


 
Reply With Quote
 
 
 
 
Jeff Schwab
Guest
Posts: n/a
 
      01-06-2004
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( )
{
// ...
}

 
Reply With Quote
 
 
 
 
Gerrit Gruben
Guest
Posts: n/a
 
      01-06-2004
template <typename T>

template <size_t size>

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


 
Reply With Quote
 
RA Scheltema
Guest
Posts: n/a
 
      01-06-2004
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][s][p]@[m]dacolian.nl> schreef in
bericht news:3ffa916f$0$314$(E-Mail Removed)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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET Templated User Controls - Limit child controls allowable within a templated control JohnyStyles@gmail.com ASP .Net 0 05-29-2006 06:00 PM
Different methods of implementing variable-length templated classes Chris Jefferson C++ 0 02-26-2005 05:12 PM
Implementing a templated "round" function? Jef Driesen C++ 6 10-21-2004 02:34 PM
Dynamically added Templated Columns (Implementing ITemplate) in DataGrid - How do I wire up events? David ASP .Net Datagrid Control 5 02-18-2004 08:28 AM
Subtypes of templated types (in templated functions) Marijn C++ 5 02-13-2004 09:50 AM



Advertisments