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
32 std::ostringstream oss;
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
99 class ToStringTraits<long double> {
101 static std::string
toString (
const long double& t) {
102 std::ostringstream os;
103 os.setf (std::ios::scientific);
120 std::ostringstream os;
121 os.setf (std::ios::scientific);
133 #ifdef HAVE_TEUCHOSCORE_QUADMATH
139 class ToStringTraits<__float128> {
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
static std::string toString(const std::string &t)
static std::string toString(const T &t)
#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...
static std::string toString(const bool &t)
static std::string toString(const float &t)
std::string toString(const HashSet< Key > &h)
static std::string toString(const std::pair< T1, T2 > &t)
Default traits class for converting objects into strings.
static std::string toString(const double &t)