Jump to content
  • Advertisement
Sign in to follow this  
jwezorek

Does using a local struct as a functor work in Xcode

This topic is 2515 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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)

Share this post


Link to post
Share on other sites
Advertisement
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).

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!