C++ 模板类中使用了错误的构造函数
我需要在模板化类a中使用C++ 模板类中使用了错误的构造函数,c++,templates,C++,Templates,我需要在模板化类a中使用boost::进程间::互斥 在我的函数中,我以下面的方式声明了我的变量 named_mutex mutex(open_only, m_name.c_str() ,permissions(0666)); 我不知道为什么我不能编译,我在下面得到一个错误。 编译器如何可能不使用正确的构造函数(它尝试匹配具有常量引用的构造函数)以及如何强制使用正确的构造函数 error: no matching function for call to boo
boost::进程间::互斥
在我的函数中,我以下面的方式声明了我的变量
named_mutex mutex(open_only, m_name.c_str()
,permissions(0666));
我不知道为什么我不能编译,我在下面得到一个错误。
编译器如何可能不使用正确的构造函数(它尝试匹配具有常量引用的构造函数)以及如何强制使用正确的构造函数
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*)
只接受
打开\u t
的构造函数不接受权限参数。这真的没有意义——您正在尝试打开一个现有的互斥锁,而不是创建一个互斥锁
删除权限,它会找到合适的重载。你说得对。我修好了!请停止使用
标记。您应该使用`backticks`
标记内联代码。谢谢!我没发现。