Turn off clr option for header file with std::mutex

后端 未结 1 1905
失恋的感觉
失恋的感觉 2021-01-02 06:02

I have a Visual Studio project that contains files with managed code and files with unmanaged code. The project has the CLR support, but when I add a file where I do not nee

相关标签:
1条回答
  • 2021-01-02 06:23

    There is the possibility to use the workaround known as the Pointer To Implementation (pImpl) idiom.

    Following is a brief example:

    // Foo.h
    #include <memory>
    
    class Foo
    {
    public:
    
      Foo();
    
      // forward declaration to a nested type
      struct Mstr;
      std::unique_ptr<Mstr> impl;
    };
    
    
    // Foo.cpp
    #include <mutex>
    
    struct Foo::Mstr
    {
      std::mutex m;
    };
    
    Foo::Foo()
      : impl(new Mstr())
    {
    }
    
    0 讨论(0)
提交回复
热议问题