| Function lexicalCast Cast from a String-type to a numerical type lexicalCast<TTarget>(TSource const & source) lexicalCast<TTarget>(String<TValue, TSpec> const & source) Include Headers seqan/stream.h Parameters
source | The string to be read from Types: char[], CharString, or similar, std::string
TTarget | Type to be casted to Types: double, int, unsigned int, or similar
Remarks Return value undefined if casting fails, see lexicalCast2 for a more robust variant. This function uses std::istringstream internally, so right now "123foobar" will be succesfully cast to an int of 123. Return Values Value of Type TTarget with casted contents of source Types: TTarget Examples Using lexicalCast<>() is easy but not as robust as lexicalCast2: We cannot detect parsing or conversion errors. unsigned u = 0; int i = 0; double = 0; bool success = false; u = lexicalCast<unsigned>( "3"); // => u is 3. u = lexicalCast<unsigned>("-3"); // => u is undefined. i = lexicalCast<int>("-3"); // => i is -3. d = lexicalCast<double>("-3.99"); // => d is -3.99. See Also lexicalCast2 SeqAn - Sequence Analysis Library - www.seqan.de

Page built @2014/10/13 16:12:58