Jump to content
  • Advertisement
Sign in to follow this  
FGFS

arguments

This topic is 2208 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

seems so. With:

std::cout << it->second = IFSDatabase::getAppr(QString::fromStdString(it->first));

 

I get:

 

..IFSDatabase.cpp:577:22: error: no match for ‘operator<<’ in ‘std::cout << it.std::_Rb_tree_iterator<_Tp>::operator-><std::pair<const std::basic_string<char>, std::vector<Procedure*> > >()->std::pair<const std::basic_string<char>, std::vector<Procedure*> >::second’

Share this post


Link to post
Share on other sites
Advertisement
it->second is a std::vector<Procedure*> (aka ProcedureList). If you have not overloaded operator<< for that type you will have to loop the vector and print each Procedure object manually.

Something like this:
for (ProcedureList::iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2)
{
	std::cout << (*it2)->toString() << std::endl;
}
If the pointers can be null you'll have to check that too.

Share this post


Link to post
Share on other sites

Thanks but with that I get:

 

SDatabase.cpp:580:36: error: no match for ‘operator<<’ in ‘std::cout << Procedure::toString()’

Share this post


Link to post
Share on other sites
std::cout << (*it2)->toString().toStdString() << std::endl;

Not sure if it's the best way to do it but I think it will should work.

Share this post


Link to post
Share on other sites

That works but I forgot that I cannot use cout but need a char*

char* ss = (*it2)->toString().toStdString();

 

tabase.cpp:580:48: error: cannot convert ‘std::string {aka std::basic_string<char>}’ to ‘char*’ in initialization

Thanks again

Share this post


Link to post
Share on other sites

You can use the .c_str() member function to get a const char * for a std::string. Be careful about storing it as the return value is only valid as long as the std::string exists, so you may need to copy the std::string first and keep it around before using .c_str().

Share this post


Link to post
Share on other sites

You can use c_str() to get a const char* from a std::string but that pointer will only stay valid for as long as the string is not destroyed/modified.

const char* ss = (*it2)->toString().toStdString().c_str();
doSomethingWith(ss); // ERROR: The data pointed to by ss is no longer valid.

If you just want to pass it to a function on the same line it is OK because the string has not yet been destroyed.

doSomethingWith((*it2)->toString().toStdString().c_str()); // OK

If you want to use it on more than one line you could store the string in a variable to extend the lifetime of the pointer.

std::string str = (*it2)->toString().toStdString();
const char* ss = str.c_str();
doSomethingWith(ss); // OK
doSomethingElseWith(ss); // OK

If you want a non-const char* you can use &str[0] instead of str.c_str().

Edited by Wooh

Share this post


Link to post
Share on other sites

Now with:

 

    virtual void getIls(const std::string &id, StdWaypointList *list);

 

declared as:

typedef vector<Waypoint*> StdWaypointList;

I cannot find the StdWaypointList. I only see single waypoints...

Thanks again

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!