Boost C++ Libraries: Ticket #9614: Optional File Creation for boost::interprocess::file_lock https://svn.boost.org/trac10/ticket/9614 <p> An optional overload (default second argument?) for the constructor to create and open the file to use for the file_lock would be very useful. </p> <p> Currently, when creating a file lock, I typically do something like: </p> <pre class="wiki">std::ofstream tmpf(/path/to/lock/file); tmpf.close(); boost::interprocess:file_lock f_lock(/path/to/lock/file); </pre><p> Say I have a class, such as: </p> <pre class="wiki">class Foo { public: Foo(); private: boost::interprocess::file_lock f_lock; }; </pre><p> I have to do the following in the constructor: </p> <pre class="wiki">Foo::Foo() { std::ofstream tmpf(/path/to/lock/file); tmpf.close(); boost::interprocess:file_lock tmp_lock(/path/to/lock/file); f_lock.swap(tmp_lock); } </pre><p> This is cumbersome and limits usefulness in initializer lists. Tweaking the constructor to something like: </p> <pre class="wiki">file_lock::file_lock(const char *path, bool create = false); </pre><p> Would allow a constructor to do the following: </p> <pre class="wiki">Foo::Foo() : f_lock(/path/to/file/lock, true) { } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9614 Trac 1.4.3