<span style="color:rgb(34,34,34);font-size:14px;font-family:arial,sans-serif">I suffer a problem when using std::map in clang. I compile it in clang 3.3 under ubuntu 12.04, and the problem is also in clang 3.0.</span><div style="color:rgb(34,34,34);font-size:14px;font-family:arial,sans-serif">
The codes like follows (also in attachment):</div><div style="color:rgb(34,34,34);font-size:14px;font-family:arial,sans-serif">================================================</div><div style="color:rgb(34,34,34);font-size:14px;font-family:arial,sans-serif">
<div><div>#include <iostream></div><div>#include <map></div><div>#include <string></div><div><br></div><div>class A</div><div>{</div><div>public:</div><div>#if 0</div><div><span style="white-space:pre-wrap"> </span>typedef std::map<std::string,std::string> MapKeyValue_t;</div>
<div><span style="white-space:pre-wrap"> </span>void PrintMap(const MapKeyValue_t &my_map </div><div><span style="white-space:pre-wrap"> </span>= MapKeyValue_t())</div><div>#else</div><div><span style="white-space:pre-wrap"> </span>void PrintMap(const std::map<std::string,std::string> &my_map </div>
<div><span style="white-space:pre-wrap"> </span>= std::map<std::string,std::string>())</div><div>#endif</div><div>{</div><div><span style="white-space:pre-wrap"> </span>std::map<std::string,std::string>::const_iterator it;</div>
<div><span style="white-space:pre-wrap"> </span>for (it = my_map.begin(); it != my_map.end(); it++)</div><div><span style="white-space:pre-wrap"> </span>{</div><div><span style="white-space:pre-wrap"> </span>std::cout << it->first << " " << it->second << std::endl;</div>
<div><span style="white-space:pre-wrap"> </span>}</div><div>}</div><div>};</div><div><br></div><div>int main()</div><div>{</div><div><span style="white-space:pre-wrap"> </span>A a;</div><div><span style="white-space:pre-wrap"> </span>a.PrintMap();</div>
<div><span style="white-space:pre-wrap"> </span>return 0;</div><div>}</div></div><div>====================================================</div><div>The output is :</div><div><div>test.cpp:9:36: error: expected ')'</div>
<div> = std::map<std::string,std::string>())</div><div> ^</div><div>test.cpp:8:14: note: to match this '('</div><div>void PrintMap(const std::map<std::string,std::string> &my_map </div>
<div> ^</div><div>test.cpp:9:24: error: expected '>'</div><div> = std::map<std::string,std::string>())</div><div> ^</div><div>test.cpp:22:13: error: too few arguments to function call, expected 2, have 0</div>
<div> a.PrintMap();</div><div> ~~~~~~~~~~ ^</div><div>test.cpp:8:1: note: 'PrintMap' declared here</div><div>void PrintMap(const std::map<std::string,std::string> &my_map </div><div>^</div>
<div>3 errors generated.</div><div><br></div><div>=========================================================</div><div>It compiles ok if I write this way:</div><div>typedef std::map<std::string, std::string> MapKeyValue_t;<br>
</div><div><div>void PrintMap(const MapKeyValue_t &my_map </div><div><span style="white-space:pre-wrap"> </span>= MapKeyValue_t())</div><div><br></div><div>Both compile ok under g++.</div></div></div></div>