考虑以下示例:
#include <boost\property_tree\ptree.hpp>
#include <boost/any.hpp>
typedef boost::property_tree::ptree PT;
struct Foo
{
int bar;
int egg;
Foo(): bar(), egg() {}
};
int main()
{
Foo foo;
foo.bar = 5;
PT pt;
pt.put<Foo>("foo", foo);
return 0;
}
我是新手,我愿意将 Foo 对象放入属性树中。上面的示例将无法编译并给出错误:
c:\mingw\bin\../lib/gcc/mingw32/4.5.2/../../../../include/boost/property_tree/stream_translator.hpp:33:13: error: no match for 'operator<<' in 's << e'
任何人都可以提出正确的方法吗?