Commit 8b4077cc authored by Praetorius, Simon's avatar Praetorius, Simon

changed return type of manipulator

parent d83b7c91
Pipeline #1601 failed with stage
in 7 minutes and 14 seconds
......@@ -77,9 +77,8 @@ namespace Dune
{
std::istringstream s(std::string(first,last));
s.imbue(std::locale::classic()); // make sure we are in locale "C"
auto manipulator_error = manipulator(s);
if (manipulator_error)
return from_chars_result{first, std::errc{manipulator_error.value()}};
if (!manipulator(s))
return from_chars_result{first, std::errc::not_supported};
try {
s >> value; // extract value
......@@ -105,9 +104,8 @@ namespace Dune
{
std::ostringstream s;
s.imbue(std::locale::classic()); // make sure we are in locale "C"
auto manipulator_error = manipulator(s);
if (manipulator_error)
return to_chars_result{last, std::errc{manipulator_error.value()}};
if (!manipulator(s))
return to_chars_result{last, std::errc::not_supported};
// negative integer values in base != 10 are not correctly converted
bool sign = value < T(0);
......@@ -136,10 +134,10 @@ namespace Dune
std::enable_if_t<std::is_integral<T>::value, int> = 0>
from_chars_result from_chars (const char* first, const char* last, T& value, int base = 10)
{
return Impl::fromCharsImpl(first, last, value, [base](auto& s) -> std::error_code
return Impl::fromCharsImpl(first, last, value, [base](auto& s)
{
s >> std::setbase(base);
return {};
return true;
});
}
......@@ -149,7 +147,7 @@ namespace Dune
from_chars_result from_chars (const char* first, const char* last, T& value,
chars_format fmt = chars_format::general)
{
return Impl::fromCharsImpl(first, last, value, [fmt](auto& s) -> std::error_code
return Impl::fromCharsImpl(first, last, value, [fmt](auto& s)
{
if ((int(fmt) & int(chars_format::scientific)) != 0)
s >> std::scientific;
......@@ -157,10 +155,10 @@ namespace Dune
s >> std::fixed;
if ((int(fmt) & int(chars_format::hex)) != 0) {
s >> std::hexfloat;
return std::make_error_code(std::errc::not_supported);
// Reading hexfloat values not supported by many standard libraries currently
return false;
// Reading hexfloat values not supported by many standard libraries, currently.
}
return {};
return true;
});
}
......@@ -170,10 +168,10 @@ namespace Dune
std::enable_if_t<std::is_integral<T>::value, int> = 0>
to_chars_result to_chars (char* first, char* last, T value, int base = 10)
{
return Impl::toCharsImpl(first, last, value, [base](auto& s) -> std::error_code
return Impl::toCharsImpl(first, last, value, [base](auto& s)
{
s << std::setbase(base);
return {};
return true;
});
}
......@@ -182,7 +180,7 @@ namespace Dune
std::enable_if_t<std::is_floating_point<T>::value, int> = 0>
to_chars_result to_chars (char* first, char* last, T value)
{
return Impl::toCharsImpl(first, last, value, [](auto& /*s*/) -> std::error_code { return {}; });
return Impl::toCharsImpl(first, last, value, [](auto& /*s*/) { return true; });
}
/// \brief Converts a floating-point value to a character sequence with additional format specifier
......@@ -190,7 +188,7 @@ namespace Dune
std::enable_if_t<std::is_floating_point<T>::value, int> = 0>
to_chars_result to_chars (char* first, char* last, T value, chars_format fmt)
{
return Impl::toCharsImpl(first, last, value, [fmt](auto& s) -> std::error_code
return Impl::toCharsImpl(first, last, value, [fmt](auto& s)
{
if ((int(fmt) & int(chars_format::scientific)) != 0)
s << std::scientific;
......@@ -198,7 +196,7 @@ namespace Dune
s << std::fixed;
if ((int(fmt) & int(chars_format::hex)) != 0)
s << std::hexfloat;
return {};
return true;
});
}
......@@ -207,7 +205,7 @@ namespace Dune
std::enable_if_t<std::is_floating_point<T>::value, int> = 0>
to_chars_result to_chars (char* first, char* last, T value, chars_format fmt, int precision)
{
return Impl::toCharsImpl(first, last, value, [fmt,precision](auto& s) -> std::error_code
return Impl::toCharsImpl(first, last, value, [fmt,precision](auto& s)
{
s << std::setprecision(precision);
if ((int(fmt) & int(chars_format::scientific)) != 0)
......@@ -216,7 +214,7 @@ namespace Dune
s << std::fixed;
if ((int(fmt) & int(chars_format::hex)) != 0)
s << std::hexfloat;
return {};
return true;
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment