在boost 属性树的文档中,有一个正确使用的示例,在此处或在包中给出 libs/property_tree/examples/debug_settings.cpp.
我想知道的是关于这struct debug_settings条线.为什么要把它作为结构而不是类?它甚至有两个成员函数,load(...)和save(...).我认为提升作者有充分的理由这样做,并且它与...效率有某种关系,即使结构和类在"技术上"相同?
从列出的版权年份,我可以猜测这可能是C++ 98,C++ 03或C++ 0x,因此使用结构而不是类的原因至少来自于前C++ 11观点.
// ----------------------------------------------------------------------------
// Copyright (C) 2002-2006 Marcin Kalicinski
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// For more information, see www.boost.org
// ----------------------------------------------------------------------------
//[debug_settings_includes
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>
#include <boost/foreach.hpp>
#include <string>
#include <set>
#include <exception>
#include <iostream>
namespace pt = …Run Code Online (Sandbox Code Playgroud)