/src/boost/boost/lexical_cast/detail/converter_lexical.hpp
Line | Count | Source |
1 | | // Copyright Kevlin Henney, 2000-2005. |
2 | | // Copyright Alexander Nasonov, 2006-2010. |
3 | | // Copyright Antony Polukhin, 2011-2026. |
4 | | // |
5 | | // Distributed under the Boost Software License, Version 1.0. (See |
6 | | // accompanying file LICENSE_1_0.txt or copy at |
7 | | // http://www.boost.org/LICENSE_1_0.txt) |
8 | | // |
9 | | // what: lexical_cast custom keyword cast |
10 | | // who: contributed by Kevlin Henney, |
11 | | // enhanced with contributions from Terje Slettebo, |
12 | | // with additional fixes and suggestions from Gennaro Prota, |
13 | | // Beman Dawes, Dave Abrahams, Daryle Walker, Peter Dimov, |
14 | | // Alexander Nasonov, Antony Polukhin, Justin Viiret, Michael Hofmann, |
15 | | // Cheng Yang, Matthew Bradbury, David W. Birdsall, Pavel Korzh and other Boosters |
16 | | // when: November 2000, March 2003, June 2005, June 2006, March 2011 - 2014 |
17 | | |
18 | | #ifndef BOOST_LEXICAL_CAST_DETAIL_CONVERTER_LEXICAL_HPP |
19 | | #define BOOST_LEXICAL_CAST_DETAIL_CONVERTER_LEXICAL_HPP |
20 | | |
21 | | #include <boost/lexical_cast/detail/config.hpp> |
22 | | |
23 | | #if !defined(BOOST_USE_MODULES) || defined(BOOST_LEXICAL_CAST_INTERFACE_UNIT) |
24 | | |
25 | | #ifndef BOOST_LEXICAL_CAST_INTERFACE_UNIT |
26 | | #include <boost/config.hpp> |
27 | | #ifdef BOOST_HAS_PRAGMA_ONCE |
28 | | # pragma once |
29 | | #endif |
30 | | |
31 | | #if defined(BOOST_NO_STRINGSTREAM) || defined(BOOST_NO_STD_WSTRING) |
32 | | #define BOOST_LCAST_NO_WCHAR_T |
33 | | #endif |
34 | | |
35 | | #include <array> |
36 | | #include <cstddef> |
37 | | #include <string> |
38 | | #include <type_traits> |
39 | | #include <boost/limits.hpp> |
40 | | |
41 | | #include <array> |
42 | | |
43 | | #ifndef BOOST_NO_CXX17_HDR_STRING_VIEW |
44 | | #include <string_view> |
45 | | #endif |
46 | | |
47 | | #include <boost/container/container_fwd.hpp> |
48 | | |
49 | | #endif // #ifndef BOOST_LEXICAL_CAST_INTERFACE_UNIT |
50 | | |
51 | | #include <boost/lexical_cast/detail/lcast_precision.hpp> |
52 | | #include <boost/lexical_cast/detail/widest_char.hpp> |
53 | | #include <boost/lexical_cast/detail/is_character.hpp> |
54 | | #include <boost/lexical_cast/detail/buffer_view.hpp> |
55 | | #include <boost/lexical_cast/detail/converter_lexical_streams.hpp> |
56 | | |
57 | | namespace boost { |
58 | | |
59 | | // Forward declaration |
60 | | template<class T, std::size_t N> |
61 | | class array; |
62 | | template<class IteratorT> |
63 | | class iterator_range; |
64 | | |
65 | | // Forward declaration of boost::basic_string_view from Utility |
66 | | template<class Ch, class Tr> class basic_string_view; |
67 | | |
68 | | namespace detail // normalize_single_byte_char<Char> |
69 | | { |
70 | | // Converts signed/unsigned char to char |
71 | | template < class Char > |
72 | | struct normalize_single_byte_char |
73 | | { |
74 | | using type = Char; |
75 | | }; |
76 | | |
77 | | template <> |
78 | | struct normalize_single_byte_char< signed char > |
79 | | { |
80 | | using type = char; |
81 | | }; |
82 | | |
83 | | template <> |
84 | | struct normalize_single_byte_char< unsigned char > |
85 | | { |
86 | | using type = char; |
87 | | }; |
88 | | } |
89 | | |
90 | | namespace detail // deduce_character_type_later<T> |
91 | | { |
92 | | // Helper type, meaning that stram character for T must be deduced |
93 | | // at Stage 2 (See deduce_source_char<T> and deduce_target_char<T>) |
94 | | template < class T > struct deduce_character_type_later {}; |
95 | | } |
96 | | |
97 | | namespace detail // stream_char_common<T> |
98 | | { |
99 | | // Selectors to choose stream character type (common for Source and Target) |
100 | | // Returns one of char, wchar_t, char16_t, char32_t or deduce_character_type_later<T> types |
101 | | // Executed on Stage 1 (See deduce_source_char<T> and deduce_target_char<T>) |
102 | | template < typename Type > |
103 | | struct stream_char_common: public std::conditional< |
104 | | boost::detail::is_character< Type >::value, |
105 | | Type, |
106 | | boost::detail::deduce_character_type_later< Type > |
107 | | > {}; |
108 | | |
109 | | template < typename Char > |
110 | | struct stream_char_common< Char* >: public std::conditional< |
111 | | boost::detail::is_character< Char >::value, |
112 | | Char, |
113 | | boost::detail::deduce_character_type_later< Char* > |
114 | | > {}; |
115 | | |
116 | | template < typename Char > |
117 | | struct stream_char_common< const Char* >: public std::conditional< |
118 | | boost::detail::is_character< Char >::value, |
119 | | Char, |
120 | | boost::detail::deduce_character_type_later< const Char* > |
121 | | > {}; |
122 | | |
123 | | template < typename Char > |
124 | | struct stream_char_common< boost::conversion::detail::buffer_view< Char > > |
125 | | { |
126 | | using type = Char; |
127 | | }; |
128 | | |
129 | | template < typename Char > |
130 | | struct stream_char_common< boost::iterator_range< Char* > >: public std::conditional< |
131 | | boost::detail::is_character< Char >::value, |
132 | | Char, |
133 | | boost::detail::deduce_character_type_later< boost::iterator_range< Char* > > |
134 | | > {}; |
135 | | |
136 | | template < typename Char > |
137 | | struct stream_char_common< boost::iterator_range< const Char* > >: public std::conditional< |
138 | | boost::detail::is_character< Char >::value, |
139 | | Char, |
140 | | boost::detail::deduce_character_type_later< boost::iterator_range< const Char* > > |
141 | | > {}; |
142 | | |
143 | | template < class Char, class Traits, class Alloc > |
144 | | struct stream_char_common< std::basic_string< Char, Traits, Alloc > > |
145 | | { |
146 | | using type = Char; |
147 | | }; |
148 | | |
149 | | template < class Char, class Traits, class Alloc > |
150 | | struct stream_char_common< boost::container::basic_string< Char, Traits, Alloc > > |
151 | | { |
152 | | using type = Char; |
153 | | }; |
154 | | |
155 | | template < typename Char, std::size_t N > |
156 | | struct stream_char_common< boost::array< Char, N > >: public std::conditional< |
157 | | boost::detail::is_character< Char >::value, |
158 | | Char, |
159 | | boost::detail::deduce_character_type_later< boost::array< Char, N > > |
160 | | > {}; |
161 | | |
162 | | template < typename Char, std::size_t N > |
163 | | struct stream_char_common< boost::array< const Char, N > >: public std::conditional< |
164 | | boost::detail::is_character< Char >::value, |
165 | | Char, |
166 | | boost::detail::deduce_character_type_later< boost::array< const Char, N > > |
167 | | > {}; |
168 | | |
169 | | #ifndef BOOST_NO_CXX11_HDR_ARRAY |
170 | | template < typename Char, std::size_t N > |
171 | | struct stream_char_common< std::array<Char, N > >: public std::conditional< |
172 | | boost::detail::is_character< Char >::value, |
173 | | Char, |
174 | | boost::detail::deduce_character_type_later< std::array< Char, N > > |
175 | | > {}; |
176 | | |
177 | | template < typename Char, std::size_t N > |
178 | | struct stream_char_common< std::array< const Char, N > >: public std::conditional< |
179 | | boost::detail::is_character< Char >::value, |
180 | | Char, |
181 | | boost::detail::deduce_character_type_later< std::array< const Char, N > > |
182 | | > {}; |
183 | | #endif |
184 | | |
185 | | #ifndef BOOST_NO_CXX17_HDR_STRING_VIEW |
186 | | template < class Char, class Traits > |
187 | | struct stream_char_common< std::basic_string_view< Char, Traits > > |
188 | | { |
189 | | using type = Char; |
190 | | }; |
191 | | #endif |
192 | | template < class Char, class Traits > |
193 | | struct stream_char_common< boost::basic_string_view< Char, Traits > > |
194 | | { |
195 | | using type = Char; |
196 | | }; |
197 | | |
198 | | #ifdef BOOST_HAS_INT128 |
199 | | template <> struct stream_char_common< boost::int128_type > |
200 | | { |
201 | | using type = char; |
202 | | }; |
203 | | template <> struct stream_char_common< boost::uint128_type > |
204 | | { |
205 | | using type = char; |
206 | | }; |
207 | | #endif |
208 | | |
209 | | #if !defined(BOOST_LCAST_NO_WCHAR_T) && defined(BOOST_NO_INTRINSIC_WCHAR_T) |
210 | | template <> |
211 | | struct stream_char_common< wchar_t > |
212 | | { |
213 | | using type = char; |
214 | | }; |
215 | | #endif |
216 | | } |
217 | | |
218 | | namespace detail // deduce_source_char_impl<T> |
219 | | { |
220 | | // If type T is `deduce_character_type_later` type, then tries to deduce |
221 | | // character type using streaming metafunctions. |
222 | | // Otherwise supplied type T is a character type, that must be normalized |
223 | | // using normalize_single_byte_char<Char>. |
224 | | // Executed at Stage 2 (See deduce_source_char<T> and deduce_target_char<T>) |
225 | | template < class Char > |
226 | | struct deduce_source_char_impl |
227 | | { |
228 | | typedef typename boost::detail::normalize_single_byte_char< Char >::type type; |
229 | | }; |
230 | | |
231 | | template < class T > |
232 | | struct deduce_source_char_impl< deduce_character_type_later< T > > |
233 | | { |
234 | | template <class U> |
235 | | static auto left_shift_type(long) |
236 | | -> decltype( std::declval<std::basic_ostream< char >&>() << std::declval<const U&>(), char{}); |
237 | | |
238 | | #if !defined(BOOST_LCAST_NO_WCHAR_T) |
239 | | template <class U> |
240 | | static auto left_shift_type(int) |
241 | | -> decltype( std::declval<std::basic_ostream< wchar_t >&>() << std::declval<const U&>(), wchar_t{}); |
242 | | #endif |
243 | | |
244 | | template <class U> |
245 | | static void left_shift_type(...); |
246 | | |
247 | | using type = decltype(left_shift_type<T>(1L)); |
248 | | |
249 | | static_assert(!std::is_same<type, void>::value, |
250 | | #if defined(BOOST_LCAST_NO_WCHAR_T) |
251 | | "Source type is not std::ostream`able and std::wostream`s are " |
252 | | "not supported by your STL implementation" |
253 | | #else |
254 | | "Source type is neither std::ostream`able nor std::wostream`able" |
255 | | #endif |
256 | | ); |
257 | | }; |
258 | | } |
259 | | |
260 | | namespace detail // deduce_target_char_impl<T> |
261 | | { |
262 | | // If type T is `deduce_character_type_later` type, then tries to deduce |
263 | | // character type using boost::has_right_shift<T> metafunction. |
264 | | // Otherwise supplied type T is a character type, that must be normalized |
265 | | // using normalize_single_byte_char<Char>. |
266 | | // Executed at Stage 2 (See deduce_source_char<T> and deduce_target_char<T>) |
267 | | template < class Char > |
268 | | struct deduce_target_char_impl |
269 | | { |
270 | | typedef typename normalize_single_byte_char< Char >::type type; |
271 | | }; |
272 | | |
273 | | template < class T > |
274 | | struct deduce_target_char_impl< deduce_character_type_later<T> > |
275 | | { |
276 | | template <class U> |
277 | | static auto right_shift_type(long) |
278 | | -> decltype( std::declval<std::basic_istream< char >&>() >> std::declval<U&>(), char{}); |
279 | | |
280 | | #if !defined(BOOST_LCAST_NO_WCHAR_T) |
281 | | template <class U> |
282 | | static auto right_shift_type(int) |
283 | | -> decltype( std::declval<std::basic_istream< wchar_t >&>() >> std::declval<U&>(), wchar_t{}); |
284 | | #endif |
285 | | |
286 | | template <class U> |
287 | | static void right_shift_type(...); |
288 | | |
289 | | using type = decltype(right_shift_type<T>(1L)); |
290 | | |
291 | | static_assert(!std::is_same<type, void>::value, |
292 | | #if defined(BOOST_LCAST_NO_WCHAR_T) |
293 | | "Target type is not std::istream`able and std::wistream`s are " |
294 | | "not supported by your STL implementation" |
295 | | #else |
296 | | "Target type is neither std::istream`able nor std::wistream`able" |
297 | | #endif |
298 | | ); |
299 | | }; |
300 | | } |
301 | | |
302 | | namespace detail // deduce_target_char<T> and deduce_source_char<T> |
303 | | { |
304 | | // We deduce stream character types in two stages. |
305 | | // |
306 | | // Stage 1 is common for Target and Source. At Stage 1 we get |
307 | | // non normalized character type (may contain unsigned/signed char) |
308 | | // or deduce_character_type_later<T> where T is the original type. |
309 | | // Stage 1 is executed by stream_char_common<T> |
310 | | // |
311 | | // At Stage 2 we normalize character types or try to deduce character |
312 | | // type using metafunctions. |
313 | | // Stage 2 is executed by deduce_target_char_impl<T> and |
314 | | // deduce_source_char_impl<T> |
315 | | // |
316 | | // deduce_target_char<T> and deduce_source_char<T> functions combine |
317 | | // both stages |
318 | | |
319 | | template < class T > |
320 | | struct deduce_target_char |
321 | | { |
322 | | typedef typename stream_char_common< T >::type stage1_type; |
323 | | typedef typename deduce_target_char_impl< stage1_type >::type type; |
324 | | }; |
325 | | |
326 | | template < class T > |
327 | | struct deduce_source_char |
328 | | { |
329 | | typedef typename stream_char_common< T >::type stage1_type; |
330 | | typedef typename deduce_source_char_impl< stage1_type >::type type; |
331 | | }; |
332 | | } |
333 | | |
334 | | namespace detail // array_to_pointer_decay<T> |
335 | | { |
336 | | template<class T> |
337 | | struct array_to_pointer_decay |
338 | | { |
339 | | typedef T type; |
340 | | }; |
341 | | |
342 | | template<class T, std::size_t N> |
343 | | struct array_to_pointer_decay<T[N]> |
344 | | { |
345 | | typedef const T * type; |
346 | | }; |
347 | | } |
348 | | |
349 | | namespace detail // lcast_src_length |
350 | | { |
351 | | // Return max. length of string representation of Source; |
352 | | template< class Source, // Source type of lexical_cast. |
353 | | class Enable = void // helper type |
354 | | > |
355 | | struct lcast_src_length |
356 | | { |
357 | | BOOST_STATIC_CONSTANT(std::size_t, value = 1); |
358 | | }; |
359 | | |
360 | | // Helper for integral types. |
361 | | // Notes on length calculation: |
362 | | // Max length for 32bit int with grouping "\1" and thousands_sep ',': |
363 | | // "-2,1,4,7,4,8,3,6,4,7" |
364 | | // ^ - is_signed |
365 | | // ^ - 1 digit not counted by digits10 |
366 | | // ^^^^^^^^^^^^^^^^^^ - digits10 * 2 |
367 | | // |
368 | | // Constant is_specialized is used instead of constant 1 |
369 | | // to prevent buffer overflow in a rare case when |
370 | | // <boost/limits.hpp> doesn't add missing specialization for |
371 | | // numeric_limits<T> for some integral type T. |
372 | | // When is_specialized is false, the whole expression is 0. |
373 | | template <class Source> |
374 | | struct lcast_src_length< |
375 | | Source, typename std::enable_if<boost::detail::lcast::is_integral<Source>::value >::type |
376 | | > |
377 | | { |
378 | | BOOST_STATIC_CONSTANT(std::size_t, value = |
379 | | std::numeric_limits<Source>::is_signed + |
380 | | std::numeric_limits<Source>::is_specialized + /* == 1 */ |
381 | | std::numeric_limits<Source>::digits10 * 2 |
382 | | ); |
383 | | }; |
384 | | |
385 | | // Helper for floating point types. |
386 | | // -1.23456789e-123456 |
387 | | // ^ sign |
388 | | // ^ leading digit |
389 | | // ^ decimal point |
390 | | // ^^^^^^^^ lcast_precision<Source>::value |
391 | | // ^ "e" |
392 | | // ^ exponent sign |
393 | | // ^^^^^^ exponent (assumed 6 or less digits) |
394 | | // sign + leading digit + decimal point + "e" + exponent sign == 5 |
395 | | template<class Source> |
396 | | struct lcast_src_length< |
397 | | Source, typename std::enable_if<std::is_floating_point<Source>::value >::type |
398 | | > |
399 | | { |
400 | | static_assert( |
401 | | std::numeric_limits<Source>::max_exponent10 <= 999999L && |
402 | | std::numeric_limits<Source>::min_exponent10 >= -999999L |
403 | | , ""); |
404 | | |
405 | | BOOST_STATIC_CONSTANT(std::size_t, value = |
406 | | 5 + lcast_precision<Source>::value + 6 |
407 | | ); |
408 | | }; |
409 | | } |
410 | | |
411 | | namespace detail // lexical_cast_stream_traits<Source, Target> |
412 | | { |
413 | | template <class Source, class Target> |
414 | | struct lexical_cast_stream_traits { |
415 | | typedef typename boost::detail::array_to_pointer_decay<Source>::type src; |
416 | | typedef typename std::remove_cv<src>::type no_cv_src; |
417 | | |
418 | | typedef boost::detail::deduce_source_char<no_cv_src> deduce_src_char_metafunc; |
419 | | typedef typename deduce_src_char_metafunc::type src_char_t; |
420 | | typedef typename boost::detail::deduce_target_char<Target>::type target_char_t; |
421 | | |
422 | | typedef typename boost::detail::widest_char< |
423 | | target_char_t, src_char_t |
424 | | >::type char_type; |
425 | | |
426 | | #if !defined(BOOST_NO_CXX11_CHAR16_T) && defined(BOOST_NO_CXX11_UNICODE_LITERALS) |
427 | | static_assert(!std::is_same<char16_t, src_char_t>::value |
428 | | && !std::is_same<char16_t, target_char_t>::value, |
429 | | "Your compiler does not have full support for char16_t" ); |
430 | | #endif |
431 | | #if !defined(BOOST_NO_CXX11_CHAR32_T) && defined(BOOST_NO_CXX11_UNICODE_LITERALS) |
432 | | static_assert(!std::is_same<char32_t, src_char_t>::value |
433 | | && !std::is_same<char32_t, target_char_t>::value, |
434 | | "Your compiler does not have full support for char32_t" ); |
435 | | #endif |
436 | | |
437 | | typedef std::char_traits<char_type> traits; |
438 | | |
439 | | typedef boost::detail::lcast_src_length<no_cv_src> len_t; |
440 | | }; |
441 | | } |
442 | | |
443 | | namespace detail |
444 | | { |
445 | | template<typename Target, typename Source> |
446 | | struct lexical_converter_impl |
447 | | { |
448 | | typedef lexical_cast_stream_traits<Source, Target> stream_trait; |
449 | | |
450 | | typedef detail::lcast::optimized_src_stream< |
451 | | typename stream_trait::char_type, |
452 | | typename stream_trait::traits, |
453 | | stream_trait::len_t::value + 1 |
454 | | > optimized_src_stream; |
455 | | |
456 | | template <class T> |
457 | | static auto detect_type(int) |
458 | | -> decltype(std::declval<optimized_src_stream&>().stream_in(std::declval<lcast::exact<T>>()), optimized_src_stream{}); |
459 | | |
460 | | template <class T> |
461 | | static lcast::ios_src_stream<typename stream_trait::char_type, typename stream_trait::traits> detect_type(...); |
462 | | |
463 | | using from_src_stream = decltype(detect_type<Source>(1)); |
464 | | |
465 | | typedef detail::lcast::to_target_stream< |
466 | | typename stream_trait::char_type, |
467 | | typename stream_trait::traits |
468 | | > to_target_stream; |
469 | | |
470 | 140k | static inline bool try_convert(const Source& arg, Target& result) { |
471 | 140k | from_src_stream src_stream; |
472 | 140k | if (!src_stream.stream_in(lcast::exact<Source>{arg})) |
473 | 0 | return false; |
474 | | |
475 | 140k | to_target_stream out(src_stream.cbegin(), src_stream.cend()); |
476 | 140k | if (!out.stream_out(result)) |
477 | 1.35k | return false; |
478 | | |
479 | 139k | return true; |
480 | 140k | } boost::detail::lexical_converter_impl<bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::try_convert(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool&) Line | Count | Source | 470 | 6.30k | static inline bool try_convert(const Source& arg, Target& result) { | 471 | 6.30k | from_src_stream src_stream; | 472 | 6.30k | if (!src_stream.stream_in(lcast::exact<Source>{arg})) | 473 | 0 | return false; | 474 | | | 475 | 6.30k | to_target_stream out(src_stream.cbegin(), src_stream.cend()); | 476 | 6.30k | if (!out.stream_out(result)) | 477 | 171 | return false; | 478 | | | 479 | 6.13k | return true; | 480 | 6.30k | } |
boost::detail::lexical_converter_impl<int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::try_convert(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int&) Line | Count | Source | 470 | 3.27k | static inline bool try_convert(const Source& arg, Target& result) { | 471 | 3.27k | from_src_stream src_stream; | 472 | 3.27k | if (!src_stream.stream_in(lcast::exact<Source>{arg})) | 473 | 0 | return false; | 474 | | | 475 | 3.27k | to_target_stream out(src_stream.cbegin(), src_stream.cend()); | 476 | 3.27k | if (!out.stream_out(result)) | 477 | 263 | return false; | 478 | | | 479 | 3.01k | return true; | 480 | 3.27k | } |
boost::detail::lexical_converter_impl<long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::try_convert(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, long&) Line | Count | Source | 470 | 2.30k | static inline bool try_convert(const Source& arg, Target& result) { | 471 | 2.30k | from_src_stream src_stream; | 472 | 2.30k | if (!src_stream.stream_in(lcast::exact<Source>{arg})) | 473 | 0 | return false; | 474 | | | 475 | 2.30k | to_target_stream out(src_stream.cbegin(), src_stream.cend()); | 476 | 2.30k | if (!out.stream_out(result)) | 477 | 125 | return false; | 478 | | | 479 | 2.17k | return true; | 480 | 2.30k | } |
boost::detail::lexical_converter_impl<float, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::try_convert(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, float&) Line | Count | Source | 470 | 6.14k | static inline bool try_convert(const Source& arg, Target& result) { | 471 | 6.14k | from_src_stream src_stream; | 472 | 6.14k | if (!src_stream.stream_in(lcast::exact<Source>{arg})) | 473 | 0 | return false; | 474 | | | 475 | 6.14k | to_target_stream out(src_stream.cbegin(), src_stream.cend()); | 476 | 6.14k | if (!out.stream_out(result)) | 477 | 366 | return false; | 478 | | | 479 | 5.77k | return true; | 480 | 6.14k | } |
boost::detail::lexical_converter_impl<double, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::try_convert(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, double&) Line | Count | Source | 470 | 7.97k | static inline bool try_convert(const Source& arg, Target& result) { | 471 | 7.97k | from_src_stream src_stream; | 472 | 7.97k | if (!src_stream.stream_in(lcast::exact<Source>{arg})) | 473 | 0 | return false; | 474 | | | 475 | 7.97k | to_target_stream out(src_stream.cbegin(), src_stream.cend()); | 476 | 7.97k | if (!out.stream_out(result)) | 477 | 294 | return false; | 478 | | | 479 | 7.67k | return true; | 480 | 7.97k | } |
boost::detail::lexical_converter_impl<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::try_convert(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) Line | Count | Source | 470 | 2.15k | static inline bool try_convert(const Source& arg, Target& result) { | 471 | 2.15k | from_src_stream src_stream; | 472 | 2.15k | if (!src_stream.stream_in(lcast::exact<Source>{arg})) | 473 | 0 | return false; | 474 | | | 475 | 2.15k | to_target_stream out(src_stream.cbegin(), src_stream.cend()); | 476 | 2.15k | if (!out.stream_out(result)) | 477 | 0 | return false; | 478 | | | 479 | 2.15k | return true; | 480 | 2.15k | } |
boost::detail::lexical_converter_impl<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, bool>::try_convert(bool const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) Line | Count | Source | 470 | 23.8k | static inline bool try_convert(const Source& arg, Target& result) { | 471 | 23.8k | from_src_stream src_stream; | 472 | 23.8k | if (!src_stream.stream_in(lcast::exact<Source>{arg})) | 473 | 0 | return false; | 474 | | | 475 | 23.8k | to_target_stream out(src_stream.cbegin(), src_stream.cend()); | 476 | 23.8k | if (!out.stream_out(result)) | 477 | 0 | return false; | 478 | | | 479 | 23.8k | return true; | 480 | 23.8k | } |
boost::detail::lexical_converter_impl<unsigned short, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >::try_convert(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned short&) Line | Count | Source | 470 | 895 | static inline bool try_convert(const Source& arg, Target& result) { | 471 | 895 | from_src_stream src_stream; | 472 | 895 | if (!src_stream.stream_in(lcast::exact<Source>{arg})) | 473 | 0 | return false; | 474 | | | 475 | 895 | to_target_stream out(src_stream.cbegin(), src_stream.cend()); | 476 | 895 | if (!out.stream_out(result)) | 477 | 134 | return false; | 478 | | | 479 | 761 | return true; | 480 | 895 | } |
boost::detail::lexical_converter_impl<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, int>::try_convert(int const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) Line | Count | Source | 470 | 83.8k | static inline bool try_convert(const Source& arg, Target& result) { | 471 | 83.8k | from_src_stream src_stream; | 472 | 83.8k | if (!src_stream.stream_in(lcast::exact<Source>{arg})) | 473 | 0 | return false; | 474 | | | 475 | 83.8k | to_target_stream out(src_stream.cbegin(), src_stream.cend()); | 476 | 83.8k | if (!out.stream_out(result)) | 477 | 0 | return false; | 478 | | | 479 | 83.8k | return true; | 480 | 83.8k | } |
boost::detail::lexical_converter_impl<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, boost::read_graphviz_detail::token>::try_convert(boost::read_graphviz_detail::token const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) Line | Count | Source | 470 | 3.62k | static inline bool try_convert(const Source& arg, Target& result) { | 471 | 3.62k | from_src_stream src_stream; | 472 | 3.62k | if (!src_stream.stream_in(lcast::exact<Source>{arg})) | 473 | 0 | return false; | 474 | | | 475 | 3.62k | to_target_stream out(src_stream.cbegin(), src_stream.cend()); | 476 | 3.62k | if (!out.stream_out(result)) | 477 | 0 | return false; | 478 | | | 479 | 3.62k | return true; | 480 | 3.62k | } |
|
481 | | }; |
482 | | } |
483 | | |
484 | | } // namespace boost |
485 | | |
486 | | #undef BOOST_LCAST_NO_WCHAR_T |
487 | | |
488 | | #endif // #if !defined(BOOST_USE_MODULES) || defined(BOOST_LEXICAL_CAST_INTERFACE_UNIT) |
489 | | |
490 | | #endif // BOOST_LEXICAL_CAST_DETAIL_CONVERTER_LEXICAL_HPP |
491 | | |