Search code examples
c++boostboost-function

static declaration in a c++ class


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.