Commit ce7c2754 authored by Praetorius, Simon's avatar Praetorius, Simon

update documentation and charconv implementation

parent 57ab580e
Pipeline #1744 passed with stage
in 4 minutes and 22 seconds
......@@ -34,7 +34,7 @@ namespace Dune
* initialized thread-wise or globally only once, and guarantees that you always get initialized data.
*
* \tparam Key The type of key to access the data.
* \tparam Data The type of the data stored in the cache. The behaviur is undefined if Data is not
* \tparam Data The type of the data stored in the cache. The behavior is undefined if Data is not
* the same type as Container::mapped_type.
* \tparam Policy A policy class template implementing the method `get_or_init()`. Three implementations
* are provided: \ref ConsecutivePolicy, \ref ThreadLocalPolicy and \ref StaticLockedPolicy.
......@@ -42,12 +42,12 @@ namespace Dune
* \see ConcurrentCachePolicy
* \tparam Container The type of the underlying associative container to use to store the data. The
* container must satisfy the requirements of AssociativeContainer. The standard
* containers `std::map` and `std::unordered_map` satisfie this requirement. By default,
* if not container class is specified, the standard container `std::unordered_map<Key,Data>`
* containers `std::map` and `std::unordered_map` satisfy this requirement. By default,
* if no container class is specified, the standard container `std::unordered_map<Key,Data>`
* is used. Note, an unordered_map requires the key to be hashable.
*
* The `Policy` class template is a template parametrizable with the container type, that provides a static `get_or_init()`
* method that is called with the key, and a functor for creation of new data elements.
* The `Policy` class template is a template parametrizable with the container type, that provides a
* static `get_or_init()` method that is called with the key, and a functor for creation of new data elements.
**/
template <class Key,
class Data,
......
......@@ -335,7 +335,11 @@ namespace Dune
/// \brief Overload of `pow` function for integer exponents.
// NOTE: This is much faster than a pow(x, Float128(p)) call
// NOTE: Derived from the boost::math::cstdfloat::detail::pown implementation
// NOTE: This is a modified version of boost::math::cstdfloat::detail::pown
// (adapted to the type Float128) that is part of the Boost 1.65 Math toolkit 2.8.0
// and is implemented by Christopher Kormanyos, John Maddock, and Paul A. Bristow,
// distributed under the Boost Software License, Version 1.0
// (See http://www.boost.org/LICENSE_1_0.txt)
template <class Int,
std::enable_if_t<std::is_integral<Int>::value, int> = 0>
inline Float128 pow(const Float128& x, const Int p)
......@@ -383,7 +387,6 @@ namespace Dune
return result;
}
} // end namespace Impl
template <>
......
......@@ -77,7 +77,7 @@ namespace Dune
* 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
* 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
......@@ -86,11 +86,11 @@ namespace Dune
*
* 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.
* that `ec` equals ´std::errc::result_out_of_range` and `ptr` has 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
* pattern, as required by `std::from_chars`. Returning `last` if all
* characters are consumed.
**/
template<typename T, typename StreamManipulator>
......@@ -144,7 +144,7 @@ namespace Dune
return to_chars_result{last, std::errc::not_supported};
// negative integer values in base != 10 are not correctly converted
bool sign = value < T(0);
const bool sign = value < T(0);
try {
s << (sign ? -value : value);
} catch (...) {
......@@ -154,7 +154,7 @@ namespace Dune
if (s.fail())
return to_chars_result{last, std::errc::value_too_large};
auto str = (sign ? "-" : "") + s.str();
auto str = (sign ? '-' + s.str() : s.str());
auto num = std::min(std::distance(first, last),
std::distance(str.begin(), str.end()));
std::copy_n(str.begin(), num, first);
......@@ -165,7 +165,8 @@ namespace Dune
} // end namespace Impl
/// \brief Converts a character sequence to an integer value
/// \brief Converts a character sequence to an integer value.
/// \see Impl::fromCharsImpl
template<typename T,
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)
......@@ -178,6 +179,9 @@ namespace Dune
}
/// \brief Converts a character sequence to a floating-point value
/// \see Impl::fromCharsImpl
// NOTE: Reading hexfloat values not supported by many standard libraries, currently.
// So, `chars_format::hex` results in an error.
template<typename T,
std::enable_if_t<std::is_floating_point<T>::value, int> = 0>
from_chars_result from_chars (const char* first, const char* last, T& value,
......@@ -192,7 +196,6 @@ namespace Dune
if ((int(fmt) & int(chars_format::hex)) != 0) {
s >> std::hexfloat;
return false;
// Reading hexfloat values not supported by many standard libraries, currently.
}
return true;
});
......@@ -200,6 +203,7 @@ namespace Dune
/// \brief Converts an integer value to a character sequence
/// \see Impl::toCharsImpl
template <class T,
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)
......@@ -212,6 +216,7 @@ namespace Dune
}
/// \brief Converts a floating-point value to a character sequence
/// \see Impl::toCharsImpl
template <class T,
std::enable_if_t<std::is_floating_point<T>::value, int> = 0>
to_chars_result to_chars (char* first, char* last, T value)
......@@ -220,6 +225,7 @@ namespace Dune
}
/// \brief Converts a floating-point value to a character sequence with additional format specifier
/// \see Impl::toCharsImpl
template <class T,
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)
......@@ -237,6 +243,7 @@ namespace Dune
}
/// \brief Converts a floating-point value to a character sequence with format specifier and precision
/// \see Impl::toCharsImpl
template <class T,
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)
......
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