clang - How to pass std::map as a default constructor parameter in c++ class function -


i have problem when attempting use std::map in clang-3.3 , clang-3.0 on ubuntu 12.04:

#include <iostream> #include <map> #include <string>  class { public: #if 0 //clang compiles ok     typedef std::map<std::string,std::string> mapkeyvalue_t;     void printmap(const mapkeyvalue_t &my_map          = mapkeyvalue_t()) #else // clang compiles fail     void printmap(const std::map<std::string,std::string> &my_map      = std::map<std::string,std::string>()) #endif {     std::map<std::string,std::string>::const_iterator it;     (it = my_map.begin(); != my_map.end(); it++)     {         std::cout << it->first << " " << it->second << std::endl;     } } };  int main() {     a;     a.printmap();     return 0; } 

however, while code compiles in both g++ , clang keep getting these errors output:

test.cpp:14:36: error: expected ')'         = std::map<std::string,std::string>())                                           ^ test.cpp:13:15: note: match '('         void printmap(const std::map<std::string,std::string> &my_map                       ^ test.cpp:14:24: error: expected '>'         = std::map<std::string,std::string>())                               ^ test.cpp:28:13: error: few arguments function call, expected 2, have 0         a.printmap();         ~~~~~~~~~~ ^ test.cpp:13:2: note: 'printmap' declared here         void printmap(const std::map<std::string,std::string> &my_map          ^ 3 errors generated. 

the closest thing find matches problem topic: how pass std::map default constructor parameter

but, have no idea what's wrong. hopefully, can shed light on this, please.

update:

void printmap(const std::map<std::string,std::string> &my_map          = (std::map<std::string,std::string>())) 

is ok. thanks.

i compiled , run in vs2012.
think it's compilers problem.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -