| 1 | 14,15c14,15
|
|---|
| 2 | < // Alexander Nasonov and other Boosters
|
|---|
| 3 | < // when: November 2000, March 2003, June 2005, June 2006
|
|---|
| 4 | ---
|
|---|
| 5 | > // Alexander Nasonov, Antony Polukhin and other Boosters
|
|---|
| 6 | > // when: November 2000, March 2003, June 2005, June 2006, March 2011
|
|---|
| 7 | 27a28,31
|
|---|
| 8 | > #include <boost/type_traits/is_integral.hpp>
|
|---|
| 9 | > #include <boost/type_traits/is_arithmetic.hpp>
|
|---|
| 10 | > #include <boost/numeric/conversion/conversion_traits.hpp>
|
|---|
| 11 | > #include <boost/type_traits/ice.hpp>
|
|---|
| 12 | 1163a1168,1303
|
|---|
| 13 | >
|
|---|
| 14 | > template<typename T>
|
|---|
| 15 | > struct is_stdstring
|
|---|
| 16 | > {
|
|---|
| 17 | > BOOST_STATIC_CONSTANT(bool, value = false );
|
|---|
| 18 | > };
|
|---|
| 19 | >
|
|---|
| 20 | > template<typename CharT, typename Traits, typename Alloc>
|
|---|
| 21 | > struct is_stdstring< std::basic_string<CharT, Traits, Alloc> >
|
|---|
| 22 | > {
|
|---|
| 23 | > BOOST_STATIC_CONSTANT(bool, value = true );
|
|---|
| 24 | > };
|
|---|
| 25 | >
|
|---|
| 26 | > template<typename T>
|
|---|
| 27 | > struct is_char_or_wchar
|
|---|
| 28 | > {
|
|---|
| 29 | > #ifndef BOOST_LCAST_NO_WCHAR_T
|
|---|
| 30 | > BOOST_STATIC_CONSTANT(bool, value =
|
|---|
| 31 | > (
|
|---|
| 32 | > ::boost::type_traits::ice_or<
|
|---|
| 33 | > is_same< T, char >::value,
|
|---|
| 34 | > is_same< T, wchar_t >::value
|
|---|
| 35 | > >::value
|
|---|
| 36 | > )
|
|---|
| 37 | > );
|
|---|
| 38 | > #else
|
|---|
| 39 | > BOOST_STATIC_CONSTANT(bool, value =
|
|---|
| 40 | > (is_same< T, char >::value)
|
|---|
| 41 | > );
|
|---|
| 42 | > #endif
|
|---|
| 43 | >
|
|---|
| 44 | > };
|
|---|
| 45 | >
|
|---|
| 46 | > template<bool IsArithmetic,typename Target, typename Source>
|
|---|
| 47 | > struct is_safe_arithmetic_to_arithmetic_impl
|
|---|
| 48 | > {
|
|---|
| 49 | > BOOST_STATIC_CONSTANT(bool, value = false);
|
|---|
| 50 | > };
|
|---|
| 51 | >
|
|---|
| 52 | > template<typename Target, typename Source>
|
|---|
| 53 | > struct is_safe_arithmetic_to_arithmetic_impl<true,Target,Source>
|
|---|
| 54 | > {
|
|---|
| 55 | > BOOST_STATIC_CONSTANT(bool, value =
|
|---|
| 56 | > (
|
|---|
| 57 | > ::boost::type_traits::ice_and<
|
|---|
| 58 | > ::boost::type_traits::ice_not<
|
|---|
| 59 | > boost::numeric::conversion_traits<Target,Source>::subranged::value
|
|---|
| 60 | > >::value,
|
|---|
| 61 | >
|
|---|
| 62 | > ::boost::type_traits::ice_not<
|
|---|
| 63 | > is_char_or_wchar<Source>::value
|
|---|
| 64 | > >::value,
|
|---|
| 65 | > ::boost::type_traits::ice_not<
|
|---|
| 66 | > is_char_or_wchar<Target>::value
|
|---|
| 67 | > >::value
|
|---|
| 68 | > >::value
|
|---|
| 69 | > )
|
|---|
| 70 | > );
|
|---|
| 71 | > };
|
|---|
| 72 | >
|
|---|
| 73 | > template<typename Target, typename Source>
|
|---|
| 74 | > struct is_safe_arithmetic_to_arithmetic
|
|---|
| 75 | > {
|
|---|
| 76 | > BOOST_STATIC_CONSTANT(bool, value =
|
|---|
| 77 | > (
|
|---|
| 78 | > is_safe_arithmetic_to_arithmetic_impl<
|
|---|
| 79 | > ::boost::type_traits::ice_and<
|
|---|
| 80 | > is_arithmetic<Source>::value,
|
|---|
| 81 | > is_arithmetic<Target>::value
|
|---|
| 82 | > >::value,
|
|---|
| 83 | > Target,
|
|---|
| 84 | > Source
|
|---|
| 85 | > >::value
|
|---|
| 86 | > )
|
|---|
| 87 | > );
|
|---|
| 88 | > };
|
|---|
| 89 | >
|
|---|
| 90 | > template<typename Target, typename Source>
|
|---|
| 91 | > struct is_xchar_to_xchar
|
|---|
| 92 | > {
|
|---|
| 93 | > BOOST_STATIC_CONSTANT(bool, value =
|
|---|
| 94 | > (
|
|---|
| 95 | > ::boost::type_traits::ice_and<
|
|---|
| 96 | > is_same<Source,Target>::value,
|
|---|
| 97 | > is_char_or_wchar<Target>::value
|
|---|
| 98 | > >::value
|
|---|
| 99 | > )
|
|---|
| 100 | > );
|
|---|
| 101 | > };
|
|---|
| 102 | >
|
|---|
| 103 | > template<typename Target, typename Source>
|
|---|
| 104 | > struct is_char_array_to_stdstring
|
|---|
| 105 | > {
|
|---|
| 106 | > BOOST_STATIC_CONSTANT(bool, value = false );
|
|---|
| 107 | > };
|
|---|
| 108 | >
|
|---|
| 109 | > template<typename CharT, typename Traits, typename Alloc>
|
|---|
| 110 | > struct is_char_array_to_stdstring< std::basic_string<CharT, Traits, Alloc>, CharT* >
|
|---|
| 111 | > {
|
|---|
| 112 | > BOOST_STATIC_CONSTANT(bool, value = true );
|
|---|
| 113 | > };
|
|---|
| 114 | >
|
|---|
| 115 | > template<typename CharT, typename Traits, typename Alloc>
|
|---|
| 116 | > struct is_char_array_to_stdstring< std::basic_string<CharT, Traits, Alloc>, const CharT* >
|
|---|
| 117 | > {
|
|---|
| 118 | > BOOST_STATIC_CONSTANT(bool, value = true );
|
|---|
| 119 | > };
|
|---|
| 120 | >
|
|---|
| 121 | > template<typename Target, typename Source>
|
|---|
| 122 | > struct lexical_cast_do_cast
|
|---|
| 123 | > {
|
|---|
| 124 | > static inline Target lexical_cast_impl(const Source &arg)
|
|---|
| 125 | > {
|
|---|
| 126 | > typedef typename detail::array_to_pointer_decay<Source>::type src;
|
|---|
| 127 | >
|
|---|
| 128 | > typedef typename detail::widest_char<
|
|---|
| 129 | > typename detail::stream_char<Target>::type
|
|---|
| 130 | > , typename detail::stream_char<src>::type
|
|---|
| 131 | > >::type char_type;
|
|---|
| 132 | >
|
|---|
| 133 | > typedef detail::lcast_src_length<char_type, src> lcast_src_length;
|
|---|
| 134 | > std::size_t const src_len = lcast_src_length::value;
|
|---|
| 135 | > char_type buf[src_len + 1];
|
|---|
| 136 | > lcast_src_length::check_coverage();
|
|---|
| 137 | > return detail::lexical_cast<Target, src, !src_len>(arg, buf, src_len);
|
|---|
| 138 | > }
|
|---|
| 139 | > };
|
|---|
| 140 | >
|
|---|
| 141 | > template<typename Source>
|
|---|
| 142 | > struct lexical_cast_copy
|
|---|
| 143 | > {
|
|---|
| 144 | > static inline Source lexical_cast_impl(const Source &arg)
|
|---|
| 145 | > {
|
|---|
| 146 | > return arg;
|
|---|
| 147 | > }
|
|---|
| 148 | > };
|
|---|
| 149 | 1169c1309,1325
|
|---|
| 150 | < typedef typename detail::array_to_pointer_decay<Source>::type src;
|
|---|
| 151 | ---
|
|---|
| 152 | > typedef BOOST_DEDUCED_TYPENAME detail::array_to_pointer_decay<Source>::type src;
|
|---|
| 153 | >
|
|---|
| 154 | > typedef BOOST_DEDUCED_TYPENAME ::boost::type_traits::ice_or<
|
|---|
| 155 | > detail::is_safe_arithmetic_to_arithmetic<Target, Source>::value,
|
|---|
| 156 | > detail::is_xchar_to_xchar<Target, Source>::value,
|
|---|
| 157 | > detail::is_char_array_to_stdstring<Target,src>::value,
|
|---|
| 158 | > ::boost::type_traits::ice_and<
|
|---|
| 159 | > is_same<Target, src>::value,
|
|---|
| 160 | > detail::is_stdstring<Target>::value
|
|---|
| 161 | > >::value
|
|---|
| 162 | > > do_copy_type;
|
|---|
| 163 | >
|
|---|
| 164 | > typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_c<
|
|---|
| 165 | > do_copy_type::value,
|
|---|
| 166 | > detail::lexical_cast_copy<src>,
|
|---|
| 167 | > detail::lexical_cast_do_cast<Target, Source>
|
|---|
| 168 | > >::type caster_type;
|
|---|
| 169 | 1171,1180c1327
|
|---|
| 170 | < typedef typename detail::widest_char<
|
|---|
| 171 | < typename detail::stream_char<Target>::type
|
|---|
| 172 | < , typename detail::stream_char<src>::type
|
|---|
| 173 | < >::type char_type;
|
|---|
| 174 | <
|
|---|
| 175 | < typedef detail::lcast_src_length<char_type, src> lcast_src_length;
|
|---|
| 176 | < std::size_t const src_len = lcast_src_length::value;
|
|---|
| 177 | < char_type buf[src_len + 1];
|
|---|
| 178 | < lcast_src_length::check_coverage();
|
|---|
| 179 | < return detail::lexical_cast<Target, src, !src_len>(arg, buf, src_len);
|
|---|
| 180 | ---
|
|---|
| 181 | > return caster_type::lexical_cast_impl(arg);
|
|---|