|
Prev | Next | base_to_string |
CppAD::to_string_struct must be defined.
Base
types,
the following can be used to define the specialization:
namespace CppAD {
CPPAD_TO_STRING(Base)
}
Note that the CPPAD_TO_STRING macro assumes that the
base_limits
and base_std_math
have already been defined
for this type.
This macro is defined as follows:
# define CPPAD_TO_STRING(Base) \
template <> struct to_string_struct<Base>\
{ std::string operator()(const Base& value) \
{ std::stringstream os;\
int n_digits = 1 + CppAD::numeric_limits<Base>::digits10; \
os << std::setprecision(n_digits);\
os << value;\
return os.str();\
}\
};