native C++ "a.h":
#include <thread>
class a
{
//...
private:
// ...
std::mutex mutex;
};
C++/CLI:
#include "a.h" // error cause thread is included
my solution:
native C++ "a.h":
class a
{
a();
~a();
//...
private:
// ...
void* mutex;
};
"a.cpp"
#include <thread>
a::a()
{
mutex = new std::mutex;
}
~a::a()
{
delete mutex;
}
C++/CLI:
#include "a.h" // no error
- How to do this without dynamic memory allocation?
- Is this safe? I somehow use wrapped stuff from < thread > in C++/CLI environment, just not in the header.
- Is there a better approach? The new/delete and a cast on every use seems bad. I want to have one mutex per object of the class.
mutexinstead of amutex*? - 463035818_is_not_a_number