cmakepp_lang/types/implicitly_convertible

cmakepp_lang/types/implicitly_convertible.cpp_implicitly_convertible(result from to)

Determines if an object of a given type can be passed as a different type.

CMakePP is a strongly-typed language with minimal implicit conversions. This function knows of all allowed implicit conversions and should be used to determine if it is okay to use one type in place of another.

Note

This function is used to implement cpp_assert_signature and thus can not rely on cpp_assert_signature for type-checking.

Note

Pointer types are treated as being convertible to and from desc. Pointer types are invariant currently, meaning one pointer type cannot be used in place of another, even if the base types would be convertible.

Parameters:
  • result (desc) – Name to use for the variable which will hold the result.

  • from (type) – The type we are attempting to cast from.

  • to (type) – The type we are attempting to cast to.

Returns:

result will be set to TRUE if an instance of from can be implicitly converted to an instance of to and FALSE otherwise.

Return type:

bool

Error Checking

cpp_implicitly_convertible will assert that it is called with only three arguments, if this is not the case an error will be raised.