42 #ifndef TEUCHOS_TO_STRING_HPP
43 #define TEUCHOS_TO_STRING_HPP
46 #ifdef HAVE_TEUCHOSCORE_QUADMATH
47 # include <quadmath.h>
48 #endif // HAVE_TEUCHOSCORE_QUADMATH
62 static std::string toString(
const T &t )
64 std::ostringstream oss;
82 std::string toString(
const T& t)
92 static std::string toString(
const bool &t )
105 static std::string toString(
const std::string &t )
115 static std::string toString (
const double& t) {
116 std::ostringstream os;
117 os.setf (std::ios::scientific);
132 static std::string toString (
const float& t) {
133 std::ostringstream os;
134 os.setf (std::ios::scientific);
146 #ifdef HAVE_TEUCHOSCORE_QUADMATH
154 static std::string toString (
const __float128& val)
158 const size_t bufSize = 128;
166 const int numCharPrinted = quadmath_snprintf (buf, bufSize,
"%.30Qe", val);
168 (static_cast<size_t> (numCharPrinted) >= bufSize, std::runtime_error,
169 "Teuchos::toString: Failed to print __float128 value: buffer has "
170 << bufSize <<
" characters, but quadmath_snprintf wanted "
171 << numCharPrinted <<
" characters!");
173 (void) quadmath_snprintf (buf, bufSize,
"%.30Qe", val);
175 return std::string (buf);
178 #endif // HAVE_TEUCHOSCORE_QUADMATH
184 template<
typename T1,
typename T2>
187 static std::string toString (
const std::pair<T1, T2>& t) {
188 std::ostringstream oss;
189 oss <<
"(" << t.first <<
"," << t.second <<
")";
197 #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.