samedi 22 août 2015

std::atomic initialization as a template member

I am trying to compile the following code, but it keeps giving me error error: expected identifier before ‘-’ token, which part am I doing wrong?

#include <atomic>
using namespace std;

template <typename T>
class IdType{
private:
    std::atomic<T> id;
public:
    IdType(T id_):id(id_){}
    void setInitial(T id_){ id = id_; }
    T getNewId(){ return ++id; }
    T getCurrentId(){ return id; }
};
class A
{
public:
    IdType<long> ticker_id(-1L);
};

int main(int argc, char const *argv[])
{
    return 0;
}

Aucun commentaire:

Enregistrer un commentaire