]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/test/x3/uint.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / spirit / test / x3 / uint.hpp
1 /*=============================================================================
2 Copyright (c) 2001-2012 Joel de Guzman
3 Copyright (c) 2001-2011 Hartmut Kaiser
4 Copyright (c) 2011 Bryce Lelbach
5
6 Distributed under the Boost Software License, Version 1.0. (See accompanying
7 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 =============================================================================*/
9 #if !defined(BOOST_SPIRIT_TEST_QI_UINT_HPP)
10 #define BOOST_SPIRIT_TEST_QI_UINT_HPP
11
12 #include <climits>
13 #include <boost/detail/lightweight_test.hpp>
14 #include <boost/spirit/home/x3.hpp>
15
16 #include "test.hpp"
17 #include <cstring>
18
19 ///////////////////////////////////////////////////////////////////////////////
20 //
21 // *** BEWARE PLATFORM DEPENDENT!!! ***
22 // *** The following assumes 32 bit integers and 64 bit long longs.
23 // *** Modify these constant strings when appropriate.
24 //
25 ///////////////////////////////////////////////////////////////////////////////
26
27 char const* max_unsigned = "4294967295";
28 char const* unsigned_overflow = "4294967296";
29 char const* max_int = "2147483647";
30 char const* int_overflow = "2147483648";
31 char const* min_int = "-2147483648";
32 char const* int_underflow = "-2147483649";
33 char const* max_binary = "11111111111111111111111111111111";
34 char const* binary_overflow = "100000000000000000000000000000000";
35 char const* max_octal = "37777777777";
36 char const* octal_overflow = "100000000000";
37 char const* max_hex = "FFFFFFFF";
38 char const* hex_overflow = "100000000";
39
40 ///////////////////////////////////////////////////////////////////////////////
41 // A custom int type
42 struct custom_uint
43 {
44 unsigned n;
45 custom_uint() : n(0) {}
46 explicit custom_uint(unsigned n_) : n(n_) {}
47 custom_uint& operator=(unsigned n_) { n = n_; return *this; }
48 friend bool operator==(custom_uint a, custom_uint b)
49 { return a.n == b.n; }
50 friend bool operator==(custom_uint a, unsigned b)
51 { return a.n == b; }
52 friend custom_uint operator*(custom_uint a, custom_uint b)
53 { return custom_uint(a.n * b.n); }
54 friend custom_uint operator+(custom_uint a, custom_uint b)
55 { return custom_uint(a.n + b.n); }
56 };
57
58 #endif
59