Trying to use something like the below with a char array but it doesn’t compile. But the example with short[] works fine. Any idea why? 🙂
char someChars[] = {'s','h','e','r','r','y'};
BOOST_FOREACH(char& currentChar, someChars)
{
}
short array_short[] = { 1, 2, 3 };
BOOST_FOREACH( short & i, array_short )
{
++i;
}
If you go to the line in
<boost/foreach.hpp>that raises the compilation error, you will see the following comment:Using
boost::as_array(someChars)as shown in the comment should fix your compilation error.