/* ***************************************************************************** * %{QMAKE_PROJECT_NAME} * Copyright (c) %YEAR% killerbee * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * ****************************************************************************/ #ifndef INTS_H #define INTS_H #include #include #define DECL_INT_T(bits) \ using i##bits = std::int##bits##_t; \ using u##bits = std::uint##bits##_t; \ constexpr inline auto operator""_i##bits(unsigned long long a)->i##bits { \ return static_cast(a); \ } \ constexpr inline auto operator""_u##bits(unsigned long long a)->u##bits { \ return static_cast(a); \ } DECL_INT_T(8) DECL_INT_T(16) DECL_INT_T(32) DECL_INT_T(64) #undef DECL_INT_T #ifdef __GNUC__ using i128 = __int128_t; using u128 = __uint128_t; #else #error must have 128-bit integers #endif template constexpr auto operator""_i128() { constexpr char arr[] = {Cs...}; return kblib::parse_integer(arr); } template constexpr auto operator""_u128() { constexpr char arr[] = {Cs...}; return kblib::parse_integer(arr); } #endif // INTS_H