I successfully compiled on Windows a code that should be crossplatform. Now when compiling it in Xcode with Mac OS X, I get:
std::valarray<float> v(32);
...
std::sort(begin(v), end(v)); # Use of undeclared identifier 'begin'
std::sort(std::begin(v), std::end(v)); # No member named 'begin' in namespace 'std'
std::sort(std::valarray::begin(v), std::valarray::end(v)); # Idem, error as well
Why does the error No member named 'begin' in namespace 'std'
happen?
std::begin
was introduced with C++11. See this answer for how to enable C++11 in XCode 4.2 (the precise name of the dialect has probably changed by now).
Alternatively, if you can't move to C++11, switch to std::vector
and use v.begin()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With