]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/spirit/test/x3/uint.hpp
add subtree-ish sources for 12.0.3
[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 //~ #include <boost/phoenix/core.hpp>
16 //~ #include <boost/phoenix/operator.hpp>
17
18 #include "test.hpp"
19 #include <cstring>
20
21 ///////////////////////////////////////////////////////////////////////////////
22 //
23 // *** BEWARE PLATFORM DEPENDENT!!! ***
24 // *** The following assumes 32 bit integers and 64 bit long longs.
25 // *** Modify these constant strings when appropriate.
26 //
27 ///////////////////////////////////////////////////////////////////////////////
28
29 char const* max_unsigned = "4294967295";
30 char const* unsigned_overflow = "4294967296";
31 char const* max_int = "2147483647";
32 char const* int_overflow = "2147483648";
33 char const* min_int = "-2147483648";
34 char const* int_underflow = "-2147483649";
35 char const* max_binary = "11111111111111111111111111111111";
36 char const* binary_overflow = "100000000000000000000000000000000";
37 char const* max_octal = "37777777777";
38 char const* octal_overflow = "100000000000";
39 char const* max_hex = "FFFFFFFF";
40 char const* hex_overflow = "100000000";
41
42 ///////////////////////////////////////////////////////////////////////////////
43 // A custom int type
44 struct custom_uint
45 {
46 unsigned n;
47 custom_uint() : n(0) {}
48 explicit custom_uint(unsigned n_) : n(n_) {}
49 custom_uint& operator=(unsigned n_) { n = n_; return *this; }
50 friend bool operator==(custom_uint a, custom_uint b)
51 { return a.n == b.n; }
52 friend bool operator==(custom_uint a, unsigned b)
53 { return a.n == b; }
54 friend custom_uint operator*(custom_uint a, custom_uint b)
55 { return custom_uint(a.n * b.n); }
56 friend custom_uint operator+(custom_uint a, custom_uint b)
57 { return custom_uint(a.n + b.n); }
58 };
59
60 #endif
61