Boost C++ Libraries: Ticket #6775: boost::filesystem::path cannot be created from lexical_cast("") https://svn.boost.org/trac10/ticket/6775 <p> The boost <code>filesystem::path</code> can hold an "empty" state, where <code>.string()</code> returns <code>""</code>. It even has a designated check for this state, <code>empty()</code> This state is useful as a kind of null-value, to turn on or off certain behavior. </p> <p> However, this state cannot be reached through <code>lexical_cast</code>, the following code will for example end with a <code>boost::bad_lexical_cast</code> error. </p> <pre class="wiki">#include &lt;boost/lexical_cast.hpp&gt; #include &lt;boost/filesystem/path.hpp&gt; #include &lt;string&gt; int main() { boost::filesystem::path str = boost::lexical_cast&lt;boost::filesystem::path, std::string&gt;(""); return 0; } </pre><p> IMO, this is a bug. <code>path</code> clearly has a normal and useful <code>empty()</code> state, which cannot for some reason be reached through <code>lexical_cast</code>. The equivalent test works for <code>std::string</code>, for example, so should not be inherent problem with <code>lexical_cast</code> itself. </p> <p> One consequence is that <code>path</code> cannot be used as a value-type for <code>program_options</code>, while allowing options with default-values to be turned of using empty values. (I.E. <code>--config-file ""</code>) </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6775 Trac 1.4.3