Problem solved => see update at the end
I'm trying to use std::function , but it seems like just turning on <functional> does not give a definition. I tried to compile the following code:
#include <functional> std::function<int(int)> f = nullptr;
with C ++ 11 parameter:
% clang++ -c -std=c++11 t.cc
Cause:
t.cc:3:6: error: no type named 'function' in namespace 'std' std::function<int(int)> f = nullptr; ~~~~~^ t.cc:3:14: error: expected unqualified-id std::function<int(int)> f = nullptr; ^ 2 errors generated.
What am I missing? I know C ++ well, but new to clang ++ / C ++ 11, so I don't know important knowledge. I think so.
I am using clang ++ on MacOS X 10.8.
Update 1
I tried the sample on cppreference.com , but it will not compile either. Providing some solutions to the problem?
Update 2
Tried the cppreference.com sample above with clang++ -c -std=c++11 -stdlib=libc++11 x.cc , and the compiler still says:
x.cc:1:10: fatal error: 'functional' file not found
Where is it functional? I think I should give -stdlib=libc++11 or something else, but this also does not work:
clang: error: invalid library name in argument '-stdlib=libc++11'
How can I find the argument list for -stdlib ? (note: in the man page, only the available libc++ and libstdc++ options are available, both of them do not work)
Or functional just doesn't work?