MCPcopy Create free account
hub / github.com/Kitware/VTK / from_chars

Function from_chars

Common/Core/vtkStringScanner.h:58–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56namespace vtk
57{
58VTK_ABI_NAMESPACE_BEGIN
59///@{
60/**
61 * Given a char* first and char* last, convert it to a number, and return a from_chars_result;
62 *
63 * @note The standard library provides these functions as of C++17, but they aren't as fast,
64 * or fully implemented.
65 */
66template <typename T, typename = FASTFLOAT_ENABLE_IF(fast_float::is_supported_float_type<T>::value)>
67VTK_ALWAYS_INLINE auto from_chars(const char* first, const char* last, T& value,
68 std::chars_format format = std::chars_format::general) -> std::from_chars_result
69{
70 static constexpr std::array<fast_float::chars_format, 5> std_to_fast_float_chars_format = { {
71 fast_float::chars_format::general, // 0: Default general
72 fast_float::chars_format::scientific, // 1: scientific
73 fast_float::chars_format::fixed, // 2: fixed
74 fast_float::chars_format::general, // 3: general
75 fast_float::chars_format::hex, // 4: hex
76 } };
77 auto result = fast_float::from_chars<T>(first, last, value,
78 std_to_fast_float_chars_format[static_cast<std::underlying_type_t<std::chars_format>>(format)]);
79 return { result.ptr, result.ec };
80}
81template <typename T,
82 typename = FASTFLOAT_ENABLE_IF(fast_float::is_supported_integer_type<T>::value)>
83VTK_ALWAYS_INLINE auto from_chars(const char* first, const char* last, T& value, int base = 10)

Calls 2

dataMethod · 0.45
sizeMethod · 0.45

Tested by 2

TestGLTFWriterFunction · 0.68