Created
September 24, 2013 19:16
-
-
Save keisukefukuda/6689841 to your computer and use it in GitHub Desktop.
Compiler compatibility test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <map> | |
#include <string> | |
using namespace std; | |
// This is OK. | |
void func(map<string,string> a=map<string,string>()) { | |
return; | |
} | |
// This is bad. | |
class Foo { | |
void bar(map<string,string> a=map<string,string>()) { | |
return; | |
} | |
}; | |
int main(int argc, char **argv) { | |
Foo foo; | |
return 0; | |
} | |
Works with Linux g++
$ g++ --version
g++ (GCC) 4.4.5 20110214 (Red Hat 4.4.5-6)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Error with Apple LLVM g++ compmiler.
$ g++ --version
i686-apple-darwin11-llvm-g++-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ g++ -Wall def_ctr.cpp
def_ctr.cpp:11: error: expected ‘,’ or ‘...’ before ‘>’ token
def_ctr.cpp:11: error: wrong number of template arguments (1, should be 4)
/usr/include/c++/4.2.1/bits/stl_map.h:93: error: provided for ‘template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map’
def_ctr.cpp:11: error: default argument missing for parameter 2 of ‘void Foo::bar(std::map<std::basic_string<char, std::char_traits, std::allocator >, std::basic_string<char, std::char_traits, std::allocator >, std::less<std::basic_string<char, std::char_traits, std::allocator > >, std::allocator<std::pair<const std::basic_string<char, std::char_traits, std::allocator >, std::basic_string<char, std::char_traits, std::allocator > > > >, std::string)’
def_ctr.cpp: In function ‘int main(int, char**)’:
def_ctr.cpp:17: warning: unused variable ‘foo’