Warning, file /include/boost/lexical_cast/try_lexical_convert.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #ifndef BOOST_LEXICAL_CAST_TRY_LEXICAL_CONVERT_HPP
0019 #define BOOST_LEXICAL_CAST_TRY_LEXICAL_CONVERT_HPP
0020
0021 #include <boost/config.hpp>
0022 #ifdef BOOST_HAS_PRAGMA_ONCE
0023 # pragma once
0024 #endif
0025
0026 #include <boost/type_traits/conditional.hpp>
0027 #include <boost/type_traits/is_arithmetic.hpp>
0028
0029 #include <boost/lexical_cast/detail/buffer_view.hpp>
0030 #include <boost/lexical_cast/detail/is_character.hpp>
0031 #include <boost/lexical_cast/detail/converter_numeric.hpp>
0032 #include <boost/lexical_cast/detail/converter_lexical.hpp>
0033
0034 namespace boost {
0035 namespace detail
0036 {
0037 template<typename Target, typename Source>
0038 using is_arithmetic_and_not_xchars = boost::integral_constant<
0039 bool,
0040 !(boost::detail::is_character<Target>::value) &&
0041 !(boost::detail::is_character<Source>::value) &&
0042 boost::is_arithmetic<Source>::value &&
0043 boost::is_arithmetic<Target>::value
0044 >;
0045 }
0046
0047 namespace conversion { namespace detail {
0048
0049 template <typename Target, typename Source>
0050 inline bool try_lexical_convert(const Source& arg, Target& result)
0051 {
0052 static_assert(
0053 !boost::is_volatile<Source>::value,
0054 "Boost.LexicalCast does not support volatile input");
0055
0056 typedef typename boost::detail::array_to_pointer_decay<Source>::type src;
0057
0058 typedef boost::detail::is_arithmetic_and_not_xchars<Target, src >
0059 shall_we_copy_with_dynamic_check_t;
0060
0061 typedef typename boost::conditional<
0062 shall_we_copy_with_dynamic_check_t::value,
0063 boost::detail::dynamic_num_converter_impl<Target, src >,
0064 boost::detail::lexical_converter_impl<Target, src >
0065 >::type caster_type;
0066
0067 return caster_type::try_convert(arg, result);
0068 }
0069
0070 template <typename Target, typename CharacterT>
0071 inline bool try_lexical_convert(const CharacterT* chars, std::size_t count, Target& result)
0072 {
0073 static_assert(
0074 boost::detail::is_character<CharacterT>::value,
0075 "This overload of try_lexical_convert is meant to be used only with arrays of characters."
0076 );
0077 return ::boost::conversion::detail::try_lexical_convert(
0078 ::boost::conversion::detail::make_buffer_view(chars, chars + count),
0079 result
0080 );
0081 }
0082
0083 }}
0084
0085 namespace conversion {
0086
0087 using ::boost::conversion::detail::try_lexical_convert;
0088 }
0089
0090 }
0091
0092 #endif
0093