template depth problem
  Home FAQ Contact Sign in
Your Ad Here
comp.lang.c++.moderated only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.c++.moderated Profile…

 Up
template depth problem         


Author: Venkat
Date: May 8, 2008 20:30

Trying to have the following usage; however, gcc is not liking.

#include

namespace xyz {
class elem {
public:
typedef boost::shared_ptr elem_sptr;
};

}

#include

namespace abc {
template
class BaseContainer
{
typedef std::map Container;

// tried this too
//typedef std::map > Container;

typedef Container::iterator iterator;

Container c;
};
Show full article (0.78Kb)
4 Comments
Re: template depth problem         


Author: Dan Barbus
Date: May 9, 2008 07:43

On May 9, 6:30 am, Venkat yahoo.com> wrote:
> Trying to have the following usage; however, gcc is not liking.
>
> #include
>
> namespace xyz {
> class elem {
> public:
> typedef boost::shared_ptr elem_sptr;
>
> };
> }
>
> #include
>
> namespace abc {
> template
> class BaseContainer
> {
> typedef std::map Container; ...
Show full article (1.32Kb)
no comments
Re: template depth problem         


Author: David Pol
Date: May 9, 2008 07:43

On 9 mayo, 05:30, Venkat yahoo.com> wrote:
> Trying to have the following usage; however, gcc is not liking.
>
> #include
>
> namespace xyz {
> class elem {
> public:
> typedef boost::shared_ptr elem_sptr;
>
> };
> }
>
> #include
>
> namespace abc {
> template
> class BaseContainer
> {
> typedef std::map Container; ...
Show full article (1.62Kb)
no comments
Re: template depth problem         


Author: ciesizdz
Date: May 9, 2008 07:44

> Trying to have the following usage; however, gcc is not liking.
>
> ...
>
> Any thoughts on the usage?

Gcc is not even compiling this code so it is rather obvious it refuses
to link. ;)
I can spot 2 problems in this code. 1st of all -- your main function.
It should
always return an integer, not void. Another mistake is missing
typename keyword.
ObjectType::elem_sprt and Container::iterator depend on ObjectType
which is
template parameter. This is why you need to precede its definition
with typename.
Here's what needs to be changed:
Show full article (1.02Kb)
no comments
Re: template depth problem         


Author: Francis Glassborow
Date: May 9, 2008 07:44

Venkat wrote:
> Trying to have the following usage; however, gcc is not liking.
When seeking help it is always desirable that you give us as much
information as possible. At the very least indicate which line gcc was
rejecting and if possible the error message that it gave. I know that
error messages are sometimes very lengthy where templates are concerned
but it is usually possible identify what is being complained about at
least in general.
>
> #include
>
> namespace xyz {
> class elem {
> public:
> typedef boost::shared_ptr elem_sptr;
> };
>
That just renames boost::shared pointer in the scope of class elem.
elem_sptr will not be visible anywhere outside this class scope. Why did
you encapsulate the typedef in a class? ...
Show full article (1.70Kb)
no comments