numericCast

func numericCast<T : _SignedIntegerType, U : _SignedIntegerType>(_: T)

Convert x to type U, trapping on overflow in -Onone and -O builds.

Typically used to do conversion to any contextually-deduced integer type:

func f(x: Int32) {}
func g(x: Int64) { f(numericCast(x)) }

Declaration

func numericCast<T : _SignedIntegerType, U : _SignedIntegerType>(x: T) -> U
func numericCast<T : _SignedIntegerType, U : UnsignedIntegerType>(_: T)

Convert x to type U, trapping on overflow in -Onone and -O builds.

Typically used to do conversion to any contextually-deduced integer type:

func f(x: UInt32) {}
func g(x: Int64) { f(numericCast(x)) }

Declaration

func numericCast<T : _SignedIntegerType, U : UnsignedIntegerType>(x: T) -> U
func numericCast<T : UnsignedIntegerType, U : _SignedIntegerType>(_: T)

Convert x to type U, trapping on overflow in -Onone and -O builds.

Typically used to do conversion to any contextually-deduced integer type:

func f(x: Int32) {}
func g(x: UInt64) { f(numericCast(x)) }

Declaration

func numericCast<T : UnsignedIntegerType, U : _SignedIntegerType>(x: T) -> U
func numericCast<T : UnsignedIntegerType, U : UnsignedIntegerType>(_: T)

Convert x to type U, trapping on overflow in -Onone and -O builds.

Typically used to do conversion to any contextually-deduced integer type:

func f(x: UInt32) {}
func g(x: UInt64) { f(numericCast(x)) }

Declaration

func numericCast<T : UnsignedIntegerType, U : UnsignedIntegerType>(x: T) -> U