"The art of simplicity is a puzzle of
complexity” Doug Horton
Feel free to skip this section. It is here to document the process and the
decisions made during design to be able to review and to reevaluate and to
ensure the relevancy and the correctness of those decisions and ultimately
the design. Still, this section might be useful for understanding why and how
certain decisions have been made and why Boost.Convert
is the way it is.
Boost.Convert has been designed to satisfy the following
user requirements:
-
(R1) Boost.Convert shall provide
a mechanism and an interface that take a value of type TypeIn
and yield a value of type TypeOut using an algorithm
of type Converter;
-
(R2) Boost.Convert shall provide
a mechanism and an interface to indicate success or failure of the requested
conversion;
-
(R3) Boost.Convert shall provide
fully-functional interfaces for two different program flows where
-
(R3a) error-processing is orthogonal to the
normal program flow (exception-throwing interface);
-
(R3b) normal and error-processing flows are
part of the same program flow (non-throwing interface);
-
(R4) The throwing interface shall return the result
of successful conversion or shall throw an exception;
-
(R5) The non-throwing interface shall return the
result and/or some indication of conversion success or failure;
-
(R5a) there shall be means to distinguish
success from failure;
-
(R5b) the result of conversion shall only
be available when conversion succeeds;
-
(R5c) when conversion fails, an optional fallback
value shall be returned instead if supplied;
-
(R5d) in the case of failure (with no fallback
provided) an attempt to retrieve the result shall result in an
exception thrown;
-
(R6) Boost.Convert shall provide
a uniform interface suitable for generic programming;
-
(R7) Boost.Convert shall not
interfere with or intercept any exceptions that are not part of the official
converter interface (i.e. exceptions caused by malfunction, etc.);
-
(R8) Converters shall be independent of and shall
not rely on the Boost.Convert infrastructure.