<div dir="ltr">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.<div>The codes like follows (also in attachment):</div><div>================================================</div>
<div><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 class="Apple-tab-span" style="white-space:pre"> </span>typedef std::map<std::string,std::string> MapKeyValue_t;</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>void PrintMap(const MapKeyValue_t &my_map </div><div><span class="Apple-tab-span" style="white-space:pre"> </span>= MapKeyValue_t())</div><div>#else</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>void PrintMap(const std::map<std::string,std::string> &my_map </div><div><span class="Apple-tab-span" style="white-space:pre"> </span>= std::map<std::string,std::string>())</div>
<div>#endif</div><div>{</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>std::map<std::string,std::string>::const_iterator it;</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>for (it = my_map.begin(); it != my_map.end(); it++)</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>{</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>std::cout << it->first << " " << it->second << std::endl;</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>}</div><div>}</div><div>};</div><div><br></div><div>int main()</div><div>{</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>A a;</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span>a.PrintMap();</div><div><span class="Apple-tab-span" style="white-space:pre"> </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></div>