cmakepp_lang/types/float

cmakepp_lang/types/float.cpp_is_float(return str2check)

Determines if a string can be lexically cast to a float.

For our purposes a float is any string whose only characters include a decimal point, and the numbers 0 through 9. Optionally the float may be prefixed with a minus sign.

Parameters:
  • return (desc) – Name for the variable used to store the result.

  • str2check (str) – The string we are checking for its floaty-ness

Returns:

return will be set to TRUE if str2check is a float and FALSE otherwise.

Return type:

bool

Example Usage

The following is an example showcasing how one would check if the identifier x contained a float.

include(cmakepp_lang/types/float)
set(x 3.14)
cpp_is_float(return ${x})
message("3.14 is a float: ${return}")  # prints TRUE

Error Checking

cpp_is_float will assert that it is called with exactly two arguments. If it is not an error will be raised.