10 #ifndef TEUCHOS_TO_STRING_HPP
11 #define TEUCHOS_TO_STRING_HPP
14 #ifdef HAVE_TEUCHOSCORE_QUADMATH
15 # include <quadmath.h>
16 #endif // HAVE_TEUCHOSCORE_QUADMATH
30 static std::string toString(
const T &t )
32 std::ostringstream oss;
50 std::string toString(
const T& t)
60 static std::string toString(
const bool &t )
73 static std::string toString(
const std::string &t )
83 static std::string toString (
const double& t) {
84 std::ostringstream os;
85 os.setf (std::ios::scientific);
96 #ifdef HAVE_TEUCHOS_LONG_DOUBLE
101 static std::string toString (
const long double& t) {
102 std::ostringstream os;
103 os.setf (std::ios::scientific);
119 static std::string toString (
const float& t) {
120 std::ostringstream os;
121 os.setf (std::ios::scientific);
133 #ifdef HAVE_TEUCHOSCORE_QUADMATH
141 static std::string toString (
const __float128& val)
145 const size_t bufSize = 128;
153 const int numCharPrinted = quadmath_snprintf (buf, bufSize,
"%.30Qe", val);
155 (static_cast<size_t> (numCharPrinted) >= bufSize, std::runtime_error,
156 "Teuchos::toString: Failed to print __float128 value: buffer has "
157 << bufSize <<
" characters, but quadmath_snprintf wanted "
158 << numCharPrinted <<
" characters!");
160 (void) quadmath_snprintf (buf, bufSize,
"%.30Qe", val);
162 return std::string (buf);
165 #endif // HAVE_TEUCHOSCORE_QUADMATH
171 template<
typename T1,
typename T2>
174 static std::string toString (
const std::pair<T1, T2>& t) {
175 std::ostringstream oss;
176 oss <<
"(" << t.first <<
"," << t.second <<
")";
184 #endif // TEUCHOS_TO_STRING_HPP
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Macro for throwing an exception with breakpointing to ease debugging.
Teuchos header file which uses auto-configuration information to include necessary C++ headers...
Default traits class for converting objects into strings.