42 #ifndef TEUCHOS_TO_STRING_HPP
43 #define TEUCHOS_TO_STRING_HPP
46 #ifdef HAVE_TEUCHOSCORE_QUADMATH
47 # include <quadmath.h>
64 std::ostringstream oss;
105 static std::string
toString(
const std::string &t )
116 std::ostringstream os;
117 os.setf (std::ios::scientific);
133 std::ostringstream os;
134 os.setf (std::ios::scientific);
146 #ifdef HAVE_TEUCHOSCORE_QUADMATH
152 class ToStringTraits<__float128> {
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);
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 <<
")";
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 double &t)
static std::string toString(const float &t)
static std::string toString(const std::pair< T1, T2 > &t)
static std::string toString(const std::string &t)
Default traits class for converting objects into strings.
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.
std::string toString(const HashSet< Key > &h)