I'm using boost::property_tree::ptree
and parse_ini
to read an ini file. Using ptree::iterator
I'm getting the ini sections and want to use them to create another object.
I have an object called First
that gets First(int& i, string& str)
So I'm trying to build new object like that using the return values I get from the ptree functions for example (posision
is my ptree::iterator
)
First* one = new First(
boost::lexical_cast<int>((posision->second).get<int>("number")),
(posision->second).get<string>("name")
);
but I get
no matching function for call to ‘First::First(int, std::basic_string<char>)’
so I tried casting like this:
First* one = new First(
(int&) boost::lexical_cast<int>((posision->second).get<int>("number")),
(string&) (posision->second).get<string>("name")
);
but then I got
invalid cast of an rvalue expression of type ‘int’ to type ‘int&’
and
invalid cast of an rvalue expression of type ‘std::basic_string<char>’ to type ‘std::string&
will appreciate any help or explanation.
thanks !