Question: typedef in templates 
Author Message
 Question: typedef in templates

I have seen something like the following construction in the <functional>
header:

template < typename _A , typename _R >
struct ar
{
  typedef _A   a_type ;
  typedef _R   r_type ;

Quote:
} ;

What kind of a structure is it? Where is it useful (other than STL)?

In code fragment below, what kind of a variable is ar_ii_1?

typedef struct ar < int , int >      ar_ii ;
ar_ii    ar_ii_1 ;

I know it's a C++ language issue, not STL.
Please help.

Kroly Ladvnszky



Sun, 26 Dec 2004 17:50:22 GMT  
 Question: typedef in templates

Quote:
> I have seen something like the following construction in the
<functional>
> header:

> template < typename _A , typename _R >
> struct ar
> {
>   typedef _A   a_type ;
>   typedef _R   r_type ;
> } ;

> What kind of a structure is it? Where is it useful (other than STL)?

It is useful in any library that uses template metaprogramming, just
like STL does.

Quote:
> In code fragment below, what kind of a variable is ar_ii_1?

> typedef struct ar < int , int >      ar_ii ;
> ar_ii    ar_ii_1 ;

ar_ii_1 is of type ar_ii, which is ar<int, int>, which is a structure
with no members.
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken



Sun, 26 Dec 2004 23:52:21 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Template parameter conflicts with typedef in template argument

2. To typedef or not to typedef, that is the question

3. VC 7.1 seems to ignore typedef in template

4. typedef with template arguments...

5. VC++ 7.0 bug with typedef & template instantiation

6. typedef with template classes

7. How to combine typedef with template

8. templates, ::, and typedef

9. vector template and typedef

10. comp error: typedef + template

11. typedef to a template class

12. Simple question: Member function templates in template classes under VC++ 5.0

 

 
Powered by phpBB® Forum Software