diff options
author | Ben Longbons <b.r.longbons@gmail.com> | 2014-06-27 19:16:45 -0700 |
---|---|---|
committer | Ben Longbons <b.r.longbons@gmail.com> | 2014-06-27 19:33:42 -0700 |
commit | 7af4c5b5c561362cb1135ab504095ae667a9270a (patch) | |
tree | 49ffd3008d7634ba36f3951493a68e928407ce89 /src/ints/udl.hpp | |
parent | 8d7f1dadeeb1dc1609b72de5a4ee3a5247b0e9e6 (diff) | |
download | tmwa-7af4c5b5c561362cb1135ab504095ae667a9270a.tar.gz tmwa-7af4c5b5c561362cb1135ab504095ae667a9270a.tar.bz2 tmwa-7af4c5b5c561362cb1135ab504095ae667a9270a.tar.xz tmwa-7af4c5b5c561362cb1135ab504095ae667a9270a.zip |
This is more reliable
Diffstat (limited to 'src/ints/udl.hpp')
-rw-r--r-- | src/ints/udl.hpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/ints/udl.hpp b/src/ints/udl.hpp index 8d18766..f85a186 100644 --- a/src/ints/udl.hpp +++ b/src/ints/udl.hpp @@ -1,5 +1,4 @@ -#ifndef TMWA_INTS_UDL_HPP -#define TMWA_INTS_UDL_HPP +#pragma once // udl.hpp - user-defined literals for integers. // // Copyright © 2014 Ben Longbons <b.r.longbons@gmail.com> @@ -19,11 +18,11 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. -# include "fwd.hpp" +#include "fwd.hpp" -# include <cstdint> +#include <cstdint> -# include <type_traits> +#include <type_traits> namespace tmwa @@ -129,12 +128,12 @@ namespace ints { typedef typename std::make_unsigned<T>::type U; // boo, body of constexpr function can't use variables -# define is_signed bool(T(-1) < T(0)) +#define is_signed bool(T(-1) < T(0)) static_assert(is_signed >= (sign && magnitude), "signed"); -# define max ullong(ullong(U(-1) >> is_signed)) +#define max ullong(ullong(U(-1) >> is_signed)) static_assert(magnitude <= max || (sign && magnitude == max + 1), "magna"); -# undef is_signed -# undef max +#undef is_signed +#undef max return sign ? T(ullong(-magnitude)) : T(magnitude); } }; @@ -226,5 +225,3 @@ using ints::operator "" _n16; using ints::operator "" _n32; using ints::operator "" _n64; } // namespace tmwa - -#endif // TMWA_INTS_UDL_HPP |