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);
128 #ifdef HAVE_TEUCHOS_LONG_DOUBLE
133 static std::string toString (
const long double& t) {
134 std::ostringstream os;
135 os.setf (std::ios::scientific);
151 static std::string toString (
const float& t) {
152 std::ostringstream os;
153 os.setf (std::ios::scientific);
165 #ifdef HAVE_TEUCHOSCORE_QUADMATH
173 static std::string toString (
const __float128& val)
177 const size_t bufSize = 128;
185 const int numCharPrinted = quadmath_snprintf (buf, bufSize,
"%.30Qe", val);
187 (static_cast<size_t> (numCharPrinted) >= bufSize, std::runtime_error,
188 "Teuchos::toString: Failed to print __float128 value: buffer has "
189 << bufSize <<
" characters, but quadmath_snprintf wanted "
190 << numCharPrinted <<
" characters!");
192 (void) quadmath_snprintf (buf, bufSize,
"%.30Qe", val);
194 return std::string (buf);
197 #endif // HAVE_TEUCHOSCORE_QUADMATH
203 template<
typename T1,
typename T2>
206 static std::string toString (
const std::pair<T1, T2>& t) {
207 std::ostringstream oss;
208 oss <<
"(" << t.first <<
"," << t.second <<
")";
216 #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.