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/cmp.hpp | 15 ++++++--------- src/ints/fwd.hpp | 7 ++----- src/ints/little.hpp | 17 +++++++---------- src/ints/udl.hpp | 19 ++++++++----------- src/ints/wrap.hpp | 11 ++++------- 5 files changed, 27 insertions(+), 42 deletions(-) (limited to 'src/ints') diff --git a/src/ints/cmp.hpp b/src/ints/cmp.hpp index 8839899..16384e6 100644 --- a/src/ints/cmp.hpp +++ b/src/ints/cmp.hpp @@ -1,5 +1,4 @@ -#ifndef TMWA_INTS_CMP_HPP -#define TMWA_INTS_CMP_HPP +#pragma once // cmp.hpp - comparison related operations // // Copyright © 2014 Ben Longbons @@ -19,17 +18,17 @@ // 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 namespace tmwa { namespace ints { -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wtype-limits" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wtype-limits" template T saturate(const U& v) { @@ -63,10 +62,8 @@ namespace ints return v; } } -# pragma GCC diagnostic pop +#pragma GCC diagnostic pop } // namespace ints using ints::saturate; } // namespace tmwa - -#endif // TMWA_INTS_CMP_HPP diff --git a/src/ints/fwd.hpp b/src/ints/fwd.hpp index 650e859..a08e546 100644 --- a/src/ints/fwd.hpp +++ b/src/ints/fwd.hpp @@ -1,5 +1,4 @@ -#ifndef TMWA_INTS_FWD_HPP -#define TMWA_INTS_FWD_HPP +#pragma once // ints/fwd.hpp - list of type names for ints library // // Copyright © 2014 Ben Longbons @@ -19,12 +18,10 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -# include "../sanity.hpp" +#include "../sanity.hpp" namespace tmwa { // meh, add more when I feel like it } // namespace tmwa - -#endif // TMWA_INTS_FWD_HPP diff --git a/src/ints/little.hpp b/src/ints/little.hpp index 62bd729..0dbbb61 100644 --- a/src/ints/little.hpp +++ b/src/ints/little.hpp @@ -1,5 +1,4 @@ -#ifndef TMWA_INTS_LITTLE_HPP -#define TMWA_INTS_LITTLE_HPP +#pragma once // little.hpp - integers of known endianness // // Copyright © 2014 Ben Longbons @@ -19,20 +18,20 @@ // 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 { // We implement our own actual swapping, because glibc emits assembly // instead of letting the *compiler* do what it does best. -# if __BYTE_ORDER != __BIG_ENDIAN && __BYTE_ORDER != __LITTLE_ENDIAN -# error "broken endians" -# endif +#if __BYTE_ORDER != __BIG_ENDIAN && __BYTE_ORDER != __LITTLE_ENDIAN +# error "broken endians" +#endif namespace ints { @@ -139,5 +138,3 @@ using ints::Little16; using ints::Little32; using ints::Little64; } // namespace tmwa - -#endif // TMWA_INTS_LITTLE_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 diff --git a/src/ints/wrap.hpp b/src/ints/wrap.hpp index 2573de5..707c787 100644 --- a/src/ints/wrap.hpp +++ b/src/ints/wrap.hpp @@ -1,5 +1,4 @@ -#ifndef TMWA_INTS_WRAP_HPP -#define TMWA_INTS_WRAP_HPP +#pragma once // wrap.hpp - basic integer wrapper classes // // 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 @@ -109,5 +108,3 @@ using ints::wrapped::Wrapped; using ints::wrapped::unwrap; using ints::wrapped::wrap; } // namespace tmwa - -#endif // TMWA_INTS_WRAP_HPP -- cgit v1.2.3-70-g09d2