
18 Jun
2008
18 Jun
'08
5:07 p.m.
Hi Sean.
I need to convert and std::string to an int, should I use Lexical_cast or can I just use static_cast?
No way to use static_cast<> for this, but lexical_cast<> is ok. One thing I do not know about lexical_cast is whether it does any dynamic memory allocation internally which it should not need to do in this specific case. Such memory allocation can throw std::bad_alloc exceptions and may or may not be a performance bottleneck depending on your use-case. If this bothers you, you can always use atoi() or something similar. Hope this helps. Best regards, Jurko Gospodnetić