Im learning c++ 11 and i found this error
#include<SFML/Graphics.hpp>
int main()
{
sf::VertexArray a;
for(auto& b:a)
{
}
}
error when compiled with GCC
g++ test.cpp -o test -lsfml-graphics -lsfml-window -lsfml-system -std=c++11
test.cpp: In function ‘int main()’:
test.cpp:6:14: error: ‘begin’ was not declared in this scope
for(auto& b:a)
^
test.cpp:6:14: note: suggested alternative:
In file included from /usr/include/c++/4.9/bits/basic_string.h:42:0,
from /usr/include/c++/4.9/string:52,
from /usr/include/c++/4.9/bits/locale_classes.h:40,
from /usr/include/c++/4.9/bits/ios_base.h:41,
from /usr/include/c++/4.9/ios:42,
from /usr/include/c++/4.9/ostream:38,
from /usr/include/SFML/System/Err.hpp:32,
from /usr/include/SFML/System.hpp:34,
from /usr/include/SFML/Window.hpp:32,
from /usr/include/SFML/Graphics.hpp:32,
from test.cpp:1:
/usr/include/c++/4.9/initializer_list:89:5: note: ‘std::begin’
begin(initializer_list<_Tp> __ils) noexcept
^
test.cpp:6:14: error: ‘end’ was not declared in this scope
for(auto& b:a)
^
test.cpp:6:14: note: suggested alternative:
In file included from /usr/include/c++/4.9/bits/basic_string.h:42:0,
from /usr/include/c++/4.9/string:52,
from /usr/include/c++/4.9/bits/locale_classes.h:40,
from /usr/include/c++/4.9/bits/ios_base.h:41,
from /usr/include/c++/4.9/ios:42,
from /usr/include/c++/4.9/ostream:38,
from /usr/include/SFML/System/Err.hpp:32,
from /usr/include/SFML/System.hpp:34,
from /usr/include/SFML/Window.hpp:32,
from /usr/include/SFML/Graphics.hpp:32,
from test.cpp:1:
/usr/include/c++/4.9/initializer_list:99:5: note: ‘std::end’
end(initializer_list<_Tp> __ils) noexcept
^
error when compiled with clang
clang++ test.cpp -o test -lsfml-graphics -lsfml-window -lsfml-system -std=c++11
test.cpp:6:13: error: invalid range expression of type 'sf::VertexArray'; no
viable 'begin' function available
for(auto& b:a)
^~
1 error generated.