In order to bring the foreach comfort from C# to C++ I found the following way to do so:
- Using boost library (a must have library for C++ developers)
- Go to make BOOST_FOREACH prettier
- Add usertype.dat into same directory where devenv.exe resists
- Add the words foreach and reverse_foreach to usertype.dat
- Restart Visual Studio
D’oh! The Code Snippet-Plug-In fails.
It should look like this:
But:
1: void BoostTests()
2: {
3: DbgLog(__FUNCTIONW__);
4:
5: boost::array<int, 3> myIntArray;
6: myIntArray[0] = 2;
7: myIntArray[1] = 8;
8: myIntArray[2] = 1976;
9:
10: int result = 0;
11:
12: foreach (int number, myIntArray)
13: {
14: result += number;
15: }
16: }
Keine Kommentare:
Kommentar veröffentlichen