2012-04-04 92 views
2

今天我重建了我的C++应用程序,编译失败。虽然没有改变。第一个错误是班里Liststd::vector(私有继承)继承了这里:编译失败在Boost librairies(program_options)

template<typename T> void List<T>::append(const T& value) 
{ 
    push_back(value); 
} 

我不得不push_back(value);之前添加std::vector<T>::因为没有声明是由编译器发现。我不知道它为什么会发生,但是有一个g ++的更新,我现在在Arch Linux上使用C++ 11使用g ++ v4.7.0(预发布)。

我修复了这个问题,但现在真正的问题是,由于Boost库program_options中的问题,我无法编译应用程序的其余部分。包括我与图书馆:

#include <boost/config.hpp> 
#include <boost/program_options/detail/config_file.hpp> 
#include <boost/program_options/parsers.hpp> 

的错误:

g++ -m64 -pipe -pedantic -Wextra -std=gnu++0x -c -g -Wall -DDEBUG -DDEV -DMYSQL_SUPPORT -I. -IHeaders -MMD -MP -MF build/Debug/GNU-Linux-x86/Sources/Libs/Settings.o.d -o build/Debug/GNU-Linux-x86/Sources/Libs/Settings.o Sources/Libs/Settings.cpp 
/usr/include/boost/program_options/detail/config_file.hpp: In instantiation of ‘bool boost::program_options::detail::basic_config_file_iterator<charT>::getline(std::string&) [with charT = char; std::string = std::basic_string<char>]’: 
In file included from Sources/Libs/Settings.cpp:33:0: 
Sources/Libs/Settings.cpp:69:24: required from here 
/usr/include/boost/program_options/detail/config_file.hpp:163:13: erreur: ‘to_internal’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive] 
In file included from /usr/include/boost/program_options/detail/parsers.hpp:9:0, 
       from /usr/include/boost/program_options/parsers.hpp:265, 
       from Sources/Libs/Settings.cpp:34: 
/usr/include/boost/program_options/detail/convert.hpp:75:34: note: ‘template<class T> std::vector<std::basic_string<char> > boost::program_options::to_internal(const std::vector<T>&)’ declared here, later in the translation unit 

同样的错误比我的列表类...

谢谢!

回答

3

我怀疑你已经被gcc 4.7中模板实例的两阶段查找规则的变化所咬。

如果没有源代码,我不能给出更多的实用建议,但gcc4.7 changes(C++章节)给出了两阶段查找的描述并建议一些代码更正。

0
template<typename T> void List<T>::append(const T& value) 
{ 
    this->push_back(value); 
}