Abruzzo Forte e Gentile
Abruzzo Forte e Gentile

Reputation: 14879

wrong constructor used in template class

I need to use inside my templated class a boost::interprocess::mutex Inside my function I declared my variable the way below

  named_mutex mutex(open_only, m_name.c_str() 
  ,permissions(0666));

I don't know why I cannot compile and I get an error below. How is it possible that the compiler doesn't use the right constructor (it tries to match a constructor having const reference) and how to force using the right one?

    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*)

Upvotes: 0

Views: 117

Answers (1)

Mat
Mat

Reputation: 206909

The constructor that takes an open_only_t doesn't take a permission parameter. Wouldn't really make sense - you're trying to open an existing mutex, not to create one.

Remove the permissions and it should find the proper overload.

Upvotes: 1

Related Questions