|
Boost Users : |
Subject: [Boost-users] Program Options and Filesystem ifstream
From: Scott Morgan (blumf_at_[hidden])
Date: 2015-08-18 11:38:29
Having a problem getting the following to compile under a Linux system
(Mint 17.2, boost 1.54). It works okay with MSVC2010 and boost 1.57 though.
**begin: main.cpp**
#include <boost/filesystem/fstream.hpp>
namespace fs = boost::filesystem;
#include <boost/program_options.hpp>
namespace po = boost::program_options;
void test(fs::path& cfg_path, po::options_description& cfg_desc,
po::variables_map& options)
{
po::store(po::parse_config_file(fs::ifstream(cfg_path), cfg_desc,
true), options);
}
**end: main.cpp**
Is this just a problem with 1.54's version of filesystem and/or program
options?
Scott
**begin: GCC output**
main.cpp: In function âvoid test(boost::filesystem::path&,
boost::program_options::options_description&,
boost::program_options::variables_map&)â:
main.cpp:8:72: error: no matching function for call to
âparse_config_file(boost::filesystem::ifstream,
boost::program_options::options_description&, bool)â
po::store(po::parse_config_file(fs::ifstream(cfg_path), cfg_desc,
true), options);
^
main.cpp:8:72: note: candidates are:
In file included from /usr/include/boost/program_options.hpp:17:0,
from main.cpp:3:
/usr/include/boost/program_options/parsers.hpp:185:5: note:
boost::program_options::basic_parsed_options<charT>
boost::program_options::parse_config_file(std::basic_istream<charT>&,
const boost::program_options::options_description&, bool) [with charT =
char]
parse_config_file(std::basic_istream<charT>&, const
options_description&,
^
/usr/include/boost/program_options/parsers.hpp:185:5: note: no known
conversion for argument 1 from âboost::filesystem::ifstream {aka
boost::filesystem::basic_ifstream<char>}â to âstd::basic_istream<char>&â
/usr/include/boost/program_options/parsers.hpp:198:5: note:
template<class charT>
boost::program_options::basic_parsed_options<charT>
boost::program_options::parse_config_file(const char*, const
boost::program_options::options_description&, bool)
parse_config_file(const char* filename, const options_description&,
^
/usr/include/boost/program_options/parsers.hpp:198:5: note: template
argument deduction/substitution failed:
main.cpp:8:72: note: cannot convert
âboost::filesystem::basic_ifstream<char>((*(const
boost::filesystem::path*)cfg_path))â (type âboost::filesystem::ifstream
{aka boost::filesystem::basic_ifstream<char>}â) to type âconst char*â
po::store(po::parse_config_file(fs::ifstream(cfg_path), cfg_desc,
true), options);
^
**end: GCC output**
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net