Conversion

Since the converting from a type to another is a very frequent operation, whcih can be used explicitly or implicitly, we consider it with a special care. A namespace let is used to do these explicit conversion from one type to the other. Two functions are available in this namespace:

In order to extend the existing set of conversions, one has to define the missing functions in the namespace let or in the namespace of the data.

namespace let {
    void assign(X0 & x, const Y0 & y) { ... }
}

If no specialization of let::assign(X& x, const Y&y) for given types X, Y is available the operator = will be used: x=y;

Example

In order to apply the default convertions, the following include directive should be used:

#include <synaps/arithm/let.h>

Here is an example of convertion from a string to an int and a double type:

  int i;    let::assign(i, "23432432");
  double d; let::assign(d,"4343.43234");

Implementation

See also:
synaps/arithm/let.h.

SYNAPS DOCUMENTATION
logo