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 
2
  • If I had known I wouldn't have opened the thread Commented Dec 24, 2011 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. Commented Dec 24, 2011 at 16:07

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Without a space is allowed since C++11.
I meant C++11. I'm confused by C99.
however, if I do that, it isn't inizialized, right? how can I use Works.myFunc() for example?
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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.