From 7af4c5b5c561362cb1135ab504095ae667a9270a Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Fri, 27 Jun 2014 19:16:45 -0700 Subject: This is more reliable --- src/ints/udl.hpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src/ints/udl.hpp') 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 @@ -19,11 +18,11 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -# include "fwd.hpp" +#include "fwd.hpp" -# include +#include -# include +#include namespace tmwa @@ -129,12 +128,12 @@ namespace ints { typedef typename std::make_unsigned::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 -- cgit v1.2.3-70-g09d2