static declaration in a c++ class [duplicate]
-
29-03-2021 - |
Question
I don't understand why the first doesn't work instead the second works!
#include <boost/bind.hpp>
#include <boost/function.hpp>
#include "concurrentQueue.h";
class TestClass {
public:
static concurrentQueue<function<void()>> notW;
static concurrentQueue<int> Works;
}
I attach also the beginning of the concurrentQueue class:
template<class Data> class concurrentQueue
Solution
Put a space inside the >>
to prevent it from being treated as a right-shift operator:
static concurrentQueue<function<void()> > notW;
With C++11 compilers this won't be necessary, as the compiler will interpret the angle brackets as closing the template argument list where possible.
OTHER TIPS
You need a space between the two closing angle brackets in C++ 03 and earlier. This has been "fixed" in the new 2011 standard.
See for example this question for more information.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow