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