42#ifndef TEUCHOS_TO_STRING_HPP
43#define TEUCHOS_TO_STRING_HPP
46#ifdef HAVE_TEUCHOSCORE_QUADMATH
64 std::ostringstream oss;
105 static std::string
toString(
const std::string &t )
116 std::ostringstream os;
117 os.setf (std::ios::scientific);
128#ifdef HAVE_TEUCHOS_LONG_DOUBLE
131class ToStringTraits<long double> {
133 static std::string
toString (
const long double& t) {
134 std::ostringstream os;
135 os.setf (std::ios::scientific);
152 std::ostringstream os;
153 os.setf (std::ios::scientific);
165#ifdef HAVE_TEUCHOSCORE_QUADMATH
171class ToStringTraits<__float128> {
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);
203template<
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 <<
")";
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)