私はini ファイルを読むためにboost::property_tree::ptree
andを使用しています。parse_ini
使用ptree::iterator
方法 ini セクションを取得していて、それらを使用して別のオブジェクトを作成したいと考えています。
First
取得するというオブジェクトがありますFirst(int& i, string& str)
そのため、たとえば ptree 関数から取得した戻り値を使用して、そのような新しいオブジェクトを構築しようとしています ( posision
is my ptree::iterator
)
First* one = new First(
boost::lexical_cast<int>((posision->second).get<int>("number")),
(posision->second).get<string>("name")
);
しかし、私は得る
no matching function for call to ‘First::First(int, std::basic_string<char>)’
だから私はこのようにキャストしようとしました:
First* one = new First(
(int&) boost::lexical_cast<int>((posision->second).get<int>("number")),
(string&) (posision->second).get<string>("name")
);
しかし、それから私は得ました
invalid cast of an rvalue expression of type ‘int’ to type ‘int&’
と
invalid cast of an rvalue expression of type ‘std::basic_string<char>’ to type ‘std::string&
助けや説明をいただければ幸いです。
ありがとう !