ocean.util.Convert

This module provides a templated function that performs value-preserving conversions between arbitrary types. This function's behaviour can be extended for user-defined types as needed.

Members

Classes

ConversionException
class ConversionException

This exception is thrown when the to template is unable to perform a conversion at run-time. This typically occurs when the source value cannot be represented in the destination type. This exception is also thrown when the conversion would cause an over- or underflow.

Functions

to
D to(S value, D default_)
Undocumented in source.
to
D to(S value)

Attempts to perform a value-preserving conversion of the given value from type S to type D. If the conversion cannot be performed in any context, a compile-time error will be issued describing the types involved. If the conversion fails at run-time because the destination type could not represent the value being converted, a ConversionException will be thrown.

Templates

to
template to(D)
Undocumented in source.

Meta

Credits

Inspired in part by Andrei Alexandrescu's work on std.conv.

License

Tango Dual License: 3-Clause BSD License / Academic Free License v3.0. See LICENSE_TANGO.txt for details.

Authors

Daniel Keep