我需要在我的模板类中使用 boost::interprocess::mutex
在我的函数中,我用下面的方式声明了我的变量
named_mutex mutex(open_only, m_name.c_str()
,permissions(0666));
我不知道为什么我无法编译并且在下面出现错误。 编译器怎么可能不使用正确的构造函数(它试图匹配具有 const 引用的构造函数)以及如何强制使用正确的构造函数?
error: no matching function for call to
boost::interprocess::named_mutex::named_mutex(const
boost::interprocess::open_only_t&, const char*, boost::interprocess::permissions)’
/usr/local/include/boost/interprocess/sync/named_mutex.hpp:140: note:
candidates are:
boost::interprocess::named_mutex::named_mutex(boost::interprocess::open_only_t, const char*)
最佳答案
采用open_only_t
的构造函数不采用权限参数。真的没有意义 - 你试图打开一个现有的互斥体,而不是创建一个。
删除权限,它应该找到合适的重载。
关于c++ - 模板类中使用了错误的构造函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15481368/