0

I have the following template class (which I've stripped right down to leave just the error). It was meant to allow threadsafe access to a resource.

#include "boost/thread.hpp"

template<class T, class M>
class MyLockable {
public:
    template <template<typename> class L>
    int GetLocked();
};

template<class T, class M>
template <template<typename> class L>
int MyLockable<T, M>::GetLocked() {
    // Some code here
    return 0;
}

This worked fine, until I tried to use it from a templated class.

class NormalExample {
public:
    MyLockable<int, boost::shared_mutex> m_lockable;

    void FunctionOfNormal() {
        this->m_lockable.GetLocked<boost::shared_lock>();
    }
};

template <class T>
class TemplatedExample {
public:
    MyLockable<T, boost::shared_mutex> m_lockable;

    void FunctionOfTemplated() {
        this->m_lockable.GetLocked<boost::shared_lock>();
    }
};

The first example FunctionOfNormal works fine with no errors. The second example FunctionOfTemplated gives the error missing template arguments before '>' token and expected primary-expression before ')' token.

This error only happens in GCC (I'm using 4.9.4, C++14). Compiling with MSVC gives no errors. Any idea what I've done wrong?

fizzybones
  • 21
  • 3

0 Answers0