Commit 57ab580e authored by Praetorius, Simon's avatar Praetorius, Simon

added more documentation to from_chars and to_chars

parent 473f4927
Pipeline #1611 passed with stage
in 4 minutes and 29 seconds
......@@ -71,6 +71,28 @@ namespace Dune
namespace Impl
{
/**
* \brief Performs the conversion of a character sequence [first, last) to
* a value of type `T` by using a `std::istringstream` formatted stream extracter.
* with format flags set by the `manipulator`.
*
* On success, returns a value of type \ref from_chars_result such that `ptr`
* points has the value equal to `last` if all characters match and `ec` is
* value-initialized.
*
* If there is no pattern match, returns a value of type \ref from_chars_result
* such that `ptr` equals `first` and `ec` equals `std::errc::invalid_argument`.
* `value` is unmodified.
*
* If the pattern was matched, but the parsed value is not in the range representable
* by the type of `value`, returns value of type \ref from_chars_result such
* that `ec` equals ´std::errc::result_out_of_range` and `ptr` points at the
* value equal to `last`. `value` is unmodified.
*
* NOTE: Can not determine pointer to the first character not matching the
* pattern, as required by `std::for_each`. Returning `last` if all
* characters are consumed.
**/
template<typename T, typename StreamManipulator>
from_chars_result fromCharsImpl (const char* first, const char* last, T& value,
StreamManipulator manipulator)
......@@ -95,11 +117,23 @@ namespace Dune
return from_chars_result{first, std::errc::invalid_argument};
}
// NOTE: Can not determine pointer to the first character not matching the pattern.
// Returning last if all characters are consumed.
return from_chars_result{s.eof() ? last : first, std::errc{}};
}
/**
* \brief Performas a conversion of `value` of type `T` to a character
* sequence stored in the memory range [first, last) by using a
* `std::ostringstream` formatted stream inserter with format flags set by
* the `manipulator`.
*
* On success, returns a value of type \ref to_chars_result such that `ec`
* equals value-initialized `std::errc` and `ptr` is the one-past-the-end
* pointer of the characters written. Note that the string is not NUL-terminated.
*
* On error, returns a value of type \ref to_chars_result holding
* `std::errc::value_too_large` in `ec`, a copy of the value `last` in `ptr`,
* and leaves the contents of the range [first, last) in unspecified state.
**/
template<typename T, typename StreamManipulator>
to_chars_result toCharsImpl (char* first, char* last, T value,
StreamManipulator manipulator)
......
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