title: How to pass a string type path to boost::filesystem:path's constructor?
body: <p>I have the following class using boost filesystem, but encountered the problem when compiling.</p>
  
  <pre><code>/// tfs.h file:
  
  #include &lt;boost/filesystem.hpp&gt;
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace boost;
  using namespace std;
  
  class OSxFS
  {
    public:
      OSxFS(string _folderPath)
      {
        mFolderPath(_folderPath);
      }
  
      string ShowStatus()
      {
        try
        {
          filesystem::file_status folderStatus = filesystem::status(mFolderPath);
          cout&lt;&lt;"Folder status: "&lt;&lt;filesystem::is_directory(folderStatus)&lt;&lt;endl;
        }
        catch(filesystem::filesystem_error &amp;e)
        {
          cerr&lt;&lt;"Error! Message: "&lt;&lt;e.what()&lt;&lt;endl;
        }
      }
  
    private:
      filesystem::path mFolderPath;
  }
  </code></pre>
  
  <p>In the m.cpp file, I use the following code to invoke the OSxFS class:</p>
  
  <pre><code>///m.cpp file 
  
  #include "tfs.h"
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  using namespace boost;
  
  int main()
  {  
    string p = "~/Desktop/";
    OSxFS folderX(p);
    folderX.ShowStatus();
    cout&lt;&lt;"Thank you!"&lt;&lt;endl;
    return 0;
  }
  </code></pre>
  
  <p>However, I got the error message when I compile them by g++ in xCode:</p>
  
  <pre><code>In file included from m.cpp:1:
  tfs.h: In constructor ‘OSxFS::OSxFS(std::string)’:
  tfs.h:13: error: no match for call to ‘(boost::filesystem::path) (std::string&amp;)’
  m.cpp: At global scope:
  m.cpp:5: error: expected unqualified-id before ‘using’
  </code></pre>
  
  <p>If I implement the function ShowStatus() of class OSxFS in a single main.cpp, it works. So, I guess the problem is about how to pass the string variable _folderPath to the class's constructor?</p>