Function
lexicalCast2
Cast from a String-type to a numerical type
Include Headers
seqan/stream.h
Parameters
Object to hold result of cast Types: | |
The string to be read from Types: char[], CharString, or similar, std::string |
Remarks
uses istringstream internally, so right now "123foobar" will be
succesfully cast to an int of 123
Return Values
Types: bool
Examples
Using lexicalCast2 is straightforward and we can detect errors.
int i = 0;
double = 0;
bool success = false;
success = lexicalCast2(u, "3"); // => success is true, u is 3.
success = lexicalCast2(u, "-3"); // => success is false, u is undefined.
success = lexicalCast2(i, "-3"); // => success is true, i is -3.
success = lexicalCast2(d, "-3.99"); // => success is true, d is -3.99.
See Also
SeqAn - Sequence Analysis Library - www.seqan.de