File indexing completed on 2025-04-19 08:19:39
0001
0002
0003
0004
0005 #ifndef BOOST_CHARCONV_DETAIL_APPLY_SIGN_HPP
0006 #define BOOST_CHARCONV_DETAIL_APPLY_SIGN_HPP
0007
0008 #include <boost/config.hpp>
0009 #include <boost/charconv/detail/emulated128.hpp>
0010 #include <boost/charconv/detail/type_traits.hpp>
0011 #include <type_traits>
0012
0013
0014 #ifdef BOOST_MSVC
0015 # pragma warning(push)
0016 # pragma warning(disable: 4146)
0017 #elif defined(__GNUC__) && __GNUC__ >= 5
0018 # pragma GCC diagnostic push
0019 # pragma GCC diagnostic ignored "-Wconversion"
0020 #elif defined(__clang__)
0021 # pragma clang diagnostic push
0022 # pragma clang diagnostic ignored "-Wconversion"
0023 #endif
0024
0025 namespace boost { namespace charconv { namespace detail {
0026
0027 template <typename Integer, typename Unsigned_Integer = detail::make_unsigned_t<Integer>,
0028 typename std::enable_if<detail::is_signed<Integer>::value, bool>::type = true>
0029 constexpr Unsigned_Integer apply_sign(Integer val) noexcept
0030 {
0031 return -(static_cast<Unsigned_Integer>(val));
0032 }
0033
0034 template <typename Unsigned_Integer, typename std::enable_if<!detail::is_signed<Unsigned_Integer>::value, bool>::type = true>
0035 constexpr Unsigned_Integer apply_sign(Unsigned_Integer val) noexcept
0036 {
0037 return val;
0038 }
0039
0040 }}}
0041
0042 #ifdef BOOST_MSVC
0043 # pragma warning(pop)
0044 #elif defined(__GNUC__) && __GNUC__ >= 5
0045 # pragma GCC diagnostic pop
0046 #elif defined(__clang__)
0047 # pragma clang diagnostic pop
0048 #endif
0049
0050 #endif