From 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 20:24:20 +0200 Subject: Adding upstream version 14.2.21. Signed-off-by: Daniel Baumann --- src/boost/libs/spirit/test/x3/int.hpp | 61 +++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/boost/libs/spirit/test/x3/int.hpp (limited to 'src/boost/libs/spirit/test/x3/int.hpp') diff --git a/src/boost/libs/spirit/test/x3/int.hpp b/src/boost/libs/spirit/test/x3/int.hpp new file mode 100644 index 00000000..21c92504 --- /dev/null +++ b/src/boost/libs/spirit/test/x3/int.hpp @@ -0,0 +1,61 @@ +/*============================================================================= + Copyright (c) 2001-2012 Joel de Guzman + Copyright (c) 2001-2011 Hartmut Kaiser + Copyright (c) 2011 Bryce Lelbach + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ +#if !defined(BOOST_SPIRIT_TEST_X3_INT_HPP) +#define BOOST_SPIRIT_TEST_X3_INT_HPP + +#include +#include +#include +#include "test.hpp" + +/////////////////////////////////////////////////////////////////////////////// +// +// *** BEWARE PLATFORM DEPENDENT!!! *** +// *** The following assumes 32 bit or 64 bit integers and 64 bit long longs. +// *** Modify these constant strings when appropriate. +// +/////////////////////////////////////////////////////////////////////////////// + + static_assert(sizeof(long long) == 8, "unexpected long long size"); + +#if INT_MAX != LLONG_MAX + static_assert(sizeof(int) == 4, "unexpected int size"); + char const* max_int = "2147483647"; + char const* int_overflow = "2147483648"; + char const* min_int = "-2147483648"; + char const* int_underflow = "-2147483649"; +#else + static_assert(sizeof(int) == 8, "unexpected int size"); + char const* max_int = "9223372036854775807"; + char const* int_overflow = "9223372036854775808"; + char const* min_int = "-9223372036854775808"; + char const* int_underflow = "-9223372036854775809"; +#endif + + char const* max_long_long = "9223372036854775807"; + char const* long_long_overflow = "9223372036854775808"; + char const* min_long_long = "-9223372036854775808"; + char const* long_long_underflow = "-9223372036854775809"; + +/////////////////////////////////////////////////////////////////////////////// +// A custom int type +struct custom_int +{ + int n; + custom_int() : n(0) {} + explicit custom_int(int n_) : n(n_) {} + custom_int& operator=(int n_) { n = n_; return *this; } + friend bool operator==(custom_int a, custom_int b) { return a.n == b.n; } + friend bool operator==(custom_int a, int b) { return a.n == b; } + friend custom_int operator*(custom_int a, custom_int b) { return custom_int(a.n * b.n); } + friend custom_int operator+(custom_int a, custom_int b) { return custom_int(a.n + b.n); } + friend custom_int operator-(custom_int a, custom_int b) { return custom_int(a.n - b.n); } +}; + +#endif -- cgit v1.2.3