代码
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/ini_parser.hpp>
int main()
{
boost::property_tree::ptree m_pt, tag_setting;
read_ini("config.ini", m_pt);
tag_setting = m_pt.get_child("config");
int g_PORT = tag_setting.get<int>("port", 10000); // tcp listen port
}
对应ini文件
#config.ini
[config]
port = 10000