jeudi 24 août 2017

Why can't tbb::atomic cast a literal to an atomic, but std::atomic can?

I'm attempting to build a large project that has many dependencies. The last thing (?) preventing it from building is TBB's failure to handle casting of an int into an const tbb::<unsigned int>&. The annoying thing is that the same cast using std::atomic (specifically const std::atomic<unsigned int>&) works just fine. I can't refactor the code to use std instead of tbb (it uses other features of tbb that aren't part of std).

I've created the following simple test case:

#include <tbb/atomic.h>
#include <atomic>

void good(const std::atomic<unsigned int>& i) {
}

void bad(const tbb::atomic<unsigned int>& i) {
}

int main() {
    good(1);
    bad(1); // error C2664: 'void bad(const tbb::atomic<unsigned int> &)': cannot convert argument 1 from 'int' to 'const tbb::atomic<unsigned int> &'
}

Does anyone know how to fix this (without removing use of TBB)? I need it to work in VS2017.

Aucun commentaire:

Enregistrer un commentaire