C++ 包含boost::property_树会引发编译器错误

C++ 包含boost::property_树会引发编译器错误,c++,boost,boost-propertytree,C++,Boost,Boost Propertytree,我尝试在SystemC项目中使用boost属性树。 项目用途: gcc 4.6.3 systemc 2.2 boost 1.46 标题: #include <typeinfo> #include <map> #include <vector> #include <string> #include <exception> #include <boost/property_tree/ptree.hpp> <-- line

我尝试在SystemC项目中使用boost属性树。 项目用途:

gcc 4.6.3
systemc 2.2
boost 1.46
标题:

#include <typeinfo>
#include <map>
#include <vector>
#include <string>
#include <exception>
#include <boost/property_tree/ptree.hpp> <-- line 17


class PersistenceProvider
{
static PersistenceProvider* m_instance;

//! private constructor to assure there is one instance
PersistenceProvider();

std::string GetTypePath(const std::string &name) const ;
std::string GetValuePath(const std::string &name)const ;

boost::property_tree::ptree m_ptree;
public:

 //! returns the current instance of the persistence provider
  static PersistenceProvider* getInstance();

  ~PersistenceProvider();

  template <class T>
  T get(std::string path);

  template <class T>
  void set(std::string path, T data);
};
#包括
#包括
#包括
#包括
#包括
#include='标记
/usr/include/boost/type_traits/type_with_alignment.hpp:207:5:错误:“found”不是类型
/usr/include/boost/type_traits/type_with_alignment.hpp:207:5:错误:在“%”标记之前应为“,”或“…”
/usr/include/boost/type_traits/type_with_alignment.hpp:207:5:错误:“int boost::detail::type_with_alignment_imp::static_assert(int)”不能重载
/usr/include/boost/type_traits/type_with_alignment.hpp:206:5:错误:带有'int boost::detail::type_with_alignment_imp::static_assert(int)'
...
还有一些人也这么说


这发生在包含时间,而不是在使用时。这可能是由于缺少包含或命名空间造成的吗

你能做一个简单的例子,告诉我们你是如何使用这个功能的吗?第17行,你用的是什么模板参数?
template <class T>
T PersistenceProvider::get(const std::string path)
{
const std::string typePath = GetTypePath(path);
std::string type = m_ptree.get<std::string>(typePath);
if(typeid(T).name() != type)
{
    assert("wrong type");
}

const std::string dataPath = GetValuePath(path);
return m_ptree.get<T >(dataPath);
}

template <class T>
void PersistenceProvider::set(const std::string path, const T data) 
{
std::string type = typeid(T).name();
const std::string typePath = GetTypePath(path);
m_ptree.put<std::string >(typePath, type, true);
const std::string dataPath = GetValuePath(path);
m_ptree.put<T >(dataPath, data, true);
} 
In file included from /usr/include/boost/type_traits/is_reference.hpp:17:0,
                 from /usr/include/boost/type_traits/intrinsics.hpp:132,
                 from /usr/include/boost/type_traits/alignment_of.hpp:15,
                 from /usr/include/boost/optional/optional.hpp:24,
                 from /usr/include/boost/optional.hpp:15,
                 from /usr/include/boost/property_tree/id_translator.hpp:16,
                 from /usr/include/boost/property_tree/string_path.hpp:15,
                 from /usr/include/boost/property_tree/ptree.hpp:16,
                 from ../src/tb_systemc/../behavior_systemc/PersistenceProvider.h:17,
                 ...
/usr/include/boost/type_traits/is_rvalue_reference.hpp:21:1: error: template argument 1 is invalid
In file included from /usr/include/boost/type_traits/intrinsics.hpp:133:0,
             from /usr/include/boost/type_traits/alignment_of.hpp:15,
             from /usr/include/boost/optional/optional.hpp:24,
             from /usr/include/boost/optional.hpp:15,
             from /usr/include/boost/property_tree/id_translator.hpp:16,
             from /usr/include/boost/property_tree/string_path.hpp:15,
             from /usr/include/boost/property_tree/ptree.hpp:16,
             from ../src/tb_systemc/../behavior_systemc/PersistenceProvider.h:17,
             ...
/usr/include/boost/type_traits/is_volatile.hpp:60:35: error: template argument 1 is invalid
In file included from /usr/include/boost/type_traits/is_member_function_pointer.hpp:25:0,
             from /usr/include/boost/type_traits/is_member_pointer.hpp:28,
             from /usr/include/boost/type_traits/is_pointer.hpp:24,
             from /usr/include/boost/type_traits/is_scalar.hpp:14,
             from /usr/include/boost/type_traits/is_pod.hpp:14,
             from /usr/include/boost/type_traits/has_trivial_constructor.hpp:14,
             from /usr/include/boost/type_traits/has_nothrow_constructor.hpp:12,
             from /usr/include/boost/optional/optional.hpp:25,
             from /usr/include/boost/optional.hpp:15,
             from /usr/include/boost/property_tree/id_translator.hpp:16,
             from /usr/include/boost/property_tree/string_path.hpp:15,
             from /usr/include/boost/property_tree/ptree.hpp:16,
             from ../src/tb_systemc/../behavior_systemc/PersistenceProvider.h:17,
             ...
/usr/include/boost/type_traits/remove_cv.hpp:44:36: error: template argument 1 is invalid
In file included from /usr/include/boost/optional/optional.hpp:26:0,
             from /usr/include/boost/optional.hpp:15,
             from /usr/include/boost/property_tree/id_translator.hpp:16,
             from /usr/include/boost/property_tree/string_path.hpp:15,
             from /usr/include/boost/property_tree/ptree.hpp:16,
             from ../src/tb_systemc/../behavior_systemc/PersistenceProvider.h:17,
             ...
/usr/include/boost/type_traits/type_with_alignment.hpp:206:5: error: ‘found’ is not a type
/usr/include/boost/type_traits/type_with_alignment.hpp:206:5: error: expected ‘,’ or ‘...’ before ‘>=’ token
/usr/include/boost/type_traits/type_with_alignment.hpp:207:5: error: ‘found’ is not a type
/usr/include/boost/type_traits/type_with_alignment.hpp:207:5: error: expected ‘,’ or ‘...’ before ‘%’ token
/usr/include/boost/type_traits/type_with_alignment.hpp:207:5: error: ‘int boost::detail::type_with_alignment_imp<Align>::static_assert(int)’ cannot be overloaded
/usr/include/boost/type_traits/type_with_alignment.hpp:206:5: error: with ‘int boost::detail::type_with_alignment_imp<Align>::static_assert(int)’
...