what does g++ want from my code
Erez D
erez0001 at gmail.com
Wed Aug 25 14:40:06 IDT 2010
On Wed, Aug 25, 2010 at 1:53 PM, Oleg Goldshmidt <pub at goldshmidt.org> wrote:
> 2010/8/25 Erez D <erez0001 at gmail.com>:
> >
> >
> > On Wed, Aug 25, 2010 at 12:08 PM, Elazar Leibovich <elazarl at gmail.com>
> > wrote:
> >>
> >> template <class a, class b>
> >>
> >> class c
> >>
> >> {
> >>
> >> private:
> >>
> >> b defaultVal;
> >>
> >> public:
> >>
> >> std::map<a,b> mymap;
> >>
> >>
> >> const b &func(a idx)
> >>
> >> {
> >>
> >> typename std::map<a,b>::iterator it(mymap.find(idx));
> >>
> >> if (it!=mymap.end())
> >>
> >> return it->second;
> >>
> >> else
> >>
> >> return defaultVal;
> >>
> >> }
> >>
> >> };
> >>
> >> The compiler is not sure std::map<a,b>::iterator is a typename or a
> value.
> >
> > how do i sove that ? can you give a solution ?
>
>
oops, you are correct.
> I think you missed the fact that Elazar gave a solution - the above is
> NOT identical to what you sent:
>
> 1. uses the proper argument (idx, not a) to find()
>
sure, this was a typo
> 2. adds typename
>
yep, this fixed it
thanks,
erez.
>
> --
> Oleg Goldshmidt | pub at goldshmidt.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.cs.huji.ac.il/pipermail/linux-il/attachments/20100825/c31b2fc9/attachment.html>
More information about the Linux-il
mailing list