<div dir="ltr"><br><br><div class="gmail_quote">On Wed, Aug 25, 2010 at 1:53 PM, Oleg Goldshmidt <span dir="ltr"><<a href="mailto:pub@goldshmidt.org">pub@goldshmidt.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
2010/8/25 Erez D <<a href="mailto:erez0001@gmail.com">erez0001@gmail.com</a>>:<br>
<div class="im">><br>
><br>
> On Wed, Aug 25, 2010 at 12:08 PM, Elazar Leibovich <<a href="mailto:elazarl@gmail.com">elazarl@gmail.com</a>><br>
> wrote:<br>
>><br>
>> template <class a, class b><br>
>><br>
>> class c<br>
>><br>
>> {<br>
>><br>
>> private:<br>
>><br>
>> b defaultVal;<br>
>><br>
>> public:<br>
>><br>
>> std::map<a,b> mymap;<br>
>><br>
>><br>
>> const b &func(a idx)<br>
>><br>
>> {<br>
>><br>
>> typename std::map<a,b>::iterator it(mymap.find(idx));<br>
>><br>
>> if (it!=mymap.end())<br>
>><br>
>> return it->second;<br>
>><br>
>> else<br>
>><br>
>> return defaultVal;<br>
>><br>
>> }<br>
>><br>
>> };<br>
>><br>
>> The compiler is not sure std::map<a,b>::iterator is a typename or a value.<br>
><br>
> how do i sove that ? can you give a solution ?<br>
<br></div></blockquote><div><br>oops, you are correct.<br> <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">
</div>I think you missed the fact that Elazar gave a solution - the above is<br>
NOT identical to what you sent:<br>
<br>
1. uses the proper argument (idx, not a) to find()<br></blockquote><div>sure, this was a typo <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
2. adds typename<br></blockquote><div>yep, this fixed it <br></div><div><br>thanks,<br>erez. <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<font color="#888888">
<br>
--<br>
Oleg Goldshmidt | <a href="mailto:pub@goldshmidt.org">pub@goldshmidt.org</a><br>
</font></blockquote></div><br></div>