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
namespace fs = boost::filesystem;
#include
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**