Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

g++: expected primary-expression before ‘[’ token

I am trying to find if all the elements of a vector y is equal to 1. The following code works fine in Visual Studio but with g++ in linux (g++ -std=c++0x) it gives me this error: expected primary-expression before ‘[’ token

bool x = all_of(y.begin(), y.end(), [](unsigned char j) {return j == 1;});

Any help would be appreciated.

My gcc version is: g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-17)

Answer*

Draft saved
Draft discarded
Cancel

lang-cpp

AltStyle によって変換されたページ (->オリジナル) /