1 ///////////////////////////////////////////////////////////////////////////////
4 // Copyright 2008 Eric Niebler. Distributed under the Boost
5 // Software License, Version 1.0. (See accompanying file
6 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 #ifndef BOOST_XPRESSIVE_DETAIL_UTILITY_WIDTH_HPP_EAN_04_07_2006
9 #define BOOST_XPRESSIVE_DETAIL_UTILITY_WIDTH_HPP_EAN_04_07_2006
11 // MS compatible compilers support #pragma once
16 #include <climits> // for INT_MAX
17 #include <boost/mpl/size_t.hpp>
19 namespace boost { namespace xpressive { namespace detail
22 typedef mpl::size_t<INT_MAX / 2 - 1> unknown_width;
24 bool is_unknown(width const &that);
26 ///////////////////////////////////////////////////////////////////////////////
30 width(std::size_t val = 0)
35 bool operator !() const
40 width &operator +=(width const &that)
43 !is_unknown(*this) && !is_unknown(that)
44 ? this->value_ + that.value_
49 width &operator |=(width const &that)
52 this->value_ == that.value_
58 std::size_t value() const
67 inline bool is_unknown(width const &that)
69 return unknown_width::value == that.value();
72 inline bool operator ==(width const &left, width const &right)
74 return left.value() == right.value();
77 inline bool operator !=(width const &left, width const &right)
79 return left.value() != right.value();
82 inline width operator +(width left, width const &right)
87 inline width operator |(width left, width const &right)
92 }}} // namespace boost::xpressive::detail