Does using a local struct as a functor work in Xcode
I'm planning on porting some code from VS2010 to Apple world and just discovered that XCode doesn't support lambdas. Was wondering if as a work-around I could use local structs as functors? As discussed in this StackOverflow thread this is a C++11 feature, but was wondering if XCode happens to support it? (I don't currently own a mac, am just thinking ahead)
xcode uses the GCC or LLVM compilers so it all depends on what versions of the compilers you have.
What Calexus said. If you want to find out, you can install a g++ compiler on your Windows machine (i.e. through MinGW or Cygwin) and try it out. I think g++ has more C++11 support than VS2010, iirc (speaking of the latest versions, of course).
Wait so you can use XCode with whatever version of GCC you want? Because the guy in this thread is saying that if you want to use C++11 features you have to install GCC 4.6 and use that but from the command line or a 3rd party IDE e.g. Eclipse + CDT. Is this not right? -- because I kind of wanted to stick with XCode since I will be a newbie in Mac development.
I was thinking you had to use GCC 4.2 with XCode and was wondering if it supported passing local structs as functors to std::algorithms.
I was thinking you had to use GCC 4.2 with XCode and was wondering if it supported passing local structs as functors to std::algorithms.
In this blog post, a guy got X Code working with GCC 4.4, and a commentor says he followed the directions and, with a slight change, got it working with GCC 4.6. Your milage may vary, however.
For a list of C++11 features Clang currently supports, see C++ and C++'11 Support in Clang. Lambda expressions are currently not implemented.
Your only choice for now (until Clang devs implement lambda support) is using MacPorts' GCC 4.5/4.6 compilers.
The extra command-line option would be -std=c++0x (in the next version of Clang and GCC it will be the proper -std=c++11).
Personally, I find MacPorts to be essential to install on my Mac if I want to get the latest version of software that is unavailable any other way.
p.s. This shows how you would see and change the option in Xcode for the compiler you want to use for a newbie.
Your only choice for now (until Clang devs implement lambda support) is using MacPorts' GCC 4.5/4.6 compilers.
The extra command-line option would be -std=c++0x (in the next version of Clang and GCC it will be the proper -std=c++11).
Personally, I find MacPorts to be essential to install on my Mac if I want to get the latest version of software that is unavailable any other way.
p.s. This shows how you would see and change the option in Xcode for the compiler you want to use for a newbie.
For a list of C++11 features Clang currently supports, see C++ and C++'11 Support in Clang. Lambda expressions are currently not implemented.
So if you choose, "LLVM Compiler" you use CLang as your front end. Which version of CLang is that? -- because according to the link you provided Clang 2.9 supports "Local and unnamed types as template arguments" which is the question in my OP.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement