From ce7c2754e8ce916d6f35eeebb877b046dd68e406 Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Wed, 27 Feb 2019 12:41:19 +0100 Subject: [PATCH] update documentation and charconv implementation --- dune/common/concurrentcache.hh | 10 +++++----- dune/common/quadmath.hh | 7 +++++-- dune/common/std/charconv.hh | 23 +++++++++++++++-------- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/dune/common/concurrentcache.hh b/dune/common/concurrentcache.hh index 7edddc8..6fc3efb 100644 --- a/dune/common/concurrentcache.hh +++ b/dune/common/concurrentcache.hh @@ -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` + * containers `std::map` and `std::unordered_map` satisfy this requirement. By default, + * if no container class is specified, the standard container `std::unordered_map` * 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 ::value, int> = 0> inline Float128 pow(const Float128& x, const Int p) @@ -383,7 +387,6 @@ namespace Dune return result; } - } // end namespace Impl template <> diff --git a/dune/common/std/charconv.hh b/dune/common/std/charconv.hh index 538f71e..e5fd8c1 100644 --- a/dune/common/std/charconv.hh +++ b/dune/common/std/charconv.hh @@ -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 @@ -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::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::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 ::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 ::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 ::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 ::value, int> = 0> to_chars_result to_chars (char* first, char* last, T value, chars_format fmt, int precision) -- GitLab