summaryrefslogtreecommitdiff
path: root/src/ints
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-06-27 19:16:45 -0700
committerBen Longbons <b.r.longbons@gmail.com>2014-06-27 19:33:42 -0700
commit7af4c5b5c561362cb1135ab504095ae667a9270a (patch)
tree49ffd3008d7634ba36f3951493a68e928407ce89 /src/ints
parent8d7f1dadeeb1dc1609b72de5a4ee3a5247b0e9e6 (diff)
downloadtmwa-7af4c5b5c561362cb1135ab504095ae667a9270a.tar.gz
tmwa-7af4c5b5c561362cb1135ab504095ae667a9270a.tar.bz2
tmwa-7af4c5b5c561362cb1135ab504095ae667a9270a.tar.xz
tmwa-7af4c5b5c561362cb1135ab504095ae667a9270a.zip
This is more reliable
Diffstat (limited to 'src/ints')
-rw-r--r--src/ints/cmp.hpp15
-rw-r--r--src/ints/fwd.hpp7
-rw-r--r--src/ints/little.hpp17
-rw-r--r--src/ints/udl.hpp19
-rw-r--r--src/ints/wrap.hpp11
5 files changed, 27 insertions, 42 deletions
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 <b.r.longbons@gmail.com>
@@ -19,17 +18,17 @@
// 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 <limits>
+#include <limits>
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<class T, class U>
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 <b.r.longbons@gmail.com>
@@ -19,12 +18,10 @@
// 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 "../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 <b.r.longbons@gmail.com>
@@ -19,20 +18,20 @@
// 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 <endian.h>
+#include <endian.h>
-# include <cstdint>
+#include <cstdint>
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 <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
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 <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
@@ -109,5 +108,3 @@ using ints::wrapped::Wrapped;
using ints::wrapped::unwrap;
using ints::wrapped::wrap;
} // namespace tmwa
-
-#endif // TMWA_INTS_WRAP_HPP