summaryrefslogtreecommitdiff
path: root/src/ints/udl.hpp
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-04-22 11:46:23 -0700
committerBen Longbons <b.r.longbons@gmail.com>2014-04-22 13:20:52 -0700
commitad049a15b43b7ddba3fe7d0a898652fc8022629d (patch)
tree142624e70ead3e89a8da6d56de41651f171524d0 /src/ints/udl.hpp
parentceeda2e337077b2edaf1af09cc4df2c30e8205a1 (diff)
downloadtmwa-ad049a15b43b7ddba3fe7d0a898652fc8022629d.tar.gz
tmwa-ad049a15b43b7ddba3fe7d0a898652fc8022629d.tar.bz2
tmwa-ad049a15b43b7ddba3fe7d0a898652fc8022629d.tar.xz
tmwa-ad049a15b43b7ddba3fe7d0a898652fc8022629d.zip
Use strict ID types
Possibly some missing for the far side of the network. AccountId and BlockId are still terribly entangled.
Diffstat (limited to 'src/ints/udl.hpp')
-rw-r--r--src/ints/udl.hpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/ints/udl.hpp b/src/ints/udl.hpp
index e3e5fcc..ecb5478 100644
--- a/src/ints/udl.hpp
+++ b/src/ints/udl.hpp
@@ -19,7 +19,7 @@
// 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 "fwd.hpp"
# include <cstdint>
@@ -121,14 +121,17 @@ namespace ints
ullong magnitude = V;
template<class T>
+ constexpr
operator T()
{
typedef typename std::make_unsigned<T>::type U;
-
- constexpr bool is_signed = T(-1) < T(0);
+ // boo, body of constexpr function can't use variables
+# define is_signed bool(T(-1) < T(0))
static_assert(is_signed >= (sign && magnitude), "signed");
- constexpr ullong max = 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
return sign ? T(ullong(-magnitude)) : T(magnitude);
}
};
@@ -162,6 +165,7 @@ namespace ints
struct nint64 { int64_t value; int64_t operator -() { return value; } };
template<char... C>
+ constexpr
SignedMagnitudeConstant<false, IntParser<C...>::value> operator "" _const()
{ return {}; }