0

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
M4rk
  • 2,042
  • 5
  • 32
  • 62
  • If I had known I wouldn't have opened the thread – M4rk Dec 24 '11 at 16:04
  • I'm not blaming you. :-) I wasn't the one who downvoted your question. I didn't know the answer either. It's just good to keep duplication to a minimum around here. Existing questions are hard enough to find as it is. – Cody Gray Dec 24 '11 at 16:07

2 Answers2

2

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.

interjay
  • 101,717
  • 21
  • 254
  • 248
2

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.

Community
  • 1
  • 1
Paolo Capriotti
  • 3,984
  • 20
  • 25