how can I use for each loop in GCC?
and how can i get GCC version? (in code)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use a lambda, e.g.
The range-based for loop is supported by GCC since 4.6.
The “for each” loop syntax is an MSVC extension. It is not available in other compilers.
But you could just use Boost.Foreach. It is portable and available without C++0x too.
See How do I test the current version of GCC ? on how to get the GCC version.