|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r64018 - in sandbox/SOC/2010/bits_and_ints/libs/integer/doc: . html html/boost_integer
From: muriloufg_at_[hidden]
Date: 2010-07-14 15:03:40
Author: murilov
Date: 2010-07-14 15:03:39 EDT (Wed, 14 Jul 2010)
New Revision: 64018
URL: http://svn.boost.org/trac/boost/changeset/64018
Log:
Working on docs, now sorted by Section name
Text files modified:
sandbox/SOC/2010/bits_and_ints/libs/integer/doc/bits_and_ints.qbk | 976 +++++++-------
sandbox/SOC/2010/bits_and_ints/libs/integer/doc/html/boost_integer/bits_and_ints.html | 2599 ++++++++++++++++++++-------------------
sandbox/SOC/2010/bits_and_ints/libs/integer/doc/html/boost_integer/history.html | 4
sandbox/SOC/2010/bits_and_ints/libs/integer/doc/html/index.html | 2
4 files changed, 1810 insertions(+), 1771 deletions(-)
Modified: sandbox/SOC/2010/bits_and_ints/libs/integer/doc/bits_and_ints.qbk
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/libs/integer/doc/bits_and_ints.qbk (original)
+++ sandbox/SOC/2010/bits_and_ints/libs/integer/doc/bits_and_ints.qbk 2010-07-14 15:03:39 EDT (Wed, 14 Jul 2010)
@@ -4,114 +4,218 @@
The intent of this library is to extend Boost.Integer with fast integer algorithms and utilities. This library can be included via [@../../../../boost/integer/bits_and_ints.hpp <boost/integer/bits_and_ints.hpp>].
[endsect]
-[section:sign_extend Sign Extending]
+[section Absolute Value in Compile-Time ]
+The static metafunctions defined on [@../../../../boost/integer/static_abs.hpp <boost/integer/static_abs.hpp>]
+calculates the absolute value of integral constants.
-Sign extension is automatic for built-in types, such as chars and ints. But suppose you have a signed two's complement number, x, that is stored
-using only b bits. Moreover, suppose you want to convert x to an int, which has more than b bits. A simple copy will work if x is positive, but if
-negative, the sign must be extended. For example, if we have only 4 bits to store a number, then -3 is represented as 1101 in binary. If we have
-8 bits, then -3 is 11111101. The most-significant bit of the 4-bit representation is replicated sinistrally to fill in the destination when we
-convert to a representation with more bits; this is sign extending. More about sign extending on [@http://en.wikipedia.org/wiki/Sign_extension]
+`mpl::abs<>` version returns the absolute value of a `mpl::integral_c<>`
+and the `static_abs<>` version returns the absolute value from an integral value.
-[section Non-Member Function Template `sign_extend`]
-The run-time version can be included via [@../../../../boost/integer/sign_extend.hpp <boost/integer/sign_extend.hpp>].
+[section Synopsis]
- template <typename T>
- Type sign_extend(T data, std::size_t bits);
+ template <typename IC>
+ struct mpl::abs : mpl::integral_c<``['implementation-defined]``,``['implementation-defined]``> {};
+
+ template <typename T, T Value>
+ struct static_abs : mpl::abs< mpl::integral_c<T, Value> > {};
+
+[endsect]
-*[*Requires: ] `bits` must be smaller than the size, in bits, of `T` and `T` must be an integral type.
+*[*Requires: ] `T` must be an integral type. `IC` a `mpl::integral_c<>` type.
-*[*Parameters:]
+*[*Results: ] The member `value ` in `mpl::abs<>` will be the absolute value of `IC::value`.
+In `static_abs<>`, `value` will be the absolute value of `Value`.
-[table
- [[Parameter][Description]]
- [[`data`][ The data to be extended. ]]
- [[`bits`][ The amount of bits in wich data is represented. ]]
-]
+[endsect]
-*[*Returns: ] `data` sign-extended to `sizeof(T)` bytes.
+[section:bit_utils Binary Utilities]
+The header [@../../../../boost/integer/bit_utils.hpp <boost/integer/bit_utils.hpp>] cotains some metafunctions to handle binary data.
+All the metafunctions have an member varible named `value` where will be the result.
+
+[section Synopsis]
+
+ namespace boost
+ {
+
+ namespace mpl {
+
+ template <typename IC, unsigned char pos>
+ struct set_bit : integral_c<typename IC::value_type, ``['implementation-defined]``> {};
+
+ template <typename IC, unsigned char pos>
+ struct clear_bit : integral_c<typename IC::value_type, ``['implementation-defined]``> {};
+
+ template <typename IC, unsigned char pos>
+ struct flip_bit : integral_c<typename IC::value_type, ``['implementation-defined]``> {};
+
+ template <typename IC, unsigned char pos>
+ struct test_bit : bool_<``['implementation-defined]``> {};
+
+ } // mpl
+
+ // Compile-time version
+
+ // Sets the bit `pos' in data
+ template <typename T, T data, unsigned char pos>
+ struct static_set_bit : mpl::set_bit<mpl::integral_c<T, data>, pos> {};
+
+ // Clear the bit `pos' in data
+ template <typename T, T data, unsigned char pos>
+ struct static_clear_bit : mpl::clear_bit<mpl::integral_c<T, data>, pos> {};
+
+ // If the bit `pos' is 1 then it will be 0 if not the bit will be 1
+ template <typename T, T data, unsigned char pos>
+ struct static_flip_bit : mpl::flip_bit<mpl::integral_c<T, data>, pos> {};
+
+ // Test if the bit in `pos' positon is set or not
+ template <typename T, T data, unsigned char pos>
+ struct static_test_bit : mpl::test_bit<mpl::integral_c<T, data>, pos> {};
+
+ // Runtime version
+ template <typename T>
+ inline T set_bit(T data, unsigned char pos);
+
+ template <typename T>
+ inline T clear_bit(T data, unsigned char pos);
+
+ template <typename T>
+ inline T flip_bit(T data, unsigned char pos);
+
+ template <typename T>
+ inline bool test_bit(T data, unsigned char pos);
+
+ } // boost
[endsect]
-[section Template Class `static_sign_extend<>`]
-The compile-time version can be included via [@../../../../boost/integer/static_sign_extend.hpp <boost/integer/static_sign_extend.hpp>].
-The result will be in `value` member.
+[section Template Class `static_set_bit<>` and `mpl::set_bit`]
+Sets the bit `pos` active in `value`.
- template<typename T, T Value, std::size_t Bits>
- struct static_sign_extend
- {
- static const T value = ``['implementation-defined]``;
- };
+*[*Requires: ] `pos` must be smaller than the size (in bits) of `Type` for `static_set_bit<>` and smaller than IC::value_type
+ for `mpl::static_set_bit<>`.
+
+*[*Remarks: ]
+ * `T` must be an integral type.
+ * `IC` must be a `mpl::integral_c<>` type.
-*[*Requires: ] `Bits` must be smaller than the size, in bits, of `T` and `T` must be an integral type.
+*[*Example:]
-*[*Template Parameters:]
+ BOOST_STATIC_ASSERT((set_bit<int, 100, 0>::value == 101));
-[table
- [[Parameter][Description]]
- [[`T`][ The data type. ]]
- [[`Value`][ The data to be extended. ]]
- [[`Bits`][ The amount of bits in wich data is represented. ]]
-]
[endsect]
+
+[section Template Class `mpl::clear_bit<>` and `static_clear_bit<>`]
+Sets the bit `pos` inactive in `data`.
-[section Template Class `mpl::sign_extend<>`]
-The MPL version can be included via [@../../../../boost/integer/static_sign_extend.hpp <boost/integer/static_sign_extend.hpp>].
-The result will be in `value` member.
- template<typename IC, std::size_t Bits>
- struct mpl::sign_extend
- {
- static const T value = ``['implementation-defined]``;
- };
+*[*Requires: ] `pos` must be smaller than the size (in bits) of `Type` for `static_clear_bit<>` and smaller than IC::value_type
+ for `mpl::static_clear_bit<>`.
+*[*Remarks: ]
+ * `T` must be an integral type.
+
+ * `IC` must be a `mpl::integral_c<>` type.
+
+*[*Example:]
-*[*Requires: ] `IC` must a `mpl::integral_c<>` type. `Bits` must be smaller than the size in bits of `IC::value_type`.
+ BOOST_STATIC_ASSERT((clear_bit<int, 3, 1>::value == 1));
-*[*Template Parameters:]
+[endsect]
-[table
- [[Parameter][Description]]
- [[`IC`][ A `mpl::integral_c<>` type. ]]
- [[`Bits`][ The amount of bits in wich data is represented. ]]
-]
+[section Template Class `mpl::test_bit` and `static_test_bit<>`]
+Test if the bit `pos` in `data` is active or not.
+
+
+*[*Requires: ] `pos` must be smaller than the size (in bits) of `Type` for `static_test_bit<>` and smaller than IC::value_type
+ for `mpl::static_test_bit<>`.
+
+*[*Remarks: ]
+ * `T` must be an integral type.
+
+ * `IC` must be a `mpl::integral_c<>` type.
+
+*[*Example:]
+
+ BOOST_STATIC_ASSERT((test_bit<int, 3982, 11>::value == true));
[endsect]
-[section Examples]
-*[*Run-time version]
-``
-#include <boost/integer/sign_extend.hpp>
-#include <iostream>
+[section Template Class `mpl::flip_bit<>` and `static_flip_bit<>`]
+Invert the value of the bit `pos` in `data`
-int main()
-{
- // data is represented in 24-bits
- int data = 0xFFFFFF; // -1 in 24-bits
+*[*Requires: ] `pos` must be smaller than the size (in bits) of `Type` for `static_flip_bit<>` and smaller than IC::value_type
+ for `mpl::static_flip_bit<>`.
+
+*[*Remarks: ]
+ * `T` must be an integral type.
+
+ * `IC` must be a `mpl::integral_c<>` type.
- int result = boost::sign_extend(data, 24);
+*[*Example:]
- std::cout << result << std::endl; // -1
-}
+ BOOST_STATIC_ASSERT((flip_bit<int, 10, 2>::value == 14));
+
+[endsect]
+
+[section Runtime version]
+
+For all runtime functions, all remarks and requirement are equals to the `static_`-prefixed version.
+
+[endsect]
+[endsect]
+
+[section Bit Iterleaving]
+Interleaved bits (aka Morton numbers) [@http://en.wikipedia.org/wiki/Morton_number_(number_theory)] are useful for linearizing 2D integer coordinates,
+so x and y are combined into a single number that can be compared easily and has the property
+that a number is usually close to another if their x and y values are close.
+These functions are defined in the header [@../../../../boost/integer/interleave.hpp <boost/integer/interleave.hpp>].
+
+[section Synopsis]
``
+T2 interleave(T1 x, T1 y);
-*[*Compile-time version]
-``
-#include <boost/integer/static_sign_extend.hpp>
+std::pair<T1, T1> uninterleave(T2 number);
+``
+[endsect]
+
+
+*[*Requires: ] `T1` and `T2` must be integral types. Additionally, `T1` must have 8, 16 or 32 bits and `T2` must have
+16, 32 or 64 bits. For these functions `T2` have the double of bits wich `T1` have.
+
+[*Returns: ] `interleave` function returns `x` and `y` interleaved. `x` will be in the even bits and `y` will be on odd positions, so the return type have the double of bits than the paramter's type.
+
+`uninterleave` returns an `std::pair<>` where in the member `first` will be the integral represented in the even positions of `number` and in the `second`
+member will be the integral represented in the odd positions of `number`.
+
+[section Examples]
+
+``
+#include <boost/integer/interleave.hpp>
+#include <utility>
#include <iostream>
+using namespace std;
+using namespace boost;
+
int main()
{
- // 0xFFFFF is -1 in 20-bits
- int result = boost::static_sign_extend<int, 0xFFFFF, 20>::value;
+ uint_t<64>::exact inter = interleave<32>(0x10, 0x0e);
+
+ cout << "interleaved number: ";
+ cout << hex << inter << endl;
- std::cout << result << std::endl; // -1
+ pair<uint8_t, uint8_t> uninter = uninterleave<16>(inter);
+
+ uint8_t a = uninter.first, b = uninter.second;
+
+ cout << "uninterleaved number: ";
+ cout << hex << unsigned(a) << " " << unsigned(b) << endl;
}
``
-
-[endsect]
[endsect]
+[endsect]
[section:bit_reversal Bit Reversal]
The bit reversal functions reverts the bits of integral types.
@@ -212,30 +316,214 @@
[endsect]
[endsect]
-[section:same_sign Same Sign]
-These functions check if wheter the sign of two integers are equal.
+[section Clear Least Bit Set]
+Clears least significant 1 bit in an integral. The `clear_least_bit_set()` function is defined on [@../../../../boost/integer/clear_least_bit_set.hpp <boost/integer/clear_least_bit_set.hpp>].
-[section Non-Member Function `same_sign`]
-The run-time version can be included via [@../../../../boost/integer/same_sign.hpp <boost/integer/same_sign.hpp>].
-For valid types T, the function `bit_reversal` will be:
+[section Synopsis]
template <typename T>
- inline bool same_sign(T first, T second);
-
-*[*Parameters:]
+ T clear_least_bit_set(T value);
+
+ template <typename IC>
+ struct mpl::clear_least_bit_set { static const typename IC::value_type value = ``['implementation-defined]``; };
+
+ template <typename T, T Value>
+ struct static_clear_least_bit_set { static const T value = ``['implementation-defined]``; };
-[table
- [[Parameter][Description]]
- [[`first`, `second`][ The two integral values to be compared. The type of data *must* be an integral type. `first` and `second` must have the same type. ]]
-]
+[endsect]
-*[*Returns: ] `false` if the signs of first and second are different or `true` if the signs are equal
+*[*Requires: ] `T` must be an integral type. `IC` must be an `mpl::integral_c<>` type.
-*[*Remarks: ] `T` must be an integral type.
+*[*Returns: ] `value` with it's least significant active bit disactivated.
[endsect]
-[section Template Class `static_same_sign<>`]
+[section Count Leading Zeros]
+The `count_trailing_zeros` function counts the number of consecutive 0's from the most significant bit of an integral value.
+The function is defined on [@../../../../boost/integer/count_leading_zeros.hpp <boost/integer/count_leading_zeros.hpp>].
+
+[section Synopsis]
+
+ inline int count_leading_zeros(uintmax_t value);
+
+[endsect]
+
+*[*Remarks: ] If `value` is 0, the result is undefined.
+*[*Returns: ] For the runtime version, the number of consecutive zeros from the least significant bit.
+
+[endsect]
+
+[section Count Trailing Zeros]
+The `count_trailing_zeros` function and metafunctions counts the number of consecutive 0's from the least significant bit of an integral value.
+The runtime function is defined on [@../../../../boost/integer/count_trailing_zeros.hpp <boost/integer/count_trailing_zeros.hpp>] and
+the compile-time metafunctions are defined on [@../../../../boost/integer/static_count_trailing_zeros.hpp <boost/integer/static_count_trailing_zeros.hpp>]
+
+[section Synopsis]
+
+ int count_trailing_zeros(uintmax_t value);
+
+ template <typename IC>
+ struct mpl::count_trailing_zeros { static const int value = ``['implementation-defined]``; };
+
+ template <uintmax_t Value>
+ struct static_count_trailing_zeros { static const int value = ``['implementation-defined]``; };
+
+[endsect]
+
+*[*Remarks: ] If `value` is 0, the result is undefined.
+*[*Requires: ] For the `mpl::count_trailing_zeros<>` version, `IC` must be an mpl::integral_c<> type.
+*[*Returns: ] For the runtime version, the number of consecutive zeros from the least significant bit.
+In the compile-time versions, the number of consecutive zeros in the `value` static member.
+
+[endsect]
+
+[section Greatest Common Divisor ]
+The header file [@../../../../boost/integer/static_gcd.hpp <boost/integer/static_gcd.hpp>] defines `mpl::gcd<>`
+metafunction wich calculates the greatest common divisor of two given `mpl::integral_c<>`.
+
+[section Synopsis]
+
+ template <typename ICT1, typename ICT2>
+ struct mpl::gcd { static const uintmax_t value = ``['implementation-defined]``; };
+
+[endsect]
+
+*[*Requires: ] `ICT1` and `ICT2` must be `mpl::integral_c<>` types.
+
+*[*Results: ] The member `value ` will be the greatest commom divisor from `IC1` and `IC2`.
+
+[endsect]
+
+[section `is_integral_constant<>` metafunction ]
+The header file [@../../../../boost/integer/is_integral_constant.hpp <boost/integer/is_integral_constant.hpp>] defines
+`is_integral_constant<>` static metafunction wich verifies if an given template parameter is or not a `mpl::integral_c<>`.
+
+[section Synopsis]
+
+ template <typename IC>
+ struct is_integral_constant { ``['implementation-defined]`` };
+
+[endsect]
+
+*[*Results: ]
+ * If `IC` is a `mpl::integral_c<>` type, `is_integral_constant<IC>` will inherit from `mpl::true_`
+ * If `IC` is not a `mpl::integral_c<>` type, `is_integral_constant<IC>` will inherit from `mpl::false_`
+
+[endsect]
+
+[section Least Common Multiple ]
+This header defines mpl::lcm<> metafunction wich calculates the
+ least common multiple from two given `mpl::integral_c<>`.
+
+This static metafunction is defined on [@../../../../boost/integer/static_lcm.hpp <boost/integer/static_lcm.hpp>].
+
+[section Synopsis]
+
+ template <typename ICT1, typename ICT2>
+ struct mpl::lcm { static const uintmax_t value = ``['implementation-defined]``; };
+
+[endsect]
+
+*[*Requires: ] `ICT1` and `ICT2` must be `mpl::integral_c<>` types.
+
+*[*Results: ] The member `value ` will be the least common multiple from `IC1` and `IC2`.
+
+[endsect]
+
+[section Population Count (count bits set)]
+Population Count (pop count) is the number of active bits in an integral. The `pop_count()` function is defined
+under the header [@../../../../boost/integer/pop_count.hpp <boost/integer/pop_count.hpp>].
+
+[section Synopsis]
+
+ int pop_count(uintmax_t value);
+
+ template <uintmax_t Value>
+ struct static_pop_count { static const int value = ``['implementation-defined]``; };
+
+ template <typename IC>
+ struct pop_count { static const int value = ``['implementation-defined]``; };
+
+[endsect]
+
+*[*Requires: ] `IC` must be an `mpl::integral_c<>` type.
+*[*Returns: ] The number of bits set in `value`. For the compile-time versions, the result will be on member `value`.
+
+[endsect]
+
+[section Round to Power of 2 functions]
+This function rounds up and down positive integral values to the next power of 2.
+The `ceil_pow2` function rounds up and `floor_pow2` function rounds down.
+These functions are defined on [@../../../../boost/integer/round_pow2.hpp <boost/integer/round_pow2.hpp>]
+
+[section Synopsis]
+
+ T ceil_pow2(T value);
+ T floor_pow2(T value);
+
+[endsect]
+
+*[*Requires: ] `T` must be an integral type and `value` must be positive. If `value` is negative, the result is
+undefined.
+
+*[*Returns: ]
+ * `ceil_pow2()` returns `value` rounded [*up] to the lesser power of two greater than or equal to `value.
+
+ * `floor_pow2()` returns `value` rounded [*down] to the greater power of two lesser or equal `value`.
+
+[endsect]
+
+[section Safe Average]
+Given two integer values x and y, the (floor of the) average normally would be computed by `(x+y)/2` unfortunately,
+this can yield incorrect results due to overflow. Safe average ensures that no overflow will happen even if `(x+y)`
+overflows the range of T.
+The runtime version is defined on [@../../../../boost/integer/safe_avg.hpp <boost/integer/safe_avg.hpp>] and
+the compile-time metafunctions are defined on [@../../../../boost/integer/static_safe_avg.hpp <boost/integer/static_safe_avg.hpp>]
+
+[section Synopsis]
+
+ template <typename T>
+ T safe_avg(T x, T y);
+
+ template <typename ICT1, typename ICT2>
+ struct mpl::safe_avg { static const int value = ``['implementation-defined]``; };
+
+ template <typename T, T Value1, T Value2>
+ struct static_safe_avg { static const int value = ``['implementation-defined]``; };
+
+[endsect]
+
+*[*Requires: ] For the `mpl::safe_avg<>` version, both `ICT1` and `ICT2` must be mpl::integral_c<> types.
+For the `static_safe_avg<>` and the runtime version, `T` must be an integral type.
+
+*[*Returns: ] The average of the sum between two integrals rounded down. Overflow is ensured to not happen.
+
+[endsect]
+
+[section:same_sign Same Sign]
+These functions check if wheter the sign of two integers are equal.
+
+[section Non-Member Function `same_sign`]
+The run-time version can be included via [@../../../../boost/integer/same_sign.hpp <boost/integer/same_sign.hpp>].
+For valid types T, the function `bit_reversal` will be:
+
+ template <typename T>
+ inline bool same_sign(T first, T second);
+
+*[*Parameters:]
+
+[table
+ [[Parameter][Description]]
+ [[`first`, `second`][ The two integral values to be compared. The type of data *must* be an integral type. `first` and `second` must have the same type. ]]
+]
+
+*[*Returns: ] `false` if the signs of first and second are different or `true` if the signs are equal
+
+*[*Remarks: ] `T` must be an integral type.
+
+[endsect]
+
+[section Template Class `static_same_sign<>`]
The compile-time version can be included via [@../../../../boost/integer/static_same_sign.hpp <boost/integer/static_same_sign.hpp>].
The result will be in `value` member.
@@ -314,244 +602,202 @@
[endsect]
[endsect]
-[section:sign Sign function]
-The `sign` function checks the sign of integrals.
+[section:sign_extend Sign Extending]
-[section Non-Member Function `sign`]
-The run-time version can be included via [@../../../../boost/integer/sign.hpp <boost/integer/sign.hpp>].
+Sign extension is automatic for built-in types, such as chars and ints. But suppose you have a signed two's complement number, x, that is stored
+using only b bits. Moreover, suppose you want to convert x to an int, which has more than b bits. A simple copy will work if x is positive, but if
+negative, the sign must be extended. For example, if we have only 4 bits to store a number, then -3 is represented as 1101 in binary. If we have
+8 bits, then -3 is 11111101. The most-significant bit of the 4-bit representation is replicated sinistrally to fill in the destination when we
+convert to a representation with more bits; this is sign extending. More about sign extending on [@http://en.wikipedia.org/wiki/Sign_extension]
+
+[section Non-Member Function Template `sign_extend`]
+The run-time version can be included via [@../../../../boost/integer/sign_extend.hpp <boost/integer/sign_extend.hpp>].
template <typename T>
- int sign(T data);
-
+ Type sign_extend(T data, std::size_t bits);
+
+*[*Requires: ] `bits` must be smaller than the size, in bits, of `T` and `T` must be an integral type.
+
*[*Parameters:]
[table
[[Parameter][Description]]
- [[`data`][ The data to be checked. The type of data *must* be an integral otherwise, sign(data) will result in an error. ]]
+ [[`data`][ The data to be extended. ]]
+ [[`bits`][ The amount of bits in wich data is represented. ]]
]
-*[*Returns:]
+*[*Returns: ] `data` sign-extended to `sizeof(T)` bytes.
-[table
- [[Value][Description]]
- [[`-1`][ `data` is negative. ]]
- [[`0`][ `data` is equal to zero. ]]
- [[`1`][ `data` is positive. ]]
-]
+[endsect]
-*[*Requires: ] `T` must be an integral type.
+[section Template Class `static_sign_extend<>`]
+The compile-time version can be included via [@../../../../boost/integer/static_sign_extend.hpp <boost/integer/static_sign_extend.hpp>].
+The result will be in `value` member.
+
+ template<typename T, T Value, std::size_t Bits>
+ struct static_sign_extend
+ {
+ static const T value = ``['implementation-defined]``;
+ };
+
+
+*[*Requires: ] `Bits` must be smaller than the size, in bits, of `T` and `T` must be an integral type.
+
+*[*Template Parameters:]
+[table
+ [[Parameter][Description]]
+ [[`T`][ The data type. ]]
+ [[`Value`][ The data to be extended. ]]
+ [[`Bits`][ The amount of bits in wich data is represented. ]]
+]
[endsect]
-[section Static Functions `mpl::sign` and `static_sign`]
-The compile-time versions can be included via [@../../../../boost/integer/static_sign.hpp <boost/integer/static_sign.hpp>].
+[section Template Class `mpl::sign_extend<>`]
+The MPL version can be included via [@../../../../boost/integer/static_sign_extend.hpp <boost/integer/static_sign_extend.hpp>].
+The result will be in `value` member.
- template <typename IC>
- struct mpl::sign { static const int value = ``['implementation-defined]``; };
-
- template <template T, T Value>
- struct static_same_sign { static const int value = ``['implementation-defined]``; };
+ template<typename IC, std::size_t Bits>
+ struct mpl::sign_extend
+ {
+ static const T value = ``['implementation-defined]``;
+ };
+
+*[*Requires: ] `IC` must a `mpl::integral_c<>` type. `Bits` must be smaller than the size in bits of `IC::value_type`.
+
+*[*Template Parameters:]
+
[table
[[Parameter][Description]]
[[`IC`][ A `mpl::integral_c<>` type. ]]
- [[`T`][ The value type. Must be an integral type. ]]
- [[`Value`][ The value to be checked. ]]
+ [[`Bits`][ The amount of bits in wich data is represented. ]]
]
-*[*Requires: ] `T` to be an integral type and `IC` to be an `mpl::integral_c<>` type.
-
[endsect]
[section Examples]
-*[*Run-time version:]
-
-``
-#include <boost/integer/sign.hpp>
+*[*Run-time version]
+``
+#include <boost/integer/sign_extend.hpp>
#include <iostream>
int main()
{
- int first = -100, second = 340, third = 0;
-
- int result = boost::sign(first);
- std::cout << result << std::endl; // -1
-
- result = boost::sign(second);
- std::cout << result << std::endl; // 1
-
- result = boost::sign(third);
- std::cout << result << std::endl; // 0
-}
-``
-
-[endsect]
-[endsect]
-
-[section Bit Iterleaving]
-Interleaved bits (aka Morton numbers) [@http://en.wikipedia.org/wiki/Morton_number_(number_theory)] are useful for linearizing 2D integer coordinates,
-so x and y are combined into a single number that can be compared easily and has the property
-that a number is usually close to another if their x and y values are close.
-These functions are defined in the header [@../../../../boost/integer/interleave.hpp <boost/integer/interleave.hpp>].
+ // data is represented in 24-bits
+ int data = 0xFFFFFF; // -1 in 24-bits
-[section Synopsis]
-``
-T2 interleave(T1 x, T1 y);
+ int result = boost::sign_extend(data, 24);
-std::pair<T1, T1> uninterleave(T2 number);
+ std::cout << result << std::endl; // -1
+}
``
-[endsect]
-
-
-*[*Requires: ] `T1` and `T2` must be integral types. Additionally, `T1` must have 8, 16 or 32 bits and `T2` must have
-16, 32 or 64 bits. For these functions `T2` have the double of bits wich `T1` have.
-
-[*Returns: ] `interleave` function returns `x` and `y` interleaved. `x` will be in the even bits and `y` will be on odd positions, so the return type have the double of bits than the paramter's type.
-
-`uninterleave` returns an `std::pair<>` where in the member `first` will be the integral represented in the even positions of `number` and in the `second`
-member will be the integral represented in the odd positions of `number`.
-[section Examples]
-
-``
-#include <boost/integer/interleave.hpp>
-#include <utility>
+*[*Compile-time version]
+``
+#include <boost/integer/static_sign_extend.hpp>
#include <iostream>
-using namespace std;
-using namespace boost;
-
int main()
{
- uint_t<64>::exact inter = interleave<32>(0x10, 0x0e);
-
- cout << "interleaved number: ";
- cout << hex << inter << endl;
-
- pair<uint8_t, uint8_t> uninter = uninterleave<16>(inter);
-
- uint8_t a = uninter.first, b = uninter.second;
+ // 0xFFFFF is -1 in 20-bits
+ int result = boost::static_sign_extend<int, 0xFFFFF, 20>::value;
- cout << "uninterleaved number: ";
- cout << hex << unsigned(a) << " " << unsigned(b) << endl;
+ std::cout << result << std::endl; // -1
}
``
-
-[endsect]
-[endsect]
-
-[section Population Count (count bits set)]
-Population Count (pop count) is the number of active bits in an integral. The `pop_count()` function is defined
-under the header [@../../../../boost/integer/pop_count.hpp <boost/integer/pop_count.hpp>].
-
-[section Synopsis]
-
- int pop_count(uintmax_t value);
- template <uintmax_t Value>
- struct static_pop_count { static const int value = ``['implementation-defined]``; };
-
- template <typename IC>
- struct pop_count { static const int value = ``['implementation-defined]``; };
-
[endsect]
-
-*[*Requires: ] `IC` must be an `mpl::integral_c<>` type.
-*[*Returns: ] The number of bits set in `value`. For the compile-time versions, the result will be on member `value`.
-
[endsect]
-[section Clear Least Bit Set]
-Clears least significant 1 bit in an integral. The `clear_least_bit_set()` function is defined on [@../../../../boost/integer/clear_least_bit_set.hpp <boost/integer/clear_least_bit_set.hpp>].
+[section:sign Sign section]
+The `sign` function checks the sign of integrals.
-[section Synopsis]
+[section Non-Member Function `sign`]
+The run-time version can be included via [@../../../../boost/integer/sign.hpp <boost/integer/sign.hpp>].
template <typename T>
- T clear_least_bit_set(T value);
-
- template <typename IC>
- struct mpl::clear_least_bit_set { static const typename IC::value_type value = ``['implementation-defined]``; };
-
- template <typename T, T Value>
- struct static_clear_least_bit_set { static const T value = ``['implementation-defined]``; };
+ int sign(T data);
+
+*[*Parameters:]
-[endsect]
+[table
+ [[Parameter][Description]]
+ [[`data`][ The data to be checked. The type of data *must* be an integral otherwise, sign(data) will result in an error. ]]
+]
-*[*Requires: ] `T` must be an integral type. `IC` must be an `mpl::integral_c<>` type.
+*[*Returns:]
-*[*Returns: ] `value` with it's least significant active bit disactivated.
+[table
+ [[Value][Description]]
+ [[`-1`][ `data` is negative. ]]
+ [[`0`][ `data` is equal to zero. ]]
+ [[`1`][ `data` is positive. ]]
+]
+
+*[*Requires: ] `T` must be an integral type.
[endsect]
-[section Count Trailing Zeros]
-The `count_trailing_zeros` function and metafunctions counts the number of consecutive 0's from the least significant bit of an integral value.
-The runtime function is defined on [@../../../../boost/integer/count_trailing_zeros.hpp <boost/integer/count_trailing_zeros.hpp>] and
-the compile-time metafunctions are defined on [@../../../../boost/integer/static_count_trailing_zeros.hpp <boost/integer/static_count_trailing_zeros.hpp>]
+[section Static Functions `mpl::sign` and `static_sign`]
+The compile-time versions can be included via [@../../../../boost/integer/static_sign.hpp <boost/integer/static_sign.hpp>].
-[section Synopsis]
-
- int count_trailing_zeros(uintmax_t value);
-
template <typename IC>
- struct mpl::count_trailing_zeros { static const int value = ``['implementation-defined]``; };
+ struct mpl::sign { static const int value = ``['implementation-defined]``; };
- template <uintmax_t Value>
- struct static_count_trailing_zeros { static const int value = ``['implementation-defined]``; };
+ template <template T, T Value>
+ struct static_same_sign { static const int value = ``['implementation-defined]``; };
-[endsect]
+[table
+ [[Parameter][Description]]
+ [[`IC`][ A `mpl::integral_c<>` type. ]]
+ [[`T`][ The value type. Must be an integral type. ]]
+ [[`Value`][ The value to be checked. ]]
+]
-*[*Requires: ] For the `mpl::count_trailing_zeros<>` version, `IC` must be an mpl::integral_c<> type.
-*[*Returns: ] For the runtime version, the number of consecutive zeros from the least significant bit.
-In the compile-time versions, the number of consecutive zeros in the `value` static member.
+*[*Requires: ] `T` to be an integral type and `IC` to be an `mpl::integral_c<>` type.
[endsect]
-[section Safe Average]
-Given two integer values x and y, the (floor of the) average normally would be computed by `(x+y)/2` unfortunately,
-this can yield incorrect results due to overflow. Safe average ensures that no overflow will happen even if `(x+y)`
-overflows the range of T.
-The runtime version is defined on [@../../../../boost/integer/safe_avg.hpp <boost/integer/safe_avg.hpp>] and
-the compile-time metafunctions are defined on [@../../../../boost/integer/static_safe_avg.hpp <boost/integer/static_safe_avg.hpp>]
+[section Examples]
+*[*Run-time version:]
-[section Synopsis]
+``
+#include <boost/integer/sign.hpp>
+#include <iostream>
+
+int main()
+{
+ int first = -100, second = 340, third = 0;
- template <typename T>
- T safe_avg(T x, T y);
+ int result = boost::sign(first);
+ std::cout << result << std::endl; // -1
- template <typename ICT1, typename ICT2>
- struct mpl::safe_avg { static const int value = ``['implementation-defined]``; };
+ result = boost::sign(second);
+ std::cout << result << std::endl; // 1
- template <typename T, T Value1, T Value2>
- struct static_safe_avg { static const int value = ``['implementation-defined]``; };
+ result = boost::sign(third);
+ std::cout << result << std::endl; // 0
+}
+``
[endsect]
-
-*[*Requires: ] For the `mpl::safe_avg<>` version, both `ICT1` and `ICT2` must be mpl::integral_c<> types.
-For the `static_safe_avg<>` and the runtime version, `T` must be an integral type.
-
-*[*Returns: ] The average of the sum between two integrals rounded down. Overflow is ensured to not happen.
-
[endsect]
-[section Round to Power of 2 functions]
-This function rounds up and down positive integral values to the next power of 2.
-The `ceil_pow2` function rounds up and `floor_pow2` function rounds down.
-These functions are defined on [@../../../../boost/integer/round_pow2.hpp <boost/integer/round_pow2.hpp>]
+[section Swap without a temporary (in-place) ]
+The header file [@../../../../boost/integer/swap.hpp <boost/integer/swap.hpp>] defines `swap`
+function wich swaps 2 integral values without using a temporary variable.
[section Synopsis]
- T ceil_pow2(T value);
- T floor_pow2(T value);
+ template <typename T>
+ inline void swap(T& x, T& y);
[endsect]
-*[*Requires: ] `T` must be an integral type and `value` must be positive. If `value` is negative, the result is
-undefined.
+*[*Requires: ] `T` must be an integral type.
-*[*Returns: ]
- * `ceil_pow2()` returns `value` rounded [*up] to the lesser power of two greater than or equal to `value.
-
- * `floor_pow2()` returns `value` rounded [*down] to the greater power of two lesser or equal `value`.
+*[*Returns: ] Nothing. `x` will have the value of `y` and `y` will have the `x` value.
[endsect]
@@ -591,240 +837,4 @@
[endsect]
-[section Absolute Value in Compile-Time ]
-The static metafunctions defined on [@../../../../boost/integer/static_abs.hpp <boost/integer/static_abs.hpp>]
-calculates the absolute value of integral constants.
-
-`mpl::abs<>` version returns the absolute value of a `mpl::integral_c<>`
-and the `static_abs<>` version returns the absolute value from an integral value.
-
-[section Synopsis]
-
- template <typename IC>
- struct mpl::abs { static const typename IC::value_type value = ``['implementation-defined]``; };
-
- template <typename T, T Value>
- struct static_abs { static const T value = ``['implementation-defined]``; };
-
-[endsect]
-
-*[*Requires: ] `T` must be an integral type. `IC` a `mpl::integral_c<>` type.
-
-*[*Results: ] The member `value ` in `mpl::abs<>` will be the absolute value of `IC::value`.
-In `static_abs<>`, `value` will be the absolute value of `Value`.
-
-[endsect]
-
-[section MPL Least Common Multiple ]
-This header defines mpl::lcm<> metafunction wich calculates the
- least common multiple from two given `mpl::integral_c<>`.
-
-This static metafunction is defined on [@../../../../boost/integer/static_lcm.hpp <boost/integer/static_lcm.hpp>].
-
-[section Synopsis]
-
- template <typename ICT1, typename ICT2>
- struct mpl::lcm { static const uintmax_t value = ``['implementation-defined]``; };
-
-[endsect]
-
-*[*Requires: ] `ICT1` and `ICT2` must be `mpl::integral_c<>` types.
-
-*[*Results: ] The member `value ` will be the least common multiple from `IC1` and `IC2`.
-
-[endsect]
-
-[section MPL Greatest Common Divisor ]
-The header file [@../../../../boost/integer/static_gcd.hpp <boost/integer/static_gcd.hpp>] defines `mpl::gcd<>`
-metafunction wich calculates the greatest common divisor of two given `mpl::integral_c<>`.
-
-[section Synopsis]
-
- template <typename ICT1, typename ICT2>
- struct mpl::gcd { static const uintmax_t value = ``['implementation-defined]``; };
-
-[endsect]
-
-*[*Requires: ] `ICT1` and `ICT2` must be `mpl::integral_c<>` types.
-
-*[*Results: ] The member `value ` will be the greatest commom divisor from `IC1` and `IC2`.
-
-[endsect]
-
-[section Swap without a temporary ]
-The header file [@../../../../boost/integer/swap.hpp <boost/integer/swap.hpp>] defines `swap`
-function wich swaps 2 integral values without using a temporary variable.
-
-[section Synopsis]
-
- template <typename T>
- inline void swap(T& x, T& y);
-
-[endsect]
-
-*[*Requires: ] `T` must be an integral type.
-
-*[*Returns: ] Nothing. `x` will have the value of `y` and `y` will have the `x` value.
-
-[endsect]
-
-[section MPL `is_integral_constant<>` metafunction ]
-The header file [@../../../../boost/integer/is_integral_constant.hpp <boost/integer/is_integral_constant.hpp>] defines
-`is_integral_constant<>` static metafunction wich verifies if an given template parameter is or not a `mpl::integral_c<>`.
-
-[section Synopsis]
-
- template <typename IC>
- struct is_integral_constant { ``['implementation-defined]`` };
-
-[endsect]
-
-*[*Results: ]
- * If `IC` is a `mpl::integral_c<>` type, `is_integral_constant<IC>` will inherit from `mpl::true_`
- * If `IC` is not a `mpl::integral_c<>` type, `is_integral_constant<IC>` will inherit from `mpl::false_`
-
-[endsect]
-
-
-[section:bit_utils Binary Utilities]
-The header [@../../../../boost/integer/bit_utils.hpp <boost/integer/bit_utils.hpp>] cotains some metafunctions to handle binary data.
-All the metafunctions have an member varible named `value` where will be the result.
-
-[section Synopsis]
-
- namespace boost
- {
-
- // Compile-time version
-
- // Sets the bit `pos' in data
- template <typename T, T data, unsigned char pos>
- struct static_set_bit { static const T value = ``['implementation-defined]``; };
-
- // Clear the bit `pos' in data
- template <typename T, T data, unsigned char pos>
- struct static_clear_bit { static const T value = ``['implementation-defined]``; };
-
- // If the bit `pos' is 1 then it will be 0 if not the bit will be 1
- template <typename T, T data, unsigned char pos>
- struct static_flip_bit{ static const T value = ``['implementation-defined]``; };
-
- // Test if the bit in `pos' positon is set or not
- template <typename T, T data, unsigned char pos>
- struct static_test_bit { static const bool value = ``['implementation-defined]``; };
-
- namespace mpl {
-
- template <typename IC, unsigned char pos>
- struct set_bit { static const typename IC::value_type value = ``['implementation-defined]``; };
-
- template <typename IC, unsigned char pos>
- struct clear_bit { static const typename IC::value_type value = ``['implementation-defined]``; };
-
- template <typename IC, unsigned char pos>
- struct flip_bit{ static const typename IC::value_type value = ``['implementation-defined]``; };
-
- template <typename IC, unsigned char pos>
- struct test_bit { static const bool value = ``['implementation-defined]``; };
-
- } // mpl
-
- // Runtime version
- template <typename T>
- inline T set_bit(T data, unsigned char pos);
-
- template <typename T>
- inline T clear_bit(T data, unsigned char pos);
-
- template <typename T>
- inline T flip_bit(T data, unsigned char pos);
-
- template <typename T>
- inline bool test_bit(T data, unsigned char pos);
-
- } // boost
-
-[endsect]
-
-[section Template Class `static_set_bit<>` and `mpl::set_bit`]
-Sets the bit `pos` active in `value`.
-
-*[*Requires: ] `pos` must be smaller than the size (in bits) of `Type` for `static_set_bit<>` and smaller than IC::value_type
- for `mpl::static_set_bit<>`.
-
-*[*Remarks: ]
- * `T` must be an integral type.
-
- * `IC` must be a `mpl::integral_c<>` type.
-
-*[*Example:]
-
- // `new_value' becomes 101
- int new_value = set_bit<int, 100, 0>::value;
-
-[endsect]
-
-[section Template Class `mpl::clear_bit<>` and `static_clear_bit<>`]
-Sets the bit `pos` inactive in `data`.
-
-
-*[*Requires: ] `pos` must be smaller than the size (in bits) of `Type` for `static_clear_bit<>` and smaller than IC::value_type
- for `mpl::static_clear_bit<>`.
-
-*[*Remarks: ]
- * `T` must be an integral type.
-
- * `IC` must be a `mpl::integral_c<>` type.
-
-*[*Example:]
-
- // `new_value' becomes 1
- int new_value = set_bit<int, 3, 2>::value;
-
-[endsect]
-
-[section Template Class `mpl::test_bit` and `static_test_bit<>`]
-Test if the bit `pos` in `data` is active or not.
-
-
-*[*Requires: ] `pos` must be smaller than the size (in bits) of `Type` for `static_test_bit<>` and smaller than IC::value_type
- for `mpl::static_test_bit<>`.
-
-*[*Remarks: ]
- * `T` must be an integral type.
-
- * `IC` must be a `mpl::integral_c<>` type.
-
-*[*Example:]
-
- // `is_set' becomes true
- bool is_set = test_bit<int, 3982, 11>::value;
-
-[endsect]
-
-[section Template Class `mpl::flip_bit<>` and `static_flip_bit<>`]
-Invert the value of the bit `pos` in `data`
-
-*[*Requires: ] `pos` must be smaller than the size (in bits) of `Type` for `static_flip_bit<>` and smaller than IC::value_type
- for `mpl::static_flip_bit<>`.
-
-*[*Remarks: ]
- * `T` must be an integral type.
-
- * `IC` must be a `mpl::integral_c<>` type.
-
-*[*Example:]
-
- // `new_value' becomes 14
- bool new_value = flip_bit<int, 10, 2>::value;
-
-[endsect]
-
-[section Runtime version]
-
-For all runtime functions, all remarks and requirement are equals to the `static_`-prefixed version.
-
-[endsect]
-[endsect]
-
[endsect]
\ No newline at end of file
Modified: sandbox/SOC/2010/bits_and_ints/libs/integer/doc/html/boost_integer/bits_and_ints.html
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/libs/integer/doc/html/boost_integer/bits_and_ints.html (original)
+++ sandbox/SOC/2010/bits_and_ints/libs/integer/doc/html/boost_integer/bits_and_ints.html 2010-07-14 15:03:39 EDT (Wed, 14 Jul 2010)
@@ -28,34 +28,35 @@
</h2></div></div></div>
<div class="toc"><dl>
<dt><span class="section">Overview</span></dt>
-<dt><span class="section"> Sign Extending</span></dt>
-<dt><span class="section"> Bit Reversal</span></dt>
-<dt><span class="section"> Same Sign</span></dt>
-<dt><span class="section"> Sign function</span></dt>
+<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.absolute_value_in_compile_time_">Absolute
+ Value in Compile-Time </a></span></dt>
+<dt><span class="section"> Binary Utilities</span></dt>
<dt><span class="section">Bit Iterleaving</span></dt>
-<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.population_count__count_bits_set_">Population
- Count (count bits set)</a></span></dt>
+<dt><span class="section"> Bit Reversal</span></dt>
<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.clear_least_bit_set">Clear
Least Bit Set</a></span></dt>
+<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.count_leading_zeros">Count
+ Leading Zeros</a></span></dt>
<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.count_trailing_zeros">Count
Trailing Zeros</a></span></dt>
-<dt><span class="section">Safe Average</span></dt>
+<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.greatest_common_divisor_">Greatest
+ Common Divisor </a></span></dt>
+<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints._is_integral_constant____metafunction_"><code class="computeroutput"><span class="identifier">is_integral_constant</span><span class="special"><></span></code>
+ metafunction </a></span></dt>
+<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.least_common_multiple_">Least
+ Common Multiple </a></span></dt>
+<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.population_count__count_bits_set_">Population
+ Count (count bits set)</a></span></dt>
<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.round_to_power_of_2_functions">Round
to Power of 2 functions</a></span></dt>
+<dt><span class="section">Safe Average</span></dt>
+<dt><span class="section"> Same Sign</span></dt>
+<dt><span class="section"> Sign Extending</span></dt>
+<dt><span class="section"> Sign section</span></dt>
+<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.swap_without_a_temporary__in_place__">Swap
+ without a temporary (in-place) </a></span></dt>
<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.transfer_of_sign__isign__functions_">Transfer
of Sign (isign) functions </a></span></dt>
-<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.absolute_value_in_compile_time_">Absolute
- Value in Compile-Time </a></span></dt>
-<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.mpl_least_common_multiple_">MPL
- Least Common Multiple </a></span></dt>
-<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.mpl_greatest_common_divisor_">MPL
- Greatest Common Divisor </a></span></dt>
-<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.swap_without_a_temporary_">Swap
- without a temporary </a></span></dt>
-<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.mpl__is_integral_constant____metafunction_">MPL
- <code class="computeroutput"><span class="identifier">is_integral_constant</span><span class="special"><></span></code>
- metafunction </a></span></dt>
-<dt><span class="section"> Binary Utilities</span></dt>
</dl></div>
<div class="section" title="Overview">
<div class="titlepage"><div><div><h3 class="title">
@@ -66,316 +67,392 @@
and utilities. This library can be included via <boost/integer/bits_and_ints.hpp>.
</p>
</div>
-<div class="section" title="Sign Extending">
+<div class="section" title="Absolute Value in Compile-Time">
<div class="titlepage"><div><div><h3 class="title">
-<a name="boost_integer.bits_and_ints.sign_extend"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.sign_extend" title="Sign Extending"> Sign Extending</a>
+<a name="boost_integer.bits_and_ints.absolute_value_in_compile_time_"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.absolute_value_in_compile_time_" title="Absolute Value in Compile-Time">Absolute
+ Value in Compile-Time </a>
+</h3></div></div></div>
+<div class="toc"><dl><dt><span class="section">Synopsis</span></dt></dl></div>
+<p>
+ The static metafunctions defined on <boost/integer/static_abs.hpp>
+ calculates the absolute value of integral constants.
+ </p>
+<p>
+ <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">abs</span><span class="special"><></span></code>
+ version returns the absolute value of a <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code> and the <code class="computeroutput"><span class="identifier">static_abs</span><span class="special"><></span></code> version returns the absolute value
+ from an integral value.
+ </p>
+<div class="section" title="Synopsis">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_integer.bits_and_ints.absolute_value_in_compile_time_.synopsis"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.absolute_value_in_compile_time_.synopsis" title="Synopsis">Synopsis</a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">IC</span><span class="special">></span>
+<span class="keyword">struct</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">abs</span> <span class="special">:</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><</span><span class="emphasis"><em>implementation-defined</em></span><span class="special">,</span><span class="emphasis"><em>implementation-defined</em></span><span class="special">></span> <span class="special">{};</span>
+
+<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">Value</span><span class="special">></span>
+<span class="keyword">struct</span> <span class="identifier">static_abs</span> <span class="special">:</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">abs</span><span class="special"><</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">Value</span><span class="special">></span> <span class="special">></span> <span class="special">{};</span>
+</pre>
+</div>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">T</span></code>
+ must be an integral type. <code class="computeroutput"><span class="identifier">IC</span></code>
+ a <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
+ type.
+ </li>
+<li class="listitem">
+<span class="bold"><strong>Results: </strong></span> The member <code class="computeroutput"><span class="identifier">value</span>
+ </code> in <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">abs</span><span class="special"><></span></code>
+ will be the absolute value of <code class="computeroutput"><span class="identifier">IC</span><span class="special">::</span><span class="identifier">value</span></code>.
+ In <code class="computeroutput"><span class="identifier">static_abs</span><span class="special"><></span></code>,
+ <code class="computeroutput"><span class="identifier">value</span></code> will be the absolute
+ value of <code class="computeroutput"><span class="identifier">Value</span></code>.
+ </li>
+</ul></div>
+</div>
+<div class="section" title="Binary Utilities">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.bits_and_ints.bit_utils"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.bit_utils" title="Binary Utilities"> Binary Utilities</a>
</h3></div></div></div>
<div class="toc"><dl>
-<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.sign_extend.non_member_function_template__sign_extend_">Non-Member
- Function Template <code class="computeroutput"><span class="identifier">sign_extend</span></code></a></span></dt>
-<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.sign_extend.template_class__static_sign_extend___">Template
- Class <code class="computeroutput"><span class="identifier">static_sign_extend</span><span class="special"><></span></code></a></span></dt>
-<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.sign_extend.template_class__mpl__sign_extend___">Template
- Class <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">sign_extend</span><span class="special"><></span></code></a></span></dt>
-<dt><span class="section">Examples</span></dt>
+<dt><span class="section">Synopsis</span></dt>
+<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.bit_utils.template_class__static_set_bit____and__mpl__set_bit_">Template
+ Class <code class="computeroutput"><span class="identifier">static_set_bit</span><span class="special"><></span></code>
+ and <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">set_bit</span></code></a></span></dt>
+<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.bit_utils.template_class__mpl__clear_bit____and__static_clear_bit___">Template
+ Class <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">clear_bit</span><span class="special"><></span></code>
+ and <code class="computeroutput"><span class="identifier">static_clear_bit</span><span class="special"><></span></code></a></span></dt>
+<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.bit_utils.template_class__mpl__test_bit__and__static_test_bit___">Template
+ Class <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">test_bit</span></code> and <code class="computeroutput"><span class="identifier">static_test_bit</span><span class="special"><></span></code></a></span></dt>
+<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.bit_utils.template_class__mpl__flip_bit____and__static_flip_bit___">Template
+ Class <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">flip_bit</span><span class="special"><></span></code>
+ and <code class="computeroutput"><span class="identifier">static_flip_bit</span><span class="special"><></span></code></a></span></dt>
+<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.bit_utils.runtime_version">Runtime
+ version</a></span></dt>
</dl></div>
<p>
- Sign extension is automatic for built-in types, such as chars and ints. But
- suppose you have a signed two's complement number, x, that is stored using
- only b bits. Moreover, suppose you want to convert x to an int, which has
- more than b bits. A simple copy will work if x is positive, but if negative,
- the sign must be extended. For example, if we have only 4 bits to store a
- number, then -3 is represented as 1101 in binary. If we have 8 bits, then
- -3 is 11111101. The most-significant bit of the 4-bit representation is replicated
- sinistrally to fill in the destination when we convert to a representation
- with more bits; this is sign extending. More about sign extending on http://en.wikipedia.org/wiki/Sign_extension
+ The header <boost/integer/bit_utils.hpp>
+ cotains some metafunctions to handle binary data. All the metafunctions have
+ an member varible named <code class="computeroutput"><span class="identifier">value</span></code>
+ where will be the result.
</p>
-<div class="section" title="Non-Member Function Template sign_extend">
+<div class="section" title="Synopsis">
<div class="titlepage"><div><div><h4 class="title">
-<a name="boost_integer.bits_and_ints.sign_extend.non_member_function_template__sign_extend_"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.sign_extend.non_member_function_template__sign_extend_" title="Non-Member Function Template sign_extend">Non-Member
- Function Template <code class="computeroutput"><span class="identifier">sign_extend</span></code></a>
+<a name="boost_integer.bits_and_ints.bit_utils.synopsis"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.bit_utils.synopsis" title="Synopsis">Synopsis</a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span>
+<span class="special">{</span>
+
+<span class="keyword">namespace</span> <span class="identifier">mpl</span> <span class="special">{</span>
+
+<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">IC</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">char</span> <span class="identifier">pos</span><span class="special">></span>
+<span class="keyword">struct</span> <span class="identifier">set_bit</span> <span class="special">:</span> <span class="identifier">integral_c</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">IC</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">,</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">></span> <span class="special">{};</span>
+
+<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">IC</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">char</span> <span class="identifier">pos</span><span class="special">></span>
+<span class="keyword">struct</span> <span class="identifier">clear_bit</span> <span class="special">:</span> <span class="identifier">integral_c</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">IC</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">,</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">></span> <span class="special">{};</span>
+
+<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">IC</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">char</span> <span class="identifier">pos</span><span class="special">></span>
+<span class="keyword">struct</span> <span class="identifier">flip_bit</span> <span class="special">:</span> <span class="identifier">integral_c</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">IC</span><span class="special">::</span><span class="identifier">value_type</span><span class="special">,</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">></span> <span class="special">{};</span>
+
+<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">IC</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">char</span> <span class="identifier">pos</span><span class="special">></span>
+<span class="keyword">struct</span> <span class="identifier">test_bit</span> <span class="special">:</span> <span class="identifier">bool_</span><span class="special"><</span><span class="emphasis"><em>implementation-defined</em></span><span class="special">></span> <span class="special">{};</span>
+
+<span class="special">}</span> <span class="comment">// mpl
+</span>
+<span class="comment">// Compile-time version
+</span>
+<span class="comment">// Sets the bit `pos' in data
+</span><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">data</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">char</span> <span class="identifier">pos</span><span class="special">></span>
+<span class="keyword">struct</span> <span class="identifier">static_set_bit</span> <span class="special">:</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">set_bit</span><span class="special"><</span><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">data</span><span class="special">>,</span> <span class="identifier">pos</span><span class="special">></span> <span class="special">{};</span>
+
+<span class="comment">// Clear the bit `pos' in data
+</span><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">data</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">char</span> <span class="identifier">pos</span><span class="special">></span>
+<span class="keyword">struct</span> <span class="identifier">static_clear_bit</span> <span class="special">:</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">clear_bit</span><span class="special"><</span><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">data</span><span class="special">>,</span> <span class="identifier">pos</span><span class="special">></span> <span class="special">{};</span>
+
+<span class="comment">// If the bit `pos' is 1 then it will be 0 if not the bit will be 1
+</span><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">data</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">char</span> <span class="identifier">pos</span><span class="special">></span>
+<span class="keyword">struct</span> <span class="identifier">static_flip_bit</span> <span class="special">:</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">flip_bit</span><span class="special"><</span><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">data</span><span class="special">>,</span> <span class="identifier">pos</span><span class="special">></span> <span class="special">{};</span>
+
+<span class="comment">// Test if the bit in `pos' positon is set or not
+</span><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">data</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">char</span> <span class="identifier">pos</span><span class="special">></span>
+<span class="keyword">struct</span> <span class="identifier">static_test_bit</span> <span class="special">:</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">test_bit</span><span class="special"><</span><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">data</span><span class="special">>,</span> <span class="identifier">pos</span><span class="special">></span> <span class="special">{};</span>
+
+<span class="comment">// Runtime version
+</span><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
+<span class="keyword">inline</span> <span class="identifier">T</span> <span class="identifier">set_bit</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">data</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">char</span> <span class="identifier">pos</span><span class="special">);</span>
+
+<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
+<span class="keyword">inline</span> <span class="identifier">T</span> <span class="identifier">clear_bit</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">data</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">char</span> <span class="identifier">pos</span><span class="special">);</span>
+
+<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
+<span class="keyword">inline</span> <span class="identifier">T</span> <span class="identifier">flip_bit</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">data</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">char</span> <span class="identifier">pos</span><span class="special">);</span>
+
+<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
+<span class="keyword">inline</span> <span class="keyword">bool</span> <span class="identifier">test_bit</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">data</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">char</span> <span class="identifier">pos</span><span class="special">);</span>
+
+<span class="special">}</span> <span class="comment">// boost
+</span></pre>
+</div>
+<div class="section" title="Template Class static_set_bit<> and mpl::set_bit">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_integer.bits_and_ints.bit_utils.template_class__static_set_bit____and__mpl__set_bit_"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.bit_utils.template_class__static_set_bit____and__mpl__set_bit_" title="Template Class static_set_bit<> and mpl::set_bit">Template
+ Class <code class="computeroutput"><span class="identifier">static_set_bit</span><span class="special"><></span></code>
+ and <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">set_bit</span></code></a>
</h4></div></div></div>
<p>
- The run-time version can be included via <boost/integer/sign_extend.hpp>.
+ Sets the bit <code class="computeroutput"><span class="identifier">pos</span></code> active
+ in <code class="computeroutput"><span class="identifier">value</span></code>.
</p>
-<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
-<span class="identifier">Type</span> <span class="identifier">sign_extend</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">data</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">bits</span><span class="special">);</span>
-</pre>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
-<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">bits</span></code>
- must be smaller than the size, in bits, of <code class="computeroutput"><span class="identifier">T</span></code>
- and <code class="computeroutput"><span class="identifier">T</span></code> must be an integral
- type.
+<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">pos</span></code>
+ must be smaller than the size (in bits) of <code class="computeroutput"><span class="identifier">Type</span></code>
+ for <code class="computeroutput"><span class="identifier">static_set_bit</span><span class="special"><></span></code>
+ and smaller than IC::value_type for <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">static_set_bit</span><span class="special"><></span></code>.
</li>
-<li class="listitem"><span class="bold"><strong>Parameters:</strong></span></li>
+<li class="listitem">
+<span class="bold"><strong>Remarks: </strong></span><div class="itemizedlist"><ul class="itemizedlist" type="circle">
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">T</span></code> must be an integral
+ type.
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">IC</span></code> must be a <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
+ type.
+ </li>
</ul></div>
-<div class="informaltable"><table class="table">
-<colgroup>
-<col>
-<col>
-</colgroup>
-<thead><tr>
-<th>
- <p>
- Parameter
- </p>
- </th>
-<th>
- <p>
- Description
- </p>
- </th>
-</tr></thead>
-<tbody>
-<tr>
-<td>
- <p>
- <code class="computeroutput"><span class="identifier">data</span></code>
- </p>
- </td>
-<td>
- <p>
- The data to be extended.
- </p>
- </td>
-</tr>
-<tr>
-<td>
- <p>
- <code class="computeroutput"><span class="identifier">bits</span></code>
- </p>
- </td>
-<td>
- <p>
- The amount of bits in wich data is represented.
- </p>
- </td>
-</tr>
-</tbody>
-</table></div>
-<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
-<span class="bold"><strong>Returns: </strong></span><code class="computeroutput"><span class="identifier">data</span></code>
- sign-extended to <code class="computeroutput"><span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">T</span><span class="special">)</span></code> bytes.
- </li></ul></div>
+</li>
+<li class="listitem"><span class="bold"><strong>Example:</strong></span></li>
+</ul></div>
+<pre class="programlisting"><span class="identifier">BOOST_STATIC_ASSERT</span><span class="special">((</span><span class="identifier">set_bit</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="number">100</span><span class="special">,</span> <span class="number">0</span><span class="special">>::</span><span class="identifier">value</span> <span class="special">==</span> <span class="number">101</span><span class="special">));</span>
+</pre>
</div>
-<div class="section" title="Template Class static_sign_extend<>">
+<div class="section" title="Template Class mpl::clear_bit<> and static_clear_bit<>">
<div class="titlepage"><div><div><h4 class="title">
-<a name="boost_integer.bits_and_ints.sign_extend.template_class__static_sign_extend___"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.sign_extend.template_class__static_sign_extend___" title="Template Class static_sign_extend<>">Template
- Class <code class="computeroutput"><span class="identifier">static_sign_extend</span><span class="special"><></span></code></a>
+<a name="boost_integer.bits_and_ints.bit_utils.template_class__mpl__clear_bit____and__static_clear_bit___"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.bit_utils.template_class__mpl__clear_bit____and__static_clear_bit___" title="Template Class mpl::clear_bit<> and static_clear_bit<>">Template
+ Class <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">clear_bit</span><span class="special"><></span></code>
+ and <code class="computeroutput"><span class="identifier">static_clear_bit</span><span class="special"><></span></code></a>
</h4></div></div></div>
<p>
- The compile-time version can be included via <boost/integer/static_sign_extend.hpp>.
- The result will be in <code class="computeroutput"><span class="identifier">value</span></code>
- member.
+ Sets the bit <code class="computeroutput"><span class="identifier">pos</span></code> inactive
+ in <code class="computeroutput"><span class="identifier">data</span></code>.
</p>
-<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">Value</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">Bits</span><span class="special">></span>
-<span class="keyword">struct</span> <span class="identifier">static_sign_extend</span>
-<span class="special">{</span>
- <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span>
-<span class="special">};</span>
-</pre>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
-<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">Bits</span></code>
- must be smaller than the size, in bits, of <code class="computeroutput"><span class="identifier">T</span></code>
- and <code class="computeroutput"><span class="identifier">T</span></code> must be an integral
- type.
- </li>
-<li class="listitem"><span class="bold"><strong>Template Parameters:</strong></span></li>
+<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">pos</span></code>
+ must be smaller than the size (in bits) of <code class="computeroutput"><span class="identifier">Type</span></code>
+ for <code class="computeroutput"><span class="identifier">static_clear_bit</span><span class="special"><></span></code> and smaller than IC::value_type
+ for <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">static_clear_bit</span><span class="special"><></span></code>.
+ </li>
+<li class="listitem">
+<span class="bold"><strong>Remarks: </strong></span><div class="itemizedlist"><ul class="itemizedlist" type="circle">
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">T</span></code> must be an integral
+ type.
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">IC</span></code> must be a <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
+ type.
+ </li>
</ul></div>
-<div class="informaltable"><table class="table">
-<colgroup>
-<col>
-<col>
-</colgroup>
-<thead><tr>
-<th>
- <p>
- Parameter
- </p>
- </th>
-<th>
- <p>
- Description
- </p>
- </th>
-</tr></thead>
-<tbody>
-<tr>
-<td>
- <p>
- <code class="computeroutput"><span class="identifier">T</span></code>
- </p>
- </td>
-<td>
- <p>
- The data type.
- </p>
- </td>
-</tr>
-<tr>
-<td>
- <p>
- <code class="computeroutput"><span class="identifier">Value</span></code>
- </p>
- </td>
-<td>
- <p>
- The data to be extended.
- </p>
- </td>
-</tr>
-<tr>
-<td>
- <p>
- <code class="computeroutput"><span class="identifier">Bits</span></code>
- </p>
- </td>
-<td>
- <p>
- The amount of bits in wich data is represented.
- </p>
- </td>
-</tr>
-</tbody>
-</table></div>
+</li>
+<li class="listitem"><span class="bold"><strong>Example:</strong></span></li>
+</ul></div>
+<pre class="programlisting"><span class="identifier">BOOST_STATIC_ASSERT</span><span class="special">((</span><span class="identifier">clear_bit</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="number">3</span><span class="special">,</span> <span class="number">1</span><span class="special">>::</span><span class="identifier">value</span> <span class="special">==</span> <span class="number">1</span><span class="special">));</span>
+</pre>
</div>
-<div class="section" title="Template Class mpl::sign_extend<>">
+<div class="section" title="Template Class mpl::test_bit and static_test_bit<>">
<div class="titlepage"><div><div><h4 class="title">
-<a name="boost_integer.bits_and_ints.sign_extend.template_class__mpl__sign_extend___"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.sign_extend.template_class__mpl__sign_extend___" title="Template Class mpl::sign_extend<>">Template
- Class <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">sign_extend</span><span class="special"><></span></code></a>
+<a name="boost_integer.bits_and_ints.bit_utils.template_class__mpl__test_bit__and__static_test_bit___"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.bit_utils.template_class__mpl__test_bit__and__static_test_bit___" title="Template Class mpl::test_bit and static_test_bit<>">Template
+ Class <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">test_bit</span></code> and <code class="computeroutput"><span class="identifier">static_test_bit</span><span class="special"><></span></code></a>
</h4></div></div></div>
<p>
- The MPL version can be included via <boost/integer/static_sign_extend.hpp>.
- The result will be in <code class="computeroutput"><span class="identifier">value</span></code>
- member.
+ Test if the bit <code class="computeroutput"><span class="identifier">pos</span></code> in
+ <code class="computeroutput"><span class="identifier">data</span></code> is active or not.
</p>
-<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">IC</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">Bits</span><span class="special">></span>
-<span class="keyword">struct</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">sign_extend</span>
-<span class="special">{</span>
- <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span>
-<span class="special">};</span>
-</pre>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
-<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">IC</span></code>
- must a <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
- type. <code class="computeroutput"><span class="identifier">Bits</span></code> must be smaller
- than the size in bits of <code class="computeroutput"><span class="identifier">IC</span><span class="special">::</span><span class="identifier">value_type</span></code>.
+<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">pos</span></code>
+ must be smaller than the size (in bits) of <code class="computeroutput"><span class="identifier">Type</span></code>
+ for <code class="computeroutput"><span class="identifier">static_test_bit</span><span class="special"><></span></code>
+ and smaller than IC::value_type for <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">static_test_bit</span><span class="special"><></span></code>.
</li>
-<li class="listitem"><span class="bold"><strong>Template Parameters:</strong></span></li>
+<li class="listitem">
+<span class="bold"><strong>Remarks: </strong></span><div class="itemizedlist"><ul class="itemizedlist" type="circle">
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">T</span></code> must be an integral
+ type.
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">IC</span></code> must be a <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
+ type.
+ </li>
</ul></div>
-<div class="informaltable"><table class="table">
-<colgroup>
-<col>
-<col>
-</colgroup>
-<thead><tr>
-<th>
- <p>
- Parameter
- </p>
- </th>
-<th>
- <p>
- Description
- </p>
- </th>
-</tr></thead>
-<tbody>
-<tr>
-<td>
- <p>
- <code class="computeroutput"><span class="identifier">IC</span></code>
- </p>
- </td>
-<td>
- <p>
- A <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
- type.
- </p>
- </td>
-</tr>
-<tr>
-<td>
- <p>
- <code class="computeroutput"><span class="identifier">Bits</span></code>
- </p>
- </td>
-<td>
- <p>
- The amount of bits in wich data is represented.
- </p>
- </td>
-</tr>
-</tbody>
-</table></div>
+</li>
+<li class="listitem"><span class="bold"><strong>Example:</strong></span></li>
+</ul></div>
+<pre class="programlisting"><span class="identifier">BOOST_STATIC_ASSERT</span><span class="special">((</span><span class="identifier">test_bit</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="number">3982</span><span class="special">,</span> <span class="number">11</span><span class="special">>::</span><span class="identifier">value</span> <span class="special">==</span> <span class="keyword">true</span><span class="special">));</span>
+</pre>
</div>
-<div class="section" title="Examples">
+<div class="section" title="Template Class mpl::flip_bit<> and static_flip_bit<>">
<div class="titlepage"><div><div><h4 class="title">
-<a name="boost_integer.bits_and_ints.sign_extend.examples"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.sign_extend.examples" title="Examples">Examples</a>
+<a name="boost_integer.bits_and_ints.bit_utils.template_class__mpl__flip_bit____and__static_flip_bit___"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.bit_utils.template_class__mpl__flip_bit____and__static_flip_bit___" title="Template Class mpl::flip_bit<> and static_flip_bit<>">Template
+ Class <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">flip_bit</span><span class="special"><></span></code>
+ and <code class="computeroutput"><span class="identifier">static_flip_bit</span><span class="special"><></span></code></a>
</h4></div></div></div>
+<p>
+ Invert the value of the bit <code class="computeroutput"><span class="identifier">pos</span></code>
+ in <code class="computeroutput"><span class="identifier">data</span></code>
+ </p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
-<span class="bold"><strong>Run-time version</strong></span><pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">integer</span><span class="special">/</span><span class="identifier">sign_extend</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
-<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
-
-<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
-<span class="special">{</span>
- <span class="comment">// data is represented in 24-bits
-</span> <span class="keyword">int</span> <span class="identifier">data</span> <span class="special">=</span> <span class="number">0xFFFFFF</span><span class="special">;</span> <span class="comment">// -1 in 24-bits
-</span>
- <span class="keyword">int</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">sign_extend</span><span class="special">(</span><span class="identifier">data</span><span class="special">,</span> <span class="number">24</span><span class="special">);</span>
-
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">result</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// -1
-</span><span class="special">}</span>
-</pre>
-</li>
+<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">pos</span></code>
+ must be smaller than the size (in bits) of <code class="computeroutput"><span class="identifier">Type</span></code>
+ for <code class="computeroutput"><span class="identifier">static_flip_bit</span><span class="special"><></span></code>
+ and smaller than IC::value_type for <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">static_flip_bit</span><span class="special"><></span></code>.
+ </li>
<li class="listitem">
-<span class="bold"><strong>Compile-time version</strong></span><pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">integer</span><span class="special">/</span><span class="identifier">static_sign_extend</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
-<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
-
-<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
-<span class="special">{</span>
- <span class="comment">// 0xFFFFF is -1 in 20-bits
-</span> <span class="keyword">int</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">static_sign_extend</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="number">0xFFFFF</span><span class="special">,</span> <span class="number">20</span><span class="special">>::</span><span class="identifier">value</span><span class="special">;</span>
-
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">result</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// -1
-</span><span class="special">}</span>
-</pre>
+<span class="bold"><strong>Remarks: </strong></span><div class="itemizedlist"><ul class="itemizedlist" type="circle">
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">T</span></code> must be an integral
+ type.
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">IC</span></code> must be a <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
+ type.
+ </li>
+</ul></div>
</li>
+<li class="listitem"><span class="bold"><strong>Example:</strong></span></li>
</ul></div>
+<pre class="programlisting"><span class="identifier">BOOST_STATIC_ASSERT</span><span class="special">((</span><span class="identifier">flip_bit</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="number">10</span><span class="special">,</span> <span class="number">2</span><span class="special">>::</span><span class="identifier">value</span> <span class="special">==</span> <span class="number">14</span><span class="special">));</span>
+</pre>
+</div>
+<div class="section" title="Runtime version">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_integer.bits_and_ints.bit_utils.runtime_version"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.bit_utils.runtime_version" title="Runtime version">Runtime
+ version</a>
+</h4></div></div></div>
+<p>
+ For all runtime functions, all remarks and requirement are equals to the
+ <code class="computeroutput"><span class="identifier">static_</span></code>-prefixed version.
+ </p>
</div>
</div>
-<div class="section" title="Bit Reversal">
+<div class="section" title="Bit Iterleaving">
<div class="titlepage"><div><div><h3 class="title">
-<a name="boost_integer.bits_and_ints.bit_reversal"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.bit_reversal" title="Bit Reversal"> Bit Reversal</a>
+<a name="boost_integer.bits_and_ints.bit_iterleaving"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.bit_iterleaving" title="Bit Iterleaving">Bit Iterleaving</a>
</h3></div></div></div>
<div class="toc"><dl>
-<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.bit_reversal.non_member_function__bit_reversal_">Non-Member
- Function <code class="computeroutput"><span class="identifier">bit_reversal</span></code></a></span></dt>
-<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.bit_reversal.template_class__static_bit_reversal___">Template
- Class <code class="computeroutput"><span class="identifier">static_bit_reversal</span><span class="special"><></span></code></a></span></dt>
-<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.bit_reversal.template_class__mpl__bit_reversal___">Template
- Class <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">bit_reversal</span><span class="special"><></span></code></a></span></dt>
-<dt><span class="section">Examples</span></dt>
+<dt><span class="section">Synopsis</span></dt>
+<dt><span class="section">Examples</span></dt>
</dl></div>
<p>
- The bit reversal functions reverts the bits of integral types.
+ Interleaved bits (aka Morton numbers) http://en.wikipedia.org/wiki/Morton_number_(number_theory)
+ are useful for linearizing 2D integer coordinates, so x and y are combined
+ into a single number that can be compared easily and has the property that
+ a number is usually close to another if their x and y values are close. These
+ functions are defined in the header <boost/integer/interleave.hpp>.
</p>
-<div class="section" title="Non-Member Function bit_reversal">
+<div class="section" title="Synopsis">
<div class="titlepage"><div><div><h4 class="title">
-<a name="boost_integer.bits_and_ints.bit_reversal.non_member_function__bit_reversal_"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.bit_reversal.non_member_function__bit_reversal_" title="Non-Member Function bit_reversal">Non-Member
- Function <code class="computeroutput"><span class="identifier">bit_reversal</span></code></a>
+<a name="boost_integer.bits_and_ints.bit_iterleaving.synopsis"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.bit_iterleaving.synopsis" title="Synopsis">Synopsis</a>
</h4></div></div></div>
<p>
- The run-time version can be included via <boost/integer/bit_reversal.hpp>.
- </p>
-<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
-<span class="keyword">inline</span> <span class="identifier">T</span> <span class="identifier">bit_reversal</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">data</span><span class="special">);</span>
+
+</p>
+<pre class="programlisting"><span class="identifier">T2</span> <span class="identifier">interleave</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T1</span> <span class="identifier">y</span><span class="special">);</span>
+
+<span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">T1</span><span class="special">,</span> <span class="identifier">T1</span><span class="special">></span> <span class="identifier">uninterleave</span><span class="special">(</span><span class="identifier">T2</span> <span class="identifier">number</span><span class="special">);</span>
</pre>
-<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><span class="bold"><strong>Parameters:</strong></span></li></ul></div>
+<p>
+ </p>
+</div>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
+<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">T1</span></code>
+ and <code class="computeroutput"><span class="identifier">T2</span></code> must be integral
+ types. Additionally, <code class="computeroutput"><span class="identifier">T1</span></code>
+ must have 8, 16 or 32 bits and <code class="computeroutput"><span class="identifier">T2</span></code>
+ must have 16, 32 or 64 bits. For these functions <code class="computeroutput"><span class="identifier">T2</span></code>
+ have the double of bits wich <code class="computeroutput"><span class="identifier">T1</span></code>
+ have.
+ </li></ul></div>
+<p>
+ <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="identifier">interleave</span></code>
+ function returns <code class="computeroutput"><span class="identifier">x</span></code> and <code class="computeroutput"><span class="identifier">y</span></code> interleaved. <code class="computeroutput"><span class="identifier">x</span></code>
+ will be in the even bits and <code class="computeroutput"><span class="identifier">y</span></code>
+ will be on odd positions, so the return type have the double of bits than
+ the paramter's type.
+ </p>
+<p>
+ <code class="computeroutput"><span class="identifier">uninterleave</span></code> returns an
+ <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><></span></code>
+ where in the member <code class="computeroutput"><span class="identifier">first</span></code>
+ will be the integral represented in the even positions of <code class="computeroutput"><span class="identifier">number</span></code>
+ and in the <code class="computeroutput"><span class="identifier">second</span></code> member
+ will be the integral represented in the odd positions of <code class="computeroutput"><span class="identifier">number</span></code>.
+ </p>
+<div class="section" title="Examples">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_integer.bits_and_ints.bit_iterleaving.examples"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.bit_iterleaving.examples" title="Examples">Examples</a>
+</h4></div></div></div>
+<p>
+
+</p>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">integer</span><span class="special">/</span><span class="identifier">interleave</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
+<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">utility</span><span class="special">></span>
+<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
+
+<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">std</span><span class="special">;</span>
+<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">;</span>
+
+<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="identifier">uint_t</span><span class="special"><</span><span class="number">64</span><span class="special">>::</span><span class="identifier">exact</span> <span class="identifier">inter</span> <span class="special">=</span> <span class="identifier">interleave</span><span class="special"><</span><span class="number">32</span><span class="special">>(</span><span class="number">0x10</span><span class="special">,</span> <span class="number">0x0e</span><span class="special">);</span>
+
+ <span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"interleaved number: "</span><span class="special">;</span>
+ <span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">hex</span> <span class="special"><<</span> <span class="identifier">inter</span> <span class="special"><<</span> <span class="identifier">endl</span><span class="special">;</span>
+
+ <span class="identifier">pair</span><span class="special"><</span><span class="identifier">uint8_t</span><span class="special">,</span> <span class="identifier">uint8_t</span><span class="special">></span> <span class="identifier">uninter</span> <span class="special">=</span> <span class="identifier">uninterleave</span><span class="special"><</span><span class="number">16</span><span class="special">>(</span><span class="identifier">inter</span><span class="special">);</span>
+
+ <span class="identifier">uint8_t</span> <span class="identifier">a</span> <span class="special">=</span> <span class="identifier">uninter</span><span class="special">.</span><span class="identifier">first</span><span class="special">,</span> <span class="identifier">b</span> <span class="special">=</span> <span class="identifier">uninter</span><span class="special">.</span><span class="identifier">second</span><span class="special">;</span>
+
+ <span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"uninterleaved number: "</span><span class="special">;</span>
+ <span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">hex</span> <span class="special"><<</span> <span class="keyword">unsigned</span><span class="special">(</span><span class="identifier">a</span><span class="special">)</span> <span class="special"><<</span> <span class="string">" "</span> <span class="special"><<</span> <span class="keyword">unsigned</span><span class="special">(</span><span class="identifier">b</span><span class="special">)</span> <span class="special"><<</span> <span class="identifier">endl</span><span class="special">;</span>
+<span class="special">}</span>
+</pre>
+<p>
+ </p>
+</div>
+</div>
+<div class="section" title="Bit Reversal">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.bits_and_ints.bit_reversal"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.bit_reversal" title="Bit Reversal"> Bit Reversal</a>
+</h3></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.bit_reversal.non_member_function__bit_reversal_">Non-Member
+ Function <code class="computeroutput"><span class="identifier">bit_reversal</span></code></a></span></dt>
+<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.bit_reversal.template_class__static_bit_reversal___">Template
+ Class <code class="computeroutput"><span class="identifier">static_bit_reversal</span><span class="special"><></span></code></a></span></dt>
+<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.bit_reversal.template_class__mpl__bit_reversal___">Template
+ Class <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">bit_reversal</span><span class="special"><></span></code></a></span></dt>
+<dt><span class="section">Examples</span></dt>
+</dl></div>
+<p>
+ The bit reversal functions reverts the bits of integral types.
+ </p>
+<div class="section" title="Non-Member Function bit_reversal">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_integer.bits_and_ints.bit_reversal.non_member_function__bit_reversal_"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.bit_reversal.non_member_function__bit_reversal_" title="Non-Member Function bit_reversal">Non-Member
+ Function <code class="computeroutput"><span class="identifier">bit_reversal</span></code></a>
+</h4></div></div></div>
+<p>
+ The run-time version can be included via <boost/integer/bit_reversal.hpp>.
+ </p>
+<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
+<span class="keyword">inline</span> <span class="identifier">T</span> <span class="identifier">bit_reversal</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">data</span><span class="special">);</span>
+</pre>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><span class="bold"><strong>Parameters:</strong></span></li></ul></div>
<div class="informaltable"><table class="table">
<colgroup>
<col>
@@ -576,554 +653,211 @@
</ul></div>
</div>
</div>
-<div class="section" title="Same Sign">
+<div class="section" title="Clear Least Bit Set">
<div class="titlepage"><div><div><h3 class="title">
-<a name="boost_integer.bits_and_ints.same_sign"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.same_sign" title="Same Sign"> Same Sign</a>
+<a name="boost_integer.bits_and_ints.clear_least_bit_set"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.clear_least_bit_set" title="Clear Least Bit Set">Clear
+ Least Bit Set</a>
</h3></div></div></div>
-<div class="toc"><dl>
-<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.same_sign.non_member_function__same_sign_">Non-Member
- Function <code class="computeroutput"><span class="identifier">same_sign</span></code></a></span></dt>
-<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.same_sign.template_class__static_same_sign___">Template
- Class <code class="computeroutput"><span class="identifier">static_same_sign</span><span class="special"><></span></code></a></span></dt>
-<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.same_sign.template_class__mpl__same_sign___">Template
- Class <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">same_sign</span><span class="special"><></span></code></a></span></dt>
-<dt><span class="section">Examples</span></dt>
-</dl></div>
+<div class="toc"><dl><dt><span class="section">Synopsis</span></dt></dl></div>
<p>
- These functions check if wheter the sign of two integers are equal.
+ Clears least significant 1 bit in an integral. The <code class="computeroutput"><span class="identifier">clear_least_bit_set</span><span class="special">()</span></code> function is defined on <boost/integer/clear_least_bit_set.hpp>.
</p>
-<div class="section" title="Non-Member Function same_sign">
+<div class="section" title="Synopsis">
<div class="titlepage"><div><div><h4 class="title">
-<a name="boost_integer.bits_and_ints.same_sign.non_member_function__same_sign_"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.same_sign.non_member_function__same_sign_" title="Non-Member Function same_sign">Non-Member
- Function <code class="computeroutput"><span class="identifier">same_sign</span></code></a>
+<a name="boost_integer.bits_and_ints.clear_least_bit_set.synopsis"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.clear_least_bit_set.synopsis" title="Synopsis">Synopsis</a>
</h4></div></div></div>
-<p>
- The run-time version can be included via <boost/integer/same_sign.hpp>.
- For valid types T, the function <code class="computeroutput"><span class="identifier">bit_reversal</span></code>
- will be:
- </p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
-<span class="keyword">inline</span> <span class="keyword">bool</span> <span class="identifier">same_sign</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">second</span><span class="special">);</span>
+<span class="identifier">T</span> <span class="identifier">clear_least_bit_set</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">value</span><span class="special">);</span>
+
+<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">IC</span><span class="special">></span>
+<span class="keyword">struct</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">clear_least_bit_set</span> <span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">typename</span> <span class="identifier">IC</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span> <span class="special">};</span>
+
+<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">Value</span><span class="special">></span>
+<span class="keyword">struct</span> <span class="identifier">static_clear_least_bit_set</span> <span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span> <span class="special">};</span>
</pre>
-<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><span class="bold"><strong>Parameters:</strong></span></li></ul></div>
-<div class="informaltable"><table class="table">
-<colgroup>
-<col>
-<col>
-</colgroup>
-<thead><tr>
-<th>
- <p>
- Parameter
- </p>
- </th>
-<th>
- <p>
- Description
- </p>
- </th>
-</tr></thead>
-<tbody><tr>
-<td>
- <p>
- <code class="computeroutput"><span class="identifier">first</span></code>, <code class="computeroutput"><span class="identifier">second</span></code>
- </p>
- </td>
-<td>
- <p>
- The two integral values to be compared. The type of data <span class="bold"><strong>must</strong></span> be an integral type. <code class="computeroutput"><span class="identifier">first</span></code> and <code class="computeroutput"><span class="identifier">second</span></code>
- must have the same type.
- </p>
- </td>
-</tr></tbody>
-</table></div>
+</div>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
-<span class="bold"><strong>Returns: </strong></span><code class="computeroutput"><span class="keyword">false</span></code>
- if the signs of first and second are different or <code class="computeroutput"><span class="keyword">true</span></code>
- if the signs are equal
- </li>
+<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">T</span></code>
+ must be an integral type. <code class="computeroutput"><span class="identifier">IC</span></code>
+ must be an <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
+ type.
+ </li>
<li class="listitem">
-<span class="bold"><strong>Remarks: </strong></span><code class="computeroutput"><span class="identifier">T</span></code>
- must be an integral type.
- </li>
+<span class="bold"><strong>Returns: </strong></span><code class="computeroutput"><span class="identifier">value</span></code>
+ with it's least significant active bit disactivated.
+ </li>
</ul></div>
</div>
-<div class="section" title="Template Class static_same_sign<>">
-<div class="titlepage"><div><div><h4 class="title">
-<a name="boost_integer.bits_and_ints.same_sign.template_class__static_same_sign___"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.same_sign.template_class__static_same_sign___" title="Template Class static_same_sign<>">Template
- Class <code class="computeroutput"><span class="identifier">static_same_sign</span><span class="special"><></span></code></a>
-</h4></div></div></div>
+<div class="section" title="Count Leading Zeros">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.bits_and_ints.count_leading_zeros"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.count_leading_zeros" title="Count Leading Zeros">Count
+ Leading Zeros</a>
+</h3></div></div></div>
+<div class="toc"><dl><dt><span class="section">Synopsis</span></dt></dl></div>
<p>
- The compile-time version can be included via <boost/integer/static_same_sign.hpp>.
- The result will be in <code class="computeroutput"><span class="identifier">value</span></code>
- member.
- </p>
-<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">Value1</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">Value2</span><span class="special">></span>
-<span class="keyword">struct</span> <span class="identifier">static_same_sign</span>
-<span class="special">{</span>
- <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">bool</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span>
-<span class="special">};</span>
-</pre>
-<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><span class="bold"><strong>Template Parameters:</strong></span></li></ul></div>
-<div class="informaltable"><table class="table">
-<colgroup>
-<col>
-<col>
-</colgroup>
-<thead><tr>
-<th>
- <p>
- Parameter
- </p>
- </th>
-<th>
- <p>
- Description
- </p>
- </th>
-</tr></thead>
-<tbody>
-<tr>
-<td>
- <p>
- <code class="computeroutput"><span class="identifier">T</span></code>
- </p>
- </td>
-<td>
- <p>
- The data type.
- </p>
- </td>
-</tr>
-<tr>
-<td>
- <p>
- <code class="computeroutput"><span class="identifier">Value1</span></code>, <code class="computeroutput"><span class="identifier">Value2</span></code>
- </p>
- </td>
-<td>
- <p>
- The two integral values to be compared.
- </p>
- </td>
-</tr>
-</tbody>
-</table></div>
-<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
-<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">T</span></code>
- must be an integral type.
- </li></ul></div>
-</div>
-<div class="section" title="Template Class mpl::same_sign<>">
+ The <code class="computeroutput"><span class="identifier">count_trailing_zeros</span></code>
+ function counts the number of consecutive 0's from the most significant bit
+ of an integral value. The function is defined on <boost/integer/count_leading_zeros.hpp>.
+ </p>
+<div class="section" title="Synopsis">
<div class="titlepage"><div><div><h4 class="title">
-<a name="boost_integer.bits_and_ints.same_sign.template_class__mpl__same_sign___"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.same_sign.template_class__mpl__same_sign___" title="Template Class mpl::same_sign<>">Template
- Class <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">same_sign</span><span class="special"><></span></code></a>
+<a name="boost_integer.bits_and_ints.count_leading_zeros.synopsis"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.count_leading_zeros.synopsis" title="Synopsis">Synopsis</a>
</h4></div></div></div>
-<p>
- The MPL version can be included via <boost/integer/static_same_sign.hpp>.
- The result will be in <code class="computeroutput"><span class="identifier">value</span></code>
- member.
- </p>
-<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">IC1</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">IC2</span><span class="special">></span>
-<span class="keyword">struct</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">same_sign</span>
-<span class="special">{</span>
- <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">bool</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span>
-<span class="special">};</span>
+<pre class="programlisting"><span class="keyword">inline</span> <span class="keyword">int</span> <span class="identifier">count_leading_zeros</span><span class="special">(</span><span class="identifier">uintmax_t</span> <span class="identifier">value</span><span class="special">);</span>
</pre>
-<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><span class="bold"><strong>Template Parameters:</strong></span></li></ul></div>
-<div class="informaltable"><table class="table">
-<colgroup>
-<col>
-<col>
-</colgroup>
-<thead><tr>
-<th>
- <p>
- Parameter
- </p>
- </th>
-<th>
- <p>
- Description
- </p>
- </th>
-</tr></thead>
-<tbody><tr>
-<td>
- <p>
- <code class="computeroutput"><span class="identifier">IC1</span></code>, <code class="computeroutput"><span class="identifier">IC2</span></code>
- </p>
- </td>
-<td>
- <p>
- The two <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
- to be compared.
- </p>
- </td>
-</tr></tbody>
-</table></div>
-<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
-<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">IC1</span></code>
- and <code class="computeroutput"><span class="identifier">IC2</span></code> must be <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
- types.
- </li></ul></div>
</div>
-<div class="section" title="Examples">
-<div class="titlepage"><div><div><h4 class="title">
-<a name="boost_integer.bits_and_ints.same_sign.examples"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.same_sign.examples" title="Examples">Examples</a>
-</h4></div></div></div>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
-<span class="bold"><strong>Run-time version:</strong></span><pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">integer</span><span class="special">/</span><span class="identifier">same_sign</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
-<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
-
-<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
-<span class="special">{</span>
- <span class="keyword">int</span> <span class="identifier">first</span> <span class="special">=</span> <span class="special">-</span><span class="number">1</span><span class="special">,</span> <span class="identifier">second</span> <span class="special">=</span> <span class="special">-</span><span class="number">2</span><span class="special">,</span> <span class="identifier">third</span> <span class="special">=</span> <span class="number">1</span><span class="special">;</span>
-
- <span class="keyword">bool</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">same_sign</span><span class="special">(</span><span class="identifier">first</span><span class="special">,</span> <span class="identifier">second</span><span class="special">);</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">result</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// true
-</span>
- <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">same_sign</span><span class="special">(</span><span class="identifier">first</span><span class="special">,</span> <span class="identifier">third</span><span class="special">);</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">result</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// false
-</span><span class="special">}</span>
-</pre>
-</li>
-<li class="listitem"><span class="bold"><strong>Compile-time version:</strong></span></li>
+<span class="bold"><strong>Remarks: </strong></span> If <code class="computeroutput"><span class="identifier">value</span></code>
+ is 0, the result is undefined.
+ </li>
+<li class="listitem">
+<span class="bold"><strong>Returns: </strong></span> For the runtime version, the
+ number of consecutive zeros from the least significant bit.
+ </li>
</ul></div>
+</div>
+<div class="section" title="Count Trailing Zeros">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.bits_and_ints.count_trailing_zeros"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.count_trailing_zeros" title="Count Trailing Zeros">Count
+ Trailing Zeros</a>
+</h3></div></div></div>
+<div class="toc"><dl><dt><span class="section">Synopsis</span></dt></dl></div>
<p>
-
-</p>
-<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">integer</span><span class="special">/</span><span class="identifier">same_sign</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
-<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
+ The <code class="computeroutput"><span class="identifier">count_trailing_zeros</span></code>
+ function and metafunctions counts the number of consecutive 0's from the
+ least significant bit of an integral value. The runtime function is defined
+ on <boost/integer/count_trailing_zeros.hpp>
+ and the compile-time metafunctions are defined on <boost/integer/static_count_trailing_zeros.hpp>
+ </p>
+<div class="section" title="Synopsis">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_integer.bits_and_ints.count_trailing_zeros.synopsis"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.count_trailing_zeros.synopsis" title="Synopsis">Synopsis</a>
+</h4></div></div></div>
+<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">count_trailing_zeros</span><span class="special">(</span><span class="identifier">uintmax_t</span> <span class="identifier">value</span><span class="special">);</span>
-<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
-<span class="special">{</span>
- <span class="keyword">bool</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">static_same_sign</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="number">2</span><span class="special">,</span> <span class="number">10</span><span class="special">>::</span><span class="identifier">value</span><span class="special">;</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">result</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">//true
-</span>
- <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">static_same_sign</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="number">10</span><span class="special">,</span> <span class="special">-</span><span class="number">2</span><span class="special">>::</span><span class="identifier">value</span><span class="special">;</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">result</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// false
-</span><span class="special">}</span>
+<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">IC</span><span class="special">></span>
+<span class="keyword">struct</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">count_trailing_zeros</span> <span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span> <span class="special">};</span>
+
+<span class="keyword">template</span> <span class="special"><</span><span class="identifier">uintmax_t</span> <span class="identifier">Value</span><span class="special">></span>
+<span class="keyword">struct</span> <span class="identifier">static_count_trailing_zeros</span> <span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span> <span class="special">};</span>
</pre>
-<p>
- </p>
</div>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+<span class="bold"><strong>Remarks: </strong></span> If <code class="computeroutput"><span class="identifier">value</span></code>
+ is 0, the result is undefined.
+ </li>
+<li class="listitem">
+<span class="bold"><strong>Requires: </strong></span> For the <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">count_trailing_zeros</span><span class="special"><></span></code> version, <code class="computeroutput"><span class="identifier">IC</span></code>
+ must be an mpl::integral_c<> type.
+ </li>
+<li class="listitem">
+<span class="bold"><strong>Returns: </strong></span> For the runtime version, the
+ number of consecutive zeros from the least significant bit. In the compile-time
+ versions, the number of consecutive zeros in the <code class="computeroutput"><span class="identifier">value</span></code>
+ static member.
+ </li>
+</ul></div>
</div>
-<div class="section" title="Sign function">
+<div class="section" title="Greatest Common Divisor">
<div class="titlepage"><div><div><h3 class="title">
-<a name="boost_integer.bits_and_ints.sign"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.sign" title="Sign function"> Sign function</a>
+<a name="boost_integer.bits_and_ints.greatest_common_divisor_"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.greatest_common_divisor_" title="Greatest Common Divisor">Greatest
+ Common Divisor </a>
</h3></div></div></div>
-<div class="toc"><dl>
-<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.sign.non_member_function__sign_">Non-Member
- Function <code class="computeroutput"><span class="identifier">sign</span></code></a></span></dt>
-<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.sign.static_functions__mpl__sign__and__static_sign_">Static
- Functions <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">sign</span></code> and <code class="computeroutput"><span class="identifier">static_sign</span></code></a></span></dt>
-<dt><span class="section">Examples</span></dt>
-</dl></div>
+<div class="toc"><dl><dt><span class="section">Synopsis</span></dt></dl></div>
<p>
- The <code class="computeroutput"><span class="identifier">sign</span></code> function checks
- the sign of integrals.
+ The header file <boost/integer/static_gcd.hpp>
+ defines <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">gcd</span><span class="special"><></span></code>
+ metafunction wich calculates the greatest common divisor of two given <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>.
</p>
-<div class="section" title="Non-Member Function sign">
+<div class="section" title="Synopsis">
<div class="titlepage"><div><div><h4 class="title">
-<a name="boost_integer.bits_and_ints.sign.non_member_function__sign_"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.sign.non_member_function__sign_" title="Non-Member Function sign">Non-Member
- Function <code class="computeroutput"><span class="identifier">sign</span></code></a>
+<a name="boost_integer.bits_and_ints.greatest_common_divisor_.synopsis"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.greatest_common_divisor_.synopsis" title="Synopsis">Synopsis</a>
</h4></div></div></div>
-<p>
- The run-time version can be included via <boost/integer/sign.hpp>.
- </p>
-<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
-<span class="keyword">int</span> <span class="identifier">sign</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">data</span><span class="special">);</span>
+<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">ICT1</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">ICT2</span><span class="special">></span>
+<span class="keyword">struct</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">gcd</span> <span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">uintmax_t</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span> <span class="special">};</span>
</pre>
-<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><span class="bold"><strong>Parameters:</strong></span></li></ul></div>
-<div class="informaltable"><table class="table">
-<colgroup>
-<col>
-<col>
-</colgroup>
-<thead><tr>
-<th>
- <p>
- Parameter
- </p>
- </th>
-<th>
- <p>
- Description
- </p>
- </th>
-</tr></thead>
-<tbody><tr>
-<td>
- <p>
- <code class="computeroutput"><span class="identifier">data</span></code>
- </p>
- </td>
-<td>
- <p>
- The data to be checked. The type of data <span class="bold"><strong>must</strong></span>
- be an integral otherwise, sign(data) will result in an error.
- </p>
- </td>
-</tr></tbody>
-</table></div>
-<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><span class="bold"><strong>Returns:</strong></span></li></ul></div>
-<div class="informaltable"><table class="table">
-<colgroup>
-<col>
-<col>
-</colgroup>
-<thead><tr>
-<th>
- <p>
- Value
- </p>
- </th>
-<th>
- <p>
- Description
- </p>
- </th>
-</tr></thead>
-<tbody>
-<tr>
-<td>
- <p>
- <code class="computeroutput"><span class="special">-</span><span class="number">1</span></code>
- </p>
- </td>
-<td>
- <p>
- <code class="computeroutput"><span class="identifier">data</span></code> is negative.
- </p>
- </td>
-</tr>
-<tr>
-<td>
- <p>
- <code class="computeroutput"><span class="number">0</span></code>
- </p>
- </td>
-<td>
- <p>
- <code class="computeroutput"><span class="identifier">data</span></code> is equal to
- zero.
- </p>
- </td>
-</tr>
-<tr>
-<td>
- <p>
- <code class="computeroutput"><span class="number">1</span></code>
- </p>
- </td>
-<td>
- <p>
- <code class="computeroutput"><span class="identifier">data</span></code> is positive.
- </p>
- </td>
-</tr>
-</tbody>
-</table></div>
-<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
-<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">T</span></code>
- must be an integral type.
- </li></ul></div>
</div>
-<div class="section" title="Static Functions mpl::sign and static_sign">
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">ICT1</span></code>
+ and <code class="computeroutput"><span class="identifier">ICT2</span></code> must be <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
+ types.
+ </li>
+<li class="listitem">
+<span class="bold"><strong>Results: </strong></span> The member <code class="computeroutput"><span class="identifier">value</span>
+ </code> will be the greatest commom divisor from <code class="computeroutput"><span class="identifier">IC1</span></code>
+ and <code class="computeroutput"><span class="identifier">IC2</span></code>.
+ </li>
+</ul></div>
+</div>
+<div class="section" title="is_integral_constant<> metafunction">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.bits_and_ints._is_integral_constant____metafunction_"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints._is_integral_constant____metafunction_" title="is_integral_constant<> metafunction"><code class="computeroutput"><span class="identifier">is_integral_constant</span><span class="special"><></span></code>
+ metafunction </a>
+</h3></div></div></div>
+<div class="toc"><dl><dt><span class="section">Synopsis</span></dt></dl></div>
+<p>
+ The header file <boost/integer/is_integral_constant.hpp>
+ defines <code class="computeroutput"><span class="identifier">is_integral_constant</span><span class="special"><></span></code> static metafunction wich verifies
+ if an given template parameter is or not a <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>.
+ </p>
+<div class="section" title="Synopsis">
<div class="titlepage"><div><div><h4 class="title">
-<a name="boost_integer.bits_and_ints.sign.static_functions__mpl__sign__and__static_sign_"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.sign.static_functions__mpl__sign__and__static_sign_" title="Static Functions mpl::sign and static_sign">Static
- Functions <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">sign</span></code> and <code class="computeroutput"><span class="identifier">static_sign</span></code></a>
+<a name="boost_integer.bits_and_ints._is_integral_constant____metafunction_.synopsis"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints._is_integral_constant____metafunction_.synopsis" title="Synopsis">Synopsis</a>
</h4></div></div></div>
-<p>
- The compile-time versions can be included via <boost/integer/static_sign.hpp>.
- </p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">IC</span><span class="special">></span>
-<span class="keyword">struct</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">sign</span> <span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span> <span class="special">};</span>
-
-<span class="keyword">template</span> <span class="special"><</span><span class="keyword">template</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">Value</span><span class="special">></span>
-<span class="keyword">struct</span> <span class="identifier">static_same_sign</span> <span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span> <span class="special">};</span>
-</pre>
-<div class="informaltable"><table class="table">
-<colgroup>
-<col>
-<col>
-</colgroup>
-<thead><tr>
-<th>
- <p>
- Parameter
- </p>
- </th>
-<th>
- <p>
- Description
- </p>
- </th>
-</tr></thead>
-<tbody>
-<tr>
-<td>
- <p>
- <code class="computeroutput"><span class="identifier">IC</span></code>
- </p>
- </td>
-<td>
- <p>
- A <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
- type.
- </p>
- </td>
-</tr>
-<tr>
-<td>
- <p>
- <code class="computeroutput"><span class="identifier">T</span></code>
- </p>
- </td>
-<td>
- <p>
- The value type. Must be an integral type.
- </p>
- </td>
-</tr>
-<tr>
-<td>
- <p>
- <code class="computeroutput"><span class="identifier">Value</span></code>
- </p>
- </td>
-<td>
- <p>
- The value to be checked.
- </p>
- </td>
-</tr>
-</tbody>
-</table></div>
-<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
-<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">T</span></code>
- to be an integral type and <code class="computeroutput"><span class="identifier">IC</span></code>
- to be an <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
- type.
- </li></ul></div>
-</div>
-<div class="section" title="Examples">
-<div class="titlepage"><div><div><h4 class="title">
-<a name="boost_integer.bits_and_ints.sign.examples"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.sign.examples" title="Examples">Examples</a>
-</h4></div></div></div>
-<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><span class="bold"><strong>Run-time version:</strong></span></li></ul></div>
-<p>
-
-</p>
-<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">integer</span><span class="special">/</span><span class="identifier">sign</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
-<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
-
-<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
-<span class="special">{</span>
- <span class="keyword">int</span> <span class="identifier">first</span> <span class="special">=</span> <span class="special">-</span><span class="number">100</span><span class="special">,</span> <span class="identifier">second</span> <span class="special">=</span> <span class="number">340</span><span class="special">,</span> <span class="identifier">third</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>
-
- <span class="keyword">int</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">sign</span><span class="special">(</span><span class="identifier">first</span><span class="special">);</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">result</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// -1
-</span>
- <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">sign</span><span class="special">(</span><span class="identifier">second</span><span class="special">);</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">result</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// 1
-</span>
- <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">sign</span><span class="special">(</span><span class="identifier">third</span><span class="special">);</span>
- <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">result</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// 0
-</span><span class="special">}</span>
+<span class="keyword">struct</span> <span class="identifier">is_integral_constant</span> <span class="special">{</span> <span class="emphasis"><em>implementation-defined</em></span> <span class="special">};</span>
</pre>
-<p>
- </p>
</div>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
+<span class="bold"><strong>Results: </strong></span><div class="itemizedlist"><ul class="itemizedlist" type="circle">
+<li class="listitem">
+ If <code class="computeroutput"><span class="identifier">IC</span></code> is a <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
+ type, <code class="computeroutput"><span class="identifier">is_integral_constant</span><span class="special"><</span><span class="identifier">IC</span><span class="special">></span></code> will inherit from <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">true_</span></code>
+</li>
+<li class="listitem">
+ If <code class="computeroutput"><span class="identifier">IC</span></code> is not a <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
+ type, <code class="computeroutput"><span class="identifier">is_integral_constant</span><span class="special"><</span><span class="identifier">IC</span><span class="special">></span></code> will inherit from <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">false_</span></code>
+</li>
+</ul></div>
+</li></ul></div>
</div>
-<div class="section" title="Bit Iterleaving">
+<div class="section" title="Least Common Multiple">
<div class="titlepage"><div><div><h3 class="title">
-<a name="boost_integer.bits_and_ints.bit_iterleaving"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.bit_iterleaving" title="Bit Iterleaving">Bit Iterleaving</a>
+<a name="boost_integer.bits_and_ints.least_common_multiple_"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.least_common_multiple_" title="Least Common Multiple">Least
+ Common Multiple </a>
</h3></div></div></div>
-<div class="toc"><dl>
-<dt><span class="section">Synopsis</span></dt>
-<dt><span class="section">Examples</span></dt>
-</dl></div>
-<p>
- Interleaved bits (aka Morton numbers) http://en.wikipedia.org/wiki/Morton_number_(number_theory)
- are useful for linearizing 2D integer coordinates, so x and y are combined
- into a single number that can be compared easily and has the property that
- a number is usually close to another if their x and y values are close. These
- functions are defined in the header <boost/integer/interleave.hpp>.
- </p>
-<div class="section" title="Synopsis">
-<div class="titlepage"><div><div><h4 class="title">
-<a name="boost_integer.bits_and_ints.bit_iterleaving.synopsis"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.bit_iterleaving.synopsis" title="Synopsis">Synopsis</a>
-</h4></div></div></div>
-<p>
-
-</p>
-<pre class="programlisting"><span class="identifier">T2</span> <span class="identifier">interleave</span><span class="special">(</span><span class="identifier">T1</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T1</span> <span class="identifier">y</span><span class="special">);</span>
-
-<span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><</span><span class="identifier">T1</span><span class="special">,</span> <span class="identifier">T1</span><span class="special">></span> <span class="identifier">uninterleave</span><span class="special">(</span><span class="identifier">T2</span> <span class="identifier">number</span><span class="special">);</span>
-</pre>
-<p>
- </p>
-</div>
-<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
-<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">T1</span></code>
- and <code class="computeroutput"><span class="identifier">T2</span></code> must be integral
- types. Additionally, <code class="computeroutput"><span class="identifier">T1</span></code>
- must have 8, 16 or 32 bits and <code class="computeroutput"><span class="identifier">T2</span></code>
- must have 16, 32 or 64 bits. For these functions <code class="computeroutput"><span class="identifier">T2</span></code>
- have the double of bits wich <code class="computeroutput"><span class="identifier">T1</span></code>
- have.
- </li></ul></div>
+<div class="toc"><dl><dt><span class="section">Synopsis</span></dt></dl></div>
<p>
- <span class="bold"><strong>Returns: </strong></span> <code class="computeroutput"><span class="identifier">interleave</span></code>
- function returns <code class="computeroutput"><span class="identifier">x</span></code> and <code class="computeroutput"><span class="identifier">y</span></code> interleaved. <code class="computeroutput"><span class="identifier">x</span></code>
- will be in the even bits and <code class="computeroutput"><span class="identifier">y</span></code>
- will be on odd positions, so the return type have the double of bits than
- the paramter's type.
+ This header defines mpl::lcm<> metafunction wich calculates the least
+ common multiple from two given <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>.
</p>
<p>
- <code class="computeroutput"><span class="identifier">uninterleave</span></code> returns an
- <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special"><></span></code>
- where in the member <code class="computeroutput"><span class="identifier">first</span></code>
- will be the integral represented in the even positions of <code class="computeroutput"><span class="identifier">number</span></code>
- and in the <code class="computeroutput"><span class="identifier">second</span></code> member
- will be the integral represented in the odd positions of <code class="computeroutput"><span class="identifier">number</span></code>.
+ This static metafunction is defined on <boost/integer/static_lcm.hpp>.
</p>
-<div class="section" title="Examples">
+<div class="section" title="Synopsis">
<div class="titlepage"><div><div><h4 class="title">
-<a name="boost_integer.bits_and_ints.bit_iterleaving.examples"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.bit_iterleaving.examples" title="Examples">Examples</a>
+<a name="boost_integer.bits_and_ints.least_common_multiple_.synopsis"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.least_common_multiple_.synopsis" title="Synopsis">Synopsis</a>
</h4></div></div></div>
-<p>
-
-</p>
-<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">integer</span><span class="special">/</span><span class="identifier">interleave</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
-<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">utility</span><span class="special">></span>
-<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
-
-<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">std</span><span class="special">;</span>
-<span class="keyword">using</span> <span class="keyword">namespace</span> <span class="identifier">boost</span><span class="special">;</span>
-
-<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
-<span class="special">{</span>
- <span class="identifier">uint_t</span><span class="special"><</span><span class="number">64</span><span class="special">>::</span><span class="identifier">exact</span> <span class="identifier">inter</span> <span class="special">=</span> <span class="identifier">interleave</span><span class="special"><</span><span class="number">32</span><span class="special">>(</span><span class="number">0x10</span><span class="special">,</span> <span class="number">0x0e</span><span class="special">);</span>
-
- <span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"interleaved number: "</span><span class="special">;</span>
- <span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">hex</span> <span class="special"><<</span> <span class="identifier">inter</span> <span class="special"><<</span> <span class="identifier">endl</span><span class="special">;</span>
-
- <span class="identifier">pair</span><span class="special"><</span><span class="identifier">uint8_t</span><span class="special">,</span> <span class="identifier">uint8_t</span><span class="special">></span> <span class="identifier">uninter</span> <span class="special">=</span> <span class="identifier">uninterleave</span><span class="special"><</span><span class="number">16</span><span class="special">>(</span><span class="identifier">inter</span><span class="special">);</span>
-
- <span class="identifier">uint8_t</span> <span class="identifier">a</span> <span class="special">=</span> <span class="identifier">uninter</span><span class="special">.</span><span class="identifier">first</span><span class="special">,</span> <span class="identifier">b</span> <span class="special">=</span> <span class="identifier">uninter</span><span class="special">.</span><span class="identifier">second</span><span class="special">;</span>
-
- <span class="identifier">cout</span> <span class="special"><<</span> <span class="string">"uninterleaved number: "</span><span class="special">;</span>
- <span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">hex</span> <span class="special"><<</span> <span class="keyword">unsigned</span><span class="special">(</span><span class="identifier">a</span><span class="special">)</span> <span class="special"><<</span> <span class="string">" "</span> <span class="special"><<</span> <span class="keyword">unsigned</span><span class="special">(</span><span class="identifier">b</span><span class="special">)</span> <span class="special"><<</span> <span class="identifier">endl</span><span class="special">;</span>
-<span class="special">}</span>
+<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">ICT1</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">ICT2</span><span class="special">></span>
+<span class="keyword">struct</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">lcm</span> <span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">uintmax_t</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span> <span class="special">};</span>
</pre>
-<p>
- </p>
</div>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">ICT1</span></code>
+ and <code class="computeroutput"><span class="identifier">ICT2</span></code> must be <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
+ types.
+ </li>
+<li class="listitem">
+<span class="bold"><strong>Results: </strong></span> The member <code class="computeroutput"><span class="identifier">value</span>
+ </code> will be the least common multiple from <code class="computeroutput"><span class="identifier">IC1</span></code>
+ and <code class="computeroutput"><span class="identifier">IC2</span></code>.
+ </li>
+</ul></div>
</div>
<div class="section" title="Population Count (count bits set)">
<div class="titlepage"><div><div><h3 class="title">
@@ -1161,86 +895,56 @@
</li>
</ul></div>
</div>
-<div class="section" title="Clear Least Bit Set">
+<div class="section" title="Round to Power of 2 functions">
<div class="titlepage"><div><div><h3 class="title">
-<a name="boost_integer.bits_and_ints.clear_least_bit_set"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.clear_least_bit_set" title="Clear Least Bit Set">Clear
- Least Bit Set</a>
+<a name="boost_integer.bits_and_ints.round_to_power_of_2_functions"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.round_to_power_of_2_functions" title="Round to Power of 2 functions">Round
+ to Power of 2 functions</a>
</h3></div></div></div>
-<div class="toc"><dl><dt><span class="section">Synopsis</span></dt></dl></div>
+<div class="toc"><dl><dt><span class="section">Synopsis</span></dt></dl></div>
<p>
- Clears least significant 1 bit in an integral. The <code class="computeroutput"><span class="identifier">clear_least_bit_set</span><span class="special">()</span></code> function is defined on <boost/integer/clear_least_bit_set.hpp>.
+ This function rounds up and down positive integral values to the next power
+ of 2. The <code class="computeroutput"><span class="identifier">ceil_pow2</span></code> function
+ rounds up and <code class="computeroutput"><span class="identifier">floor_pow2</span></code>
+ function rounds down. These functions are defined on <boost/integer/round_pow2.hpp>
</p>
<div class="section" title="Synopsis">
<div class="titlepage"><div><div><h4 class="title">
-<a name="boost_integer.bits_and_ints.clear_least_bit_set.synopsis"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.clear_least_bit_set.synopsis" title="Synopsis">Synopsis</a>
+<a name="boost_integer.bits_and_ints.round_to_power_of_2_functions.synopsis"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.round_to_power_of_2_functions.synopsis" title="Synopsis">Synopsis</a>
</h4></div></div></div>
-<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
-<span class="identifier">T</span> <span class="identifier">clear_least_bit_set</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">value</span><span class="special">);</span>
-
-<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">IC</span><span class="special">></span>
-<span class="keyword">struct</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">clear_least_bit_set</span> <span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">typename</span> <span class="identifier">IC</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span> <span class="special">};</span>
-
-<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">Value</span><span class="special">></span>
-<span class="keyword">struct</span> <span class="identifier">static_clear_least_bit_set</span> <span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span> <span class="special">};</span>
+<pre class="programlisting"><span class="identifier">T</span> <span class="identifier">ceil_pow2</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">value</span><span class="special">);</span>
+<span class="identifier">T</span> <span class="identifier">floor_pow2</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">value</span><span class="special">);</span>
</pre>
</div>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">T</span></code>
- must be an integral type. <code class="computeroutput"><span class="identifier">IC</span></code>
- must be an <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
- type.
+ must be an integral type and <code class="computeroutput"><span class="identifier">value</span></code>
+ must be positive. If <code class="computeroutput"><span class="identifier">value</span></code>
+ is negative, the result is undefined.
</li>
<li class="listitem">
-<span class="bold"><strong>Returns: </strong></span><code class="computeroutput"><span class="identifier">value</span></code>
- with it's least significant active bit disactivated.
- </li>
+<span class="bold"><strong>Returns: </strong></span><div class="itemizedlist"><ul class="itemizedlist" type="circle">
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">ceil_pow2</span><span class="special">()</span></code>
+ returns <code class="computeroutput"><span class="identifier">value</span></code> rounded
+ <span class="bold"><strong>up</strong></span> to the lesser power of two greater
+ than or equal to `value.
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">floor_pow2</span><span class="special">()</span></code>
+ returns <code class="computeroutput"><span class="identifier">value</span></code> rounded
+ <span class="bold"><strong>down</strong></span> to the greater power of two lesser
+ or equal <code class="computeroutput"><span class="identifier">value</span></code>.
+ </li>
+</ul></div>
+</li>
</ul></div>
</div>
-<div class="section" title="Count Trailing Zeros">
+<div class="section" title="Safe Average">
<div class="titlepage"><div><div><h3 class="title">
-<a name="boost_integer.bits_and_ints.count_trailing_zeros"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.count_trailing_zeros" title="Count Trailing Zeros">Count
- Trailing Zeros</a>
+<a name="boost_integer.bits_and_ints.safe_average"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.safe_average" title="Safe Average">Safe Average</a>
</h3></div></div></div>
-<div class="toc"><dl><dt><span class="section">Synopsis</span></dt></dl></div>
-<p>
- The <code class="computeroutput"><span class="identifier">count_trailing_zeros</span></code>
- function and metafunctions counts the number of consecutive 0's from the
- least significant bit of an integral value. The runtime function is defined
- on <boost/integer/count_trailing_zeros.hpp>
- and the compile-time metafunctions are defined on <boost/integer/static_count_trailing_zeros.hpp>
- </p>
-<div class="section" title="Synopsis">
-<div class="titlepage"><div><div><h4 class="title">
-<a name="boost_integer.bits_and_ints.count_trailing_zeros.synopsis"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.count_trailing_zeros.synopsis" title="Synopsis">Synopsis</a>
-</h4></div></div></div>
-<pre class="programlisting"><span class="keyword">int</span> <span class="identifier">count_trailing_zeros</span><span class="special">(</span><span class="identifier">uintmax_t</span> <span class="identifier">value</span><span class="special">);</span>
-
-<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">IC</span><span class="special">></span>
-<span class="keyword">struct</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">count_trailing_zeros</span> <span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span> <span class="special">};</span>
-
-<span class="keyword">template</span> <span class="special"><</span><span class="identifier">uintmax_t</span> <span class="identifier">Value</span><span class="special">></span>
-<span class="keyword">struct</span> <span class="identifier">static_count_trailing_zeros</span> <span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span> <span class="special">};</span>
-</pre>
-</div>
-<div class="itemizedlist"><ul class="itemizedlist" type="disc">
-<li class="listitem">
-<span class="bold"><strong>Requires: </strong></span> For the <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">count_trailing_zeros</span><span class="special"><></span></code> version, <code class="computeroutput"><span class="identifier">IC</span></code>
- must be an mpl::integral_c<> type.
- </li>
-<li class="listitem">
-<span class="bold"><strong>Returns: </strong></span> For the runtime version, the
- number of consecutive zeros from the least significant bit. In the compile-time
- versions, the number of consecutive zeros in the <code class="computeroutput"><span class="identifier">value</span></code>
- static member.
- </li>
-</ul></div>
-</div>
-<div class="section" title="Safe Average">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="boost_integer.bits_and_ints.safe_average"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.safe_average" title="Safe Average">Safe Average</a>
-</h3></div></div></div>
-<div class="toc"><dl><dt><span class="section">Synopsis</span></dt></dl></div>
+<div class="toc"><dl><dt><span class="section">Synopsis</span></dt></dl></div>
<p>
Given two integer values x and y, the (floor of the) average normally would
be computed by <code class="computeroutput"><span class="special">(</span><span class="identifier">x</span><span class="special">+</span><span class="identifier">y</span><span class="special">)/</span><span class="number">2</span></code> unfortunately, this can yield incorrect results
@@ -1275,520 +979,845 @@
</li>
</ul></div>
</div>
-<div class="section" title="Round to Power of 2 functions">
+<div class="section" title="Same Sign">
<div class="titlepage"><div><div><h3 class="title">
-<a name="boost_integer.bits_and_ints.round_to_power_of_2_functions"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.round_to_power_of_2_functions" title="Round to Power of 2 functions">Round
- to Power of 2 functions</a>
+<a name="boost_integer.bits_and_ints.same_sign"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.same_sign" title="Same Sign"> Same Sign</a>
</h3></div></div></div>
-<div class="toc"><dl><dt><span class="section">Synopsis</span></dt></dl></div>
+<div class="toc"><dl>
+<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.same_sign.non_member_function__same_sign_">Non-Member
+ Function <code class="computeroutput"><span class="identifier">same_sign</span></code></a></span></dt>
+<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.same_sign.template_class__static_same_sign___">Template
+ Class <code class="computeroutput"><span class="identifier">static_same_sign</span><span class="special"><></span></code></a></span></dt>
+<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.same_sign.template_class__mpl__same_sign___">Template
+ Class <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">same_sign</span><span class="special"><></span></code></a></span></dt>
+<dt><span class="section">Examples</span></dt>
+</dl></div>
<p>
- This function rounds up and down positive integral values to the next power
- of 2. The <code class="computeroutput"><span class="identifier">ceil_pow2</span></code> function
- rounds up and <code class="computeroutput"><span class="identifier">floor_pow2</span></code>
- function rounds down. These functions are defined on <boost/integer/round_pow2.hpp>
+ These functions check if wheter the sign of two integers are equal.
</p>
-<div class="section" title="Synopsis">
+<div class="section" title="Non-Member Function same_sign">
<div class="titlepage"><div><div><h4 class="title">
-<a name="boost_integer.bits_and_ints.round_to_power_of_2_functions.synopsis"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.round_to_power_of_2_functions.synopsis" title="Synopsis">Synopsis</a>
+<a name="boost_integer.bits_and_ints.same_sign.non_member_function__same_sign_"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.same_sign.non_member_function__same_sign_" title="Non-Member Function same_sign">Non-Member
+ Function <code class="computeroutput"><span class="identifier">same_sign</span></code></a>
</h4></div></div></div>
-<pre class="programlisting"><span class="identifier">T</span> <span class="identifier">ceil_pow2</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">value</span><span class="special">);</span>
-<span class="identifier">T</span> <span class="identifier">floor_pow2</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">value</span><span class="special">);</span>
-</pre>
-</div>
-<div class="itemizedlist"><ul class="itemizedlist" type="disc">
-<li class="listitem">
-<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">T</span></code>
- must be an integral type and <code class="computeroutput"><span class="identifier">value</span></code>
- must be positive. If <code class="computeroutput"><span class="identifier">value</span></code>
- is negative, the result is undefined.
- </li>
-<li class="listitem">
-<span class="bold"><strong>Returns: </strong></span><div class="itemizedlist"><ul class="itemizedlist" type="circle">
-<li class="listitem">
-<code class="computeroutput"><span class="identifier">ceil_pow2</span><span class="special">()</span></code>
- returns <code class="computeroutput"><span class="identifier">value</span></code> rounded
- <span class="bold"><strong>up</strong></span> to the lesser power of two greater
- than or equal to `value.
- </li>
-<li class="listitem">
-<code class="computeroutput"><span class="identifier">floor_pow2</span><span class="special">()</span></code>
- returns <code class="computeroutput"><span class="identifier">value</span></code> rounded
- <span class="bold"><strong>down</strong></span> to the greater power of two lesser
- or equal <code class="computeroutput"><span class="identifier">value</span></code>.
- </li>
-</ul></div>
-</li>
-</ul></div>
-</div>
-<div class="section" title="Transfer of Sign (isign) functions">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="boost_integer.bits_and_ints.transfer_of_sign__isign__functions_"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.transfer_of_sign__isign__functions_" title="Transfer of Sign (isign) functions">Transfer
- of Sign (isign) functions </a>
-</h3></div></div></div>
-<div class="toc"><dl><dt><span class="section">Synopsis</span></dt></dl></div>
-<p>
- isign or transfer of sign function is defined by:
-</p>
-<pre class="programlisting"><span class="identifier">isign</span><span class="special">(</span><span class="identifier">x</span><span class="special">,</span> <span class="identifier">y</span><span class="special">)</span> <span class="special">=</span>
- <span class="identifier">abs</span><span class="special">(</span><span class="identifier">x</span><span class="special">),</span> <span class="keyword">if</span> <span class="identifier">y</span> <span class="identifier">is</span> <span class="identifier">greater</span> <span class="identifier">than</span> <span class="keyword">or</span> <span class="identifier">equal</span> <span class="number">0</span><span class="special">,</span>
-<span class="special">-</span><span class="identifier">abs</span><span class="special">(</span><span class="identifier">x</span><span class="special">),</span> <span class="keyword">if</span> <span class="identifier">y</span> <span class="identifier">is</span> <span class="identifier">less</span> <span class="identifier">than</span> <span class="number">0</span>
-</pre>
-<p>
- </p>
<p>
- The runtime functions are defined on <boost/integer/isign.hpp>
- and the static metafunctions are defined on <boost/integer/static_isign.hpp>
- </p>
-<div class="section" title="Synopsis">
-<div class="titlepage"><div><div><h4 class="title">
-<a name="boost_integer.bits_and_ints.transfer_of_sign__isign__functions_.synopsis"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.transfer_of_sign__isign__functions_.synopsis" title="Synopsis">Synopsis</a>
-</h4></div></div></div>
+ The run-time version can be included via <boost/integer/same_sign.hpp>.
+ For valid types T, the function <code class="computeroutput"><span class="identifier">bit_reversal</span></code>
+ will be:
+ </p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
-<span class="identifier">T</span> <span class="identifier">isign</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">y</span><span class="special">);</span>
-
-<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">Value1</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">Value2</span><span class="special">></span>
-<span class="keyword">struct</span> <span class="identifier">static_isign</span> <span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span> <span class="special">};</span>
-
-<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">IC1</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">IC2</span><span class="special">></span>
-<span class="keyword">struct</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">isign</span> <span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">typename</span> <span class="identifier">IC1</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span> <span class="special">};</span>
+<span class="keyword">inline</span> <span class="keyword">bool</span> <span class="identifier">same_sign</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">first</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">second</span><span class="special">);</span>
</pre>
-</div>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><span class="bold"><strong>Parameters:</strong></span></li></ul></div>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<thead><tr>
+<th>
+ <p>
+ Parameter
+ </p>
+ </th>
+<th>
+ <p>
+ Description
+ </p>
+ </th>
+</tr></thead>
+<tbody><tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">first</span></code>, <code class="computeroutput"><span class="identifier">second</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ The two integral values to be compared. The type of data <span class="bold"><strong>must</strong></span> be an integral type. <code class="computeroutput"><span class="identifier">first</span></code> and <code class="computeroutput"><span class="identifier">second</span></code>
+ must have the same type.
+ </p>
+ </td>
+</tr></tbody>
+</table></div>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
-<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">T</span></code>
- must be an integral type. Both <code class="computeroutput"><span class="identifier">IC1</span></code>
- and <code class="computeroutput"><span class="identifier">IC2</span></code> must be <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
- types.
- </li>
-<li class="listitem">
-<span class="bold"><strong>Returns: </strong></span><div class="itemizedlist"><ul class="itemizedlist" type="circle">
-<li class="listitem">
- Runtime version: returns <code class="computeroutput"><span class="identifier">abs</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code> if <code class="computeroutput"><span class="identifier">y</span></code>
- is greater than or equal 0 and <code class="computeroutput"><span class="special">-</span><span class="identifier">abs</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code>
- if <code class="computeroutput"><span class="identifier">y</span></code> is negative.
- </li>
-<li class="listitem">
- MPL version: the member <code class="computeroutput"><span class="identifier">value</span></code>
- will be <code class="computeroutput"><span class="identifier">abs</span><span class="special">(</span><span class="identifier">IC1</span><span class="special">::</span><span class="identifier">value</span><span class="special">)</span></code>
- if <code class="computeroutput"><span class="identifier">IC2</span></code> holds an value
- greater than or equal 0, or <code class="computeroutput"><span class="special">-</span><span class="identifier">abs</span><span class="special">(</span><span class="identifier">IC1</span><span class="special">::</span><span class="identifier">value</span><span class="special">)</span></code>
- if <code class="computeroutput"><span class="identifier">IC2</span></code> holds a negative
- value.
- </li>
+<span class="bold"><strong>Returns: </strong></span><code class="computeroutput"><span class="keyword">false</span></code>
+ if the signs of first and second are different or <code class="computeroutput"><span class="keyword">true</span></code>
+ if the signs are equal
+ </li>
<li class="listitem">
-<code class="computeroutput"><span class="identifier">static_isign</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">Value1</span><span class="special">,</span>
- <span class="identifier">Value2</span><span class="special">>::</span><span class="identifier">value</span></code> will be <code class="computeroutput"><span class="identifier">abs</span><span class="special">(</span><span class="identifier">Value1</span><span class="special">)</span></code> if Value2 is greater than or equal
- 0, or <code class="computeroutput"><span class="special">-</span><span class="identifier">abs</span><span class="special">(</span><span class="identifier">Value1</span><span class="special">)</span></code> if Value2 is negative.
- </li>
-</ul></div>
-</li>
+<span class="bold"><strong>Remarks: </strong></span><code class="computeroutput"><span class="identifier">T</span></code>
+ must be an integral type.
+ </li>
</ul></div>
</div>
-<div class="section" title="Absolute Value in Compile-Time">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="boost_integer.bits_and_ints.absolute_value_in_compile_time_"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.absolute_value_in_compile_time_" title="Absolute Value in Compile-Time">Absolute
- Value in Compile-Time </a>
-</h3></div></div></div>
-<div class="toc"><dl><dt><span class="section">Synopsis</span></dt></dl></div>
-<p>
- The static metafunctions defined on <boost/integer/static_abs.hpp>
- calculates the absolute value of integral constants.
- </p>
-<p>
- <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">abs</span><span class="special"><></span></code>
- version returns the absolute value of a <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code> and the <code class="computeroutput"><span class="identifier">static_abs</span><span class="special"><></span></code> version returns the absolute value
- from an integral value.
- </p>
-<div class="section" title="Synopsis">
+<div class="section" title="Template Class static_same_sign<>">
<div class="titlepage"><div><div><h4 class="title">
-<a name="boost_integer.bits_and_ints.absolute_value_in_compile_time_.synopsis"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.absolute_value_in_compile_time_.synopsis" title="Synopsis">Synopsis</a>
+<a name="boost_integer.bits_and_ints.same_sign.template_class__static_same_sign___"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.same_sign.template_class__static_same_sign___" title="Template Class static_same_sign<>">Template
+ Class <code class="computeroutput"><span class="identifier">static_same_sign</span><span class="special"><></span></code></a>
</h4></div></div></div>
-<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">IC</span><span class="special">></span>
-<span class="keyword">struct</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">abs</span> <span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">typename</span> <span class="identifier">IC</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span> <span class="special">};</span>
-
-<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">Value</span><span class="special">></span>
-<span class="keyword">struct</span> <span class="identifier">static_abs</span> <span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span> <span class="special">};</span>
-</pre>
-</div>
-<div class="itemizedlist"><ul class="itemizedlist" type="disc">
-<li class="listitem">
-<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">T</span></code>
- must be an integral type. <code class="computeroutput"><span class="identifier">IC</span></code>
- a <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
- type.
- </li>
-<li class="listitem">
-<span class="bold"><strong>Results: </strong></span> The member <code class="computeroutput"><span class="identifier">value</span>
- </code> in <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">abs</span><span class="special"><></span></code>
- will be the absolute value of <code class="computeroutput"><span class="identifier">IC</span><span class="special">::</span><span class="identifier">value</span></code>.
- In <code class="computeroutput"><span class="identifier">static_abs</span><span class="special"><></span></code>,
- <code class="computeroutput"><span class="identifier">value</span></code> will be the absolute
- value of <code class="computeroutput"><span class="identifier">Value</span></code>.
- </li>
-</ul></div>
-</div>
-<div class="section" title="MPL Least Common Multiple">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="boost_integer.bits_and_ints.mpl_least_common_multiple_"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.mpl_least_common_multiple_" title="MPL Least Common Multiple">MPL
- Least Common Multiple </a>
-</h3></div></div></div>
-<div class="toc"><dl><dt><span class="section">Synopsis</span></dt></dl></div>
-<p>
- This header defines mpl::lcm<> metafunction wich calculates the least
- common multiple from two given <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>.
- </p>
<p>
- This static metafunction is defined on <boost/integer/static_lcm.hpp>.
- </p>
-<div class="section" title="Synopsis">
-<div class="titlepage"><div><div><h4 class="title">
-<a name="boost_integer.bits_and_ints.mpl_least_common_multiple_.synopsis"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.mpl_least_common_multiple_.synopsis" title="Synopsis">Synopsis</a>
-</h4></div></div></div>
-<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">ICT1</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">ICT2</span><span class="special">></span>
-<span class="keyword">struct</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">lcm</span> <span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">uintmax_t</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span> <span class="special">};</span>
+ The compile-time version can be included via <boost/integer/static_same_sign.hpp>.
+ The result will be in <code class="computeroutput"><span class="identifier">value</span></code>
+ member.
+ </p>
+<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">Value1</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">Value2</span><span class="special">></span>
+<span class="keyword">struct</span> <span class="identifier">static_same_sign</span>
+<span class="special">{</span>
+ <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">bool</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span>
+<span class="special">};</span>
</pre>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><span class="bold"><strong>Template Parameters:</strong></span></li></ul></div>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<thead><tr>
+<th>
+ <p>
+ Parameter
+ </p>
+ </th>
+<th>
+ <p>
+ Description
+ </p>
+ </th>
+</tr></thead>
+<tbody>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">T</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ The data type.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">Value1</span></code>, <code class="computeroutput"><span class="identifier">Value2</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ The two integral values to be compared.
+ </p>
+ </td>
+</tr>
+</tbody>
+</table></div>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
+<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">T</span></code>
+ must be an integral type.
+ </li></ul></div>
</div>
-<div class="itemizedlist"><ul class="itemizedlist" type="disc">
-<li class="listitem">
-<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">ICT1</span></code>
- and <code class="computeroutput"><span class="identifier">ICT2</span></code> must be <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
- types.
- </li>
-<li class="listitem">
-<span class="bold"><strong>Results: </strong></span> The member <code class="computeroutput"><span class="identifier">value</span>
- </code> will be the least common multiple from <code class="computeroutput"><span class="identifier">IC1</span></code>
- and <code class="computeroutput"><span class="identifier">IC2</span></code>.
- </li>
-</ul></div>
-</div>
-<div class="section" title="MPL Greatest Common Divisor">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="boost_integer.bits_and_ints.mpl_greatest_common_divisor_"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.mpl_greatest_common_divisor_" title="MPL Greatest Common Divisor">MPL
- Greatest Common Divisor </a>
-</h3></div></div></div>
-<div class="toc"><dl><dt><span class="section">Synopsis</span></dt></dl></div>
-<p>
- The header file <boost/integer/static_gcd.hpp>
- defines <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">gcd</span><span class="special"><></span></code>
- metafunction wich calculates the greatest common divisor of two given <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>.
- </p>
-<div class="section" title="Synopsis">
+<div class="section" title="Template Class mpl::same_sign<>">
<div class="titlepage"><div><div><h4 class="title">
-<a name="boost_integer.bits_and_ints.mpl_greatest_common_divisor_.synopsis"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.mpl_greatest_common_divisor_.synopsis" title="Synopsis">Synopsis</a>
+<a name="boost_integer.bits_and_ints.same_sign.template_class__mpl__same_sign___"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.same_sign.template_class__mpl__same_sign___" title="Template Class mpl::same_sign<>">Template
+ Class <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">same_sign</span><span class="special"><></span></code></a>
</h4></div></div></div>
-<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">ICT1</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">ICT2</span><span class="special">></span>
-<span class="keyword">struct</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">gcd</span> <span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">uintmax_t</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span> <span class="special">};</span>
+<p>
+ The MPL version can be included via <boost/integer/static_same_sign.hpp>.
+ The result will be in <code class="computeroutput"><span class="identifier">value</span></code>
+ member.
+ </p>
+<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">IC1</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">IC2</span><span class="special">></span>
+<span class="keyword">struct</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">same_sign</span>
+<span class="special">{</span>
+ <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">bool</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span>
+<span class="special">};</span>
</pre>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><span class="bold"><strong>Template Parameters:</strong></span></li></ul></div>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<thead><tr>
+<th>
+ <p>
+ Parameter
+ </p>
+ </th>
+<th>
+ <p>
+ Description
+ </p>
+ </th>
+</tr></thead>
+<tbody><tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">IC1</span></code>, <code class="computeroutput"><span class="identifier">IC2</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ The two <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
+ to be compared.
+ </p>
+ </td>
+</tr></tbody>
+</table></div>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
+<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">IC1</span></code>
+ and <code class="computeroutput"><span class="identifier">IC2</span></code> must be <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
+ types.
+ </li></ul></div>
</div>
+<div class="section" title="Examples">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_integer.bits_and_ints.same_sign.examples"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.same_sign.examples" title="Examples">Examples</a>
+</h4></div></div></div>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
-<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">ICT1</span></code>
- and <code class="computeroutput"><span class="identifier">ICT2</span></code> must be <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
- types.
- </li>
-<li class="listitem">
-<span class="bold"><strong>Results: </strong></span> The member <code class="computeroutput"><span class="identifier">value</span>
- </code> will be the greatest commom divisor from <code class="computeroutput"><span class="identifier">IC1</span></code>
- and <code class="computeroutput"><span class="identifier">IC2</span></code>.
- </li>
+<span class="bold"><strong>Run-time version:</strong></span><pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">integer</span><span class="special">/</span><span class="identifier">same_sign</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
+<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
+
+<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="keyword">int</span> <span class="identifier">first</span> <span class="special">=</span> <span class="special">-</span><span class="number">1</span><span class="special">,</span> <span class="identifier">second</span> <span class="special">=</span> <span class="special">-</span><span class="number">2</span><span class="special">,</span> <span class="identifier">third</span> <span class="special">=</span> <span class="number">1</span><span class="special">;</span>
+
+ <span class="keyword">bool</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">same_sign</span><span class="special">(</span><span class="identifier">first</span><span class="special">,</span> <span class="identifier">second</span><span class="special">);</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">result</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// true
+</span>
+ <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">same_sign</span><span class="special">(</span><span class="identifier">first</span><span class="special">,</span> <span class="identifier">third</span><span class="special">);</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">result</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// false
+</span><span class="special">}</span>
+</pre>
+</li>
+<li class="listitem"><span class="bold"><strong>Compile-time version:</strong></span></li>
</ul></div>
-</div>
-<div class="section" title="Swap without a temporary">
-<div class="titlepage"><div><div><h3 class="title">
-<a name="boost_integer.bits_and_ints.swap_without_a_temporary_"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.swap_without_a_temporary_" title="Swap without a temporary">Swap
- without a temporary </a>
-</h3></div></div></div>
-<div class="toc"><dl><dt><span class="section">Synopsis</span></dt></dl></div>
<p>
- The header file <boost/integer/swap.hpp>
- defines <code class="computeroutput"><span class="identifier">swap</span></code> function wich
- swaps 2 integral values without using a temporary variable.
- </p>
-<div class="section" title="Synopsis">
-<div class="titlepage"><div><div><h4 class="title">
-<a name="boost_integer.bits_and_ints.swap_without_a_temporary_.synopsis"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.swap_without_a_temporary_.synopsis" title="Synopsis">Synopsis</a>
-</h4></div></div></div>
-<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
-<span class="keyword">inline</span> <span class="keyword">void</span> <span class="identifier">swap</span><span class="special">(</span><span class="identifier">T</span><span class="special">&</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T</span><span class="special">&</span> <span class="identifier">y</span><span class="special">);</span>
+
+</p>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">integer</span><span class="special">/</span><span class="identifier">same_sign</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
+<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
+
+<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="keyword">bool</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">static_same_sign</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="number">2</span><span class="special">,</span> <span class="number">10</span><span class="special">>::</span><span class="identifier">value</span><span class="special">;</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">result</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">//true
+</span>
+ <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">static_same_sign</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="number">10</span><span class="special">,</span> <span class="special">-</span><span class="number">2</span><span class="special">>::</span><span class="identifier">value</span><span class="special">;</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">result</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// false
+</span><span class="special">}</span>
</pre>
+<p>
+ </p>
</div>
-<div class="itemizedlist"><ul class="itemizedlist" type="disc">
-<li class="listitem">
-<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">T</span></code>
- must be an integral type.
- </li>
-<li class="listitem">
-<span class="bold"><strong>Returns: </strong></span> Nothing. <code class="computeroutput"><span class="identifier">x</span></code>
- will have the value of <code class="computeroutput"><span class="identifier">y</span></code>
- and <code class="computeroutput"><span class="identifier">y</span></code> will have the <code class="computeroutput"><span class="identifier">x</span></code> value.
- </li>
-</ul></div>
</div>
-<div class="section" title="MPL is_integral_constant<> metafunction">
+<div class="section" title="Sign Extending">
<div class="titlepage"><div><div><h3 class="title">
-<a name="boost_integer.bits_and_ints.mpl__is_integral_constant____metafunction_"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.mpl__is_integral_constant____metafunction_" title="MPL is_integral_constant<> metafunction">MPL
- <code class="computeroutput"><span class="identifier">is_integral_constant</span><span class="special"><></span></code>
- metafunction </a>
+<a name="boost_integer.bits_and_ints.sign_extend"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.sign_extend" title="Sign Extending"> Sign Extending</a>
</h3></div></div></div>
-<div class="toc"><dl><dt><span class="section">Synopsis</span></dt></dl></div>
+<div class="toc"><dl>
+<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.sign_extend.non_member_function_template__sign_extend_">Non-Member
+ Function Template <code class="computeroutput"><span class="identifier">sign_extend</span></code></a></span></dt>
+<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.sign_extend.template_class__static_sign_extend___">Template
+ Class <code class="computeroutput"><span class="identifier">static_sign_extend</span><span class="special"><></span></code></a></span></dt>
+<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.sign_extend.template_class__mpl__sign_extend___">Template
+ Class <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">sign_extend</span><span class="special"><></span></code></a></span></dt>
+<dt><span class="section">Examples</span></dt>
+</dl></div>
<p>
- The header file <boost/integer/is_integral_constant.hpp>
- defines <code class="computeroutput"><span class="identifier">is_integral_constant</span><span class="special"><></span></code> static metafunction wich verifies
- if an given template parameter is or not a <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>.
+ Sign extension is automatic for built-in types, such as chars and ints. But
+ suppose you have a signed two's complement number, x, that is stored using
+ only b bits. Moreover, suppose you want to convert x to an int, which has
+ more than b bits. A simple copy will work if x is positive, but if negative,
+ the sign must be extended. For example, if we have only 4 bits to store a
+ number, then -3 is represented as 1101 in binary. If we have 8 bits, then
+ -3 is 11111101. The most-significant bit of the 4-bit representation is replicated
+ sinistrally to fill in the destination when we convert to a representation
+ with more bits; this is sign extending. More about sign extending on http://en.wikipedia.org/wiki/Sign_extension
</p>
-<div class="section" title="Synopsis">
+<div class="section" title="Non-Member Function Template sign_extend">
<div class="titlepage"><div><div><h4 class="title">
-<a name="boost_integer.bits_and_ints.mpl__is_integral_constant____metafunction_.synopsis"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.mpl__is_integral_constant____metafunction_.synopsis" title="Synopsis">Synopsis</a>
+<a name="boost_integer.bits_and_ints.sign_extend.non_member_function_template__sign_extend_"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.sign_extend.non_member_function_template__sign_extend_" title="Non-Member Function Template sign_extend">Non-Member
+ Function Template <code class="computeroutput"><span class="identifier">sign_extend</span></code></a>
</h4></div></div></div>
-<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">IC</span><span class="special">></span>
-<span class="keyword">struct</span> <span class="identifier">is_integral_constant</span> <span class="special">{</span> <span class="emphasis"><em>implementation-defined</em></span> <span class="special">};</span>
+<p>
+ The run-time version can be included via <boost/integer/sign_extend.hpp>.
+ </p>
+<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
+<span class="identifier">Type</span> <span class="identifier">sign_extend</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">data</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">bits</span><span class="special">);</span>
</pre>
-</div>
-<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
-<span class="bold"><strong>Results: </strong></span><div class="itemizedlist"><ul class="itemizedlist" type="circle">
-<li class="listitem">
- If <code class="computeroutput"><span class="identifier">IC</span></code> is a <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
- type, <code class="computeroutput"><span class="identifier">is_integral_constant</span><span class="special"><</span><span class="identifier">IC</span><span class="special">></span></code> will inherit from <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">true_</span></code>
-</li>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
- If <code class="computeroutput"><span class="identifier">IC</span></code> is not a <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
- type, <code class="computeroutput"><span class="identifier">is_integral_constant</span><span class="special"><</span><span class="identifier">IC</span><span class="special">></span></code> will inherit from <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">false_</span></code>
-</li>
+<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">bits</span></code>
+ must be smaller than the size, in bits, of <code class="computeroutput"><span class="identifier">T</span></code>
+ and <code class="computeroutput"><span class="identifier">T</span></code> must be an integral
+ type.
+ </li>
+<li class="listitem"><span class="bold"><strong>Parameters:</strong></span></li>
</ul></div>
-</li></ul></div>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<thead><tr>
+<th>
+ <p>
+ Parameter
+ </p>
+ </th>
+<th>
+ <p>
+ Description
+ </p>
+ </th>
+</tr></thead>
+<tbody>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">data</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ The data to be extended.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">bits</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ The amount of bits in wich data is represented.
+ </p>
+ </td>
+</tr>
+</tbody>
+</table></div>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
+<span class="bold"><strong>Returns: </strong></span><code class="computeroutput"><span class="identifier">data</span></code>
+ sign-extended to <code class="computeroutput"><span class="keyword">sizeof</span><span class="special">(</span><span class="identifier">T</span><span class="special">)</span></code> bytes.
+ </li></ul></div>
+</div>
+<div class="section" title="Template Class static_sign_extend<>">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_integer.bits_and_ints.sign_extend.template_class__static_sign_extend___"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.sign_extend.template_class__static_sign_extend___" title="Template Class static_sign_extend<>">Template
+ Class <code class="computeroutput"><span class="identifier">static_sign_extend</span><span class="special"><></span></code></a>
+</h4></div></div></div>
+<p>
+ The compile-time version can be included via <boost/integer/static_sign_extend.hpp>.
+ The result will be in <code class="computeroutput"><span class="identifier">value</span></code>
+ member.
+ </p>
+<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">Value</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">Bits</span><span class="special">></span>
+<span class="keyword">struct</span> <span class="identifier">static_sign_extend</span>
+<span class="special">{</span>
+ <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span>
+<span class="special">};</span>
+</pre>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">Bits</span></code>
+ must be smaller than the size, in bits, of <code class="computeroutput"><span class="identifier">T</span></code>
+ and <code class="computeroutput"><span class="identifier">T</span></code> must be an integral
+ type.
+ </li>
+<li class="listitem"><span class="bold"><strong>Template Parameters:</strong></span></li>
+</ul></div>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<thead><tr>
+<th>
+ <p>
+ Parameter
+ </p>
+ </th>
+<th>
+ <p>
+ Description
+ </p>
+ </th>
+</tr></thead>
+<tbody>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">T</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ The data type.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">Value</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ The data to be extended.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">Bits</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ The amount of bits in wich data is represented.
+ </p>
+ </td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<div class="section" title="Template Class mpl::sign_extend<>">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_integer.bits_and_ints.sign_extend.template_class__mpl__sign_extend___"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.sign_extend.template_class__mpl__sign_extend___" title="Template Class mpl::sign_extend<>">Template
+ Class <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">sign_extend</span><span class="special"><></span></code></a>
+</h4></div></div></div>
+<p>
+ The MPL version can be included via <boost/integer/static_sign_extend.hpp>.
+ The result will be in <code class="computeroutput"><span class="identifier">value</span></code>
+ member.
+ </p>
+<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">typename</span> <span class="identifier">IC</span><span class="special">,</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">Bits</span><span class="special">></span>
+<span class="keyword">struct</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">sign_extend</span>
+<span class="special">{</span>
+ <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span>
+<span class="special">};</span>
+</pre>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">IC</span></code>
+ must a <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
+ type. <code class="computeroutput"><span class="identifier">Bits</span></code> must be smaller
+ than the size in bits of <code class="computeroutput"><span class="identifier">IC</span><span class="special">::</span><span class="identifier">value_type</span></code>.
+ </li>
+<li class="listitem"><span class="bold"><strong>Template Parameters:</strong></span></li>
+</ul></div>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<thead><tr>
+<th>
+ <p>
+ Parameter
+ </p>
+ </th>
+<th>
+ <p>
+ Description
+ </p>
+ </th>
+</tr></thead>
+<tbody>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">IC</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ A <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
+ type.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">Bits</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ The amount of bits in wich data is represented.
+ </p>
+ </td>
+</tr>
+</tbody>
+</table></div>
+</div>
+<div class="section" title="Examples">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_integer.bits_and_ints.sign_extend.examples"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.sign_extend.examples" title="Examples">Examples</a>
+</h4></div></div></div>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc">
+<li class="listitem">
+<span class="bold"><strong>Run-time version</strong></span><pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">integer</span><span class="special">/</span><span class="identifier">sign_extend</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
+<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
+
+<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="comment">// data is represented in 24-bits
+</span> <span class="keyword">int</span> <span class="identifier">data</span> <span class="special">=</span> <span class="number">0xFFFFFF</span><span class="special">;</span> <span class="comment">// -1 in 24-bits
+</span>
+ <span class="keyword">int</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">sign_extend</span><span class="special">(</span><span class="identifier">data</span><span class="special">,</span> <span class="number">24</span><span class="special">);</span>
+
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">result</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// -1
+</span><span class="special">}</span>
+</pre>
+</li>
+<li class="listitem">
+<span class="bold"><strong>Compile-time version</strong></span><pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">integer</span><span class="special">/</span><span class="identifier">static_sign_extend</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
+<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
+
+<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="comment">// 0xFFFFF is -1 in 20-bits
+</span> <span class="keyword">int</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">static_sign_extend</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="number">0xFFFFF</span><span class="special">,</span> <span class="number">20</span><span class="special">>::</span><span class="identifier">value</span><span class="special">;</span>
+
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">result</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// -1
+</span><span class="special">}</span>
+</pre>
+</li>
+</ul></div>
+</div>
+</div>
+<div class="section" title="Sign section">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.bits_and_ints.sign"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.sign" title="Sign section"> Sign section</a>
+</h3></div></div></div>
+<div class="toc"><dl>
+<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.sign.non_member_function__sign_">Non-Member
+ Function <code class="computeroutput"><span class="identifier">sign</span></code></a></span></dt>
+<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.sign.static_functions__mpl__sign__and__static_sign_">Static
+ Functions <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">sign</span></code> and <code class="computeroutput"><span class="identifier">static_sign</span></code></a></span></dt>
+<dt><span class="section">Examples</span></dt>
+</dl></div>
+<p>
+ The <code class="computeroutput"><span class="identifier">sign</span></code> function checks
+ the sign of integrals.
+ </p>
+<div class="section" title="Non-Member Function sign">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_integer.bits_and_ints.sign.non_member_function__sign_"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.sign.non_member_function__sign_" title="Non-Member Function sign">Non-Member
+ Function <code class="computeroutput"><span class="identifier">sign</span></code></a>
+</h4></div></div></div>
+<p>
+ The run-time version can be included via <boost/integer/sign.hpp>.
+ </p>
+<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
+<span class="keyword">int</span> <span class="identifier">sign</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">data</span><span class="special">);</span>
+</pre>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><span class="bold"><strong>Parameters:</strong></span></li></ul></div>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<thead><tr>
+<th>
+ <p>
+ Parameter
+ </p>
+ </th>
+<th>
+ <p>
+ Description
+ </p>
+ </th>
+</tr></thead>
+<tbody><tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">data</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ The data to be checked. The type of data <span class="bold"><strong>must</strong></span>
+ be an integral otherwise, sign(data) will result in an error.
+ </p>
+ </td>
+</tr></tbody>
+</table></div>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><span class="bold"><strong>Returns:</strong></span></li></ul></div>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<thead><tr>
+<th>
+ <p>
+ Value
+ </p>
+ </th>
+<th>
+ <p>
+ Description
+ </p>
+ </th>
+</tr></thead>
+<tbody>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="special">-</span><span class="number">1</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">data</span></code> is negative.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="number">0</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">data</span></code> is equal to
+ zero.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="number">1</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">data</span></code> is positive.
+ </p>
+ </td>
+</tr>
+</tbody>
+</table></div>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
+<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">T</span></code>
+ must be an integral type.
+ </li></ul></div>
+</div>
+<div class="section" title="Static Functions mpl::sign and static_sign">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_integer.bits_and_ints.sign.static_functions__mpl__sign__and__static_sign_"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.sign.static_functions__mpl__sign__and__static_sign_" title="Static Functions mpl::sign and static_sign">Static
+ Functions <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">sign</span></code> and <code class="computeroutput"><span class="identifier">static_sign</span></code></a>
+</h4></div></div></div>
+<p>
+ The compile-time versions can be included via <boost/integer/static_sign.hpp>.
+ </p>
+<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">IC</span><span class="special">></span>
+<span class="keyword">struct</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">sign</span> <span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span> <span class="special">};</span>
+
+<span class="keyword">template</span> <span class="special"><</span><span class="keyword">template</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">Value</span><span class="special">></span>
+<span class="keyword">struct</span> <span class="identifier">static_same_sign</span> <span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">int</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span> <span class="special">};</span>
+</pre>
+<div class="informaltable"><table class="table">
+<colgroup>
+<col>
+<col>
+</colgroup>
+<thead><tr>
+<th>
+ <p>
+ Parameter
+ </p>
+ </th>
+<th>
+ <p>
+ Description
+ </p>
+ </th>
+</tr></thead>
+<tbody>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">IC</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ A <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
+ type.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">T</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ The value type. Must be an integral type.
+ </p>
+ </td>
+</tr>
+<tr>
+<td>
+ <p>
+ <code class="computeroutput"><span class="identifier">Value</span></code>
+ </p>
+ </td>
+<td>
+ <p>
+ The value to be checked.
+ </p>
+ </td>
+</tr>
+</tbody>
+</table></div>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
+<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">T</span></code>
+ to be an integral type and <code class="computeroutput"><span class="identifier">IC</span></code>
+ to be an <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
+ type.
+ </li></ul></div>
+</div>
+<div class="section" title="Examples">
+<div class="titlepage"><div><div><h4 class="title">
+<a name="boost_integer.bits_and_ints.sign.examples"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.sign.examples" title="Examples">Examples</a>
+</h4></div></div></div>
+<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><span class="bold"><strong>Run-time version:</strong></span></li></ul></div>
+<p>
+
+</p>
+<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">integer</span><span class="special">/</span><span class="identifier">sign</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span>
+<span class="preprocessor">#include</span> <span class="special"><</span><span class="identifier">iostream</span><span class="special">></span>
+
+<span class="keyword">int</span> <span class="identifier">main</span><span class="special">()</span>
+<span class="special">{</span>
+ <span class="keyword">int</span> <span class="identifier">first</span> <span class="special">=</span> <span class="special">-</span><span class="number">100</span><span class="special">,</span> <span class="identifier">second</span> <span class="special">=</span> <span class="number">340</span><span class="special">,</span> <span class="identifier">third</span> <span class="special">=</span> <span class="number">0</span><span class="special">;</span>
+
+ <span class="keyword">int</span> <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">sign</span><span class="special">(</span><span class="identifier">first</span><span class="special">);</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">result</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// -1
+</span>
+ <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">sign</span><span class="special">(</span><span class="identifier">second</span><span class="special">);</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">result</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// 1
+</span>
+ <span class="identifier">result</span> <span class="special">=</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">sign</span><span class="special">(</span><span class="identifier">third</span><span class="special">);</span>
+ <span class="identifier">std</span><span class="special">::</span><span class="identifier">cout</span> <span class="special"><<</span> <span class="identifier">result</span> <span class="special"><<</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">endl</span><span class="special">;</span> <span class="comment">// 0
+</span><span class="special">}</span>
+</pre>
+<p>
+ </p>
</div>
-<div class="section" title="Binary Utilities">
+</div>
+<div class="section" title="Swap without a temporary (in-place)">
<div class="titlepage"><div><div><h3 class="title">
-<a name="boost_integer.bits_and_ints.bit_utils"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.bit_utils" title="Binary Utilities"> Binary Utilities</a>
+<a name="boost_integer.bits_and_ints.swap_without_a_temporary__in_place__"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.swap_without_a_temporary__in_place__" title="Swap without a temporary (in-place)">Swap
+ without a temporary (in-place) </a>
</h3></div></div></div>
-<div class="toc"><dl>
-<dt><span class="section">Synopsis</span></dt>
-<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.bit_utils.template_class__static_set_bit____and__mpl__set_bit_">Template
- Class <code class="computeroutput"><span class="identifier">static_set_bit</span><span class="special"><></span></code>
- and <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">set_bit</span></code></a></span></dt>
-<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.bit_utils.template_class__mpl__clear_bit____and__static_clear_bit___">Template
- Class <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">clear_bit</span><span class="special"><></span></code>
- and <code class="computeroutput"><span class="identifier">static_clear_bit</span><span class="special"><></span></code></a></span></dt>
-<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.bit_utils.template_class__mpl__test_bit__and__static_test_bit___">Template
- Class <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">test_bit</span></code> and <code class="computeroutput"><span class="identifier">static_test_bit</span><span class="special"><></span></code></a></span></dt>
-<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.bit_utils.template_class__mpl__flip_bit____and__static_flip_bit___">Template
- Class <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">flip_bit</span><span class="special"><></span></code>
- and <code class="computeroutput"><span class="identifier">static_flip_bit</span><span class="special"><></span></code></a></span></dt>
-<dt><span class="section"><a href="bits_and_ints.html#boost_integer.bits_and_ints.bit_utils.runtime_version">Runtime
- version</a></span></dt>
-</dl></div>
+<div class="toc"><dl><dt><span class="section">Synopsis</span></dt></dl></div>
<p>
- The header <boost/integer/bit_utils.hpp>
- cotains some metafunctions to handle binary data. All the metafunctions have
- an member varible named <code class="computeroutput"><span class="identifier">value</span></code>
- where will be the result.
+ The header file <boost/integer/swap.hpp>
+ defines <code class="computeroutput"><span class="identifier">swap</span></code> function wich
+ swaps 2 integral values without using a temporary variable.
</p>
<div class="section" title="Synopsis">
<div class="titlepage"><div><div><h4 class="title">
-<a name="boost_integer.bits_and_ints.bit_utils.synopsis"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.bit_utils.synopsis" title="Synopsis">Synopsis</a>
+<a name="boost_integer.bits_and_ints.swap_without_a_temporary__in_place__.synopsis"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.swap_without_a_temporary__in_place__.synopsis" title="Synopsis">Synopsis</a>
</h4></div></div></div>
-<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span>
-<span class="special">{</span>
-
-<span class="comment">// Compile-time version
-</span>
-<span class="comment">// Sets the bit `pos' in data
-</span><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">data</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">char</span> <span class="identifier">pos</span><span class="special">></span>
-<span class="keyword">struct</span> <span class="identifier">static_set_bit</span> <span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span> <span class="special">};</span>
-
-<span class="comment">// Clear the bit `pos' in data
-</span><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">data</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">char</span> <span class="identifier">pos</span><span class="special">></span>
-<span class="keyword">struct</span> <span class="identifier">static_clear_bit</span> <span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span> <span class="special">};</span>
-
-<span class="comment">// If the bit `pos' is 1 then it will be 0 if not the bit will be 1
-</span><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">data</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">char</span> <span class="identifier">pos</span><span class="special">></span>
-<span class="keyword">struct</span> <span class="identifier">static_flip_bit</span><span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span> <span class="special">};</span>
-
-<span class="comment">// Test if the bit in `pos' positon is set or not
-</span><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">data</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">char</span> <span class="identifier">pos</span><span class="special">></span>
-<span class="keyword">struct</span> <span class="identifier">static_test_bit</span> <span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">bool</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span> <span class="special">};</span>
-
-<span class="keyword">namespace</span> <span class="identifier">mpl</span> <span class="special">{</span>
-
-<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">IC</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">char</span> <span class="identifier">pos</span><span class="special">></span>
-<span class="keyword">struct</span> <span class="identifier">set_bit</span> <span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">typename</span> <span class="identifier">IC</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span> <span class="special">};</span>
-
-<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">IC</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">char</span> <span class="identifier">pos</span><span class="special">></span>
-<span class="keyword">struct</span> <span class="identifier">clear_bit</span> <span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">typename</span> <span class="identifier">IC</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span> <span class="special">};</span>
-
-<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">IC</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">char</span> <span class="identifier">pos</span><span class="special">></span>
-<span class="keyword">struct</span> <span class="identifier">flip_bit</span><span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">typename</span> <span class="identifier">IC</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span> <span class="special">};</span>
-
-<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">IC</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">char</span> <span class="identifier">pos</span><span class="special">></span>
-<span class="keyword">struct</span> <span class="identifier">test_bit</span> <span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">bool</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span> <span class="special">};</span>
-
-<span class="special">}</span> <span class="comment">// mpl
-</span>
-<span class="comment">// Runtime version
-</span><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
-<span class="keyword">inline</span> <span class="identifier">T</span> <span class="identifier">set_bit</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">data</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">char</span> <span class="identifier">pos</span><span class="special">);</span>
-
-<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
-<span class="keyword">inline</span> <span class="identifier">T</span> <span class="identifier">clear_bit</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">data</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">char</span> <span class="identifier">pos</span><span class="special">);</span>
-
-<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
-<span class="keyword">inline</span> <span class="identifier">T</span> <span class="identifier">flip_bit</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">data</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">char</span> <span class="identifier">pos</span><span class="special">);</span>
-
-<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
-<span class="keyword">inline</span> <span class="keyword">bool</span> <span class="identifier">test_bit</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">data</span><span class="special">,</span> <span class="keyword">unsigned</span> <span class="keyword">char</span> <span class="identifier">pos</span><span class="special">);</span>
-
-<span class="special">}</span> <span class="comment">// boost
-</span></pre>
+<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
+<span class="keyword">inline</span> <span class="keyword">void</span> <span class="identifier">swap</span><span class="special">(</span><span class="identifier">T</span><span class="special">&</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T</span><span class="special">&</span> <span class="identifier">y</span><span class="special">);</span>
+</pre>
</div>
-<div class="section" title="Template Class static_set_bit<> and mpl::set_bit">
-<div class="titlepage"><div><div><h4 class="title">
-<a name="boost_integer.bits_and_ints.bit_utils.template_class__static_set_bit____and__mpl__set_bit_"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.bit_utils.template_class__static_set_bit____and__mpl__set_bit_" title="Template Class static_set_bit<> and mpl::set_bit">Template
- Class <code class="computeroutput"><span class="identifier">static_set_bit</span><span class="special"><></span></code>
- and <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">set_bit</span></code></a>
-</h4></div></div></div>
-<p>
- Sets the bit <code class="computeroutput"><span class="identifier">pos</span></code> active
- in <code class="computeroutput"><span class="identifier">value</span></code>.
- </p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
-<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">pos</span></code>
- must be smaller than the size (in bits) of <code class="computeroutput"><span class="identifier">Type</span></code>
- for <code class="computeroutput"><span class="identifier">static_set_bit</span><span class="special"><></span></code>
- and smaller than IC::value_type for <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">static_set_bit</span><span class="special"><></span></code>.
- </li>
-<li class="listitem">
-<span class="bold"><strong>Remarks: </strong></span><div class="itemizedlist"><ul class="itemizedlist" type="circle">
-<li class="listitem">
-<code class="computeroutput"><span class="identifier">T</span></code> must be an integral
- type.
- </li>
+<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">T</span></code>
+ must be an integral type.
+ </li>
<li class="listitem">
-<code class="computeroutput"><span class="identifier">IC</span></code> must be a <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
- type.
- </li>
-</ul></div>
-</li>
-<li class="listitem"><span class="bold"><strong>Example:</strong></span></li>
+<span class="bold"><strong>Returns: </strong></span> Nothing. <code class="computeroutput"><span class="identifier">x</span></code>
+ will have the value of <code class="computeroutput"><span class="identifier">y</span></code>
+ and <code class="computeroutput"><span class="identifier">y</span></code> will have the <code class="computeroutput"><span class="identifier">x</span></code> value.
+ </li>
</ul></div>
-<pre class="programlisting"><span class="comment">// `new_value' becomes 101
-</span><span class="keyword">int</span> <span class="identifier">new_value</span> <span class="special">=</span> <span class="identifier">set_bit</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="number">100</span><span class="special">,</span> <span class="number">0</span><span class="special">>::</span><span class="identifier">value</span><span class="special">;</span>
-</pre>
</div>
-<div class="section" title="Template Class mpl::clear_bit<> and static_clear_bit<>">
-<div class="titlepage"><div><div><h4 class="title">
-<a name="boost_integer.bits_and_ints.bit_utils.template_class__mpl__clear_bit____and__static_clear_bit___"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.bit_utils.template_class__mpl__clear_bit____and__static_clear_bit___" title="Template Class mpl::clear_bit<> and static_clear_bit<>">Template
- Class <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">clear_bit</span><span class="special"><></span></code>
- and <code class="computeroutput"><span class="identifier">static_clear_bit</span><span class="special"><></span></code></a>
-</h4></div></div></div>
+<div class="section" title="Transfer of Sign (isign) functions">
+<div class="titlepage"><div><div><h3 class="title">
+<a name="boost_integer.bits_and_ints.transfer_of_sign__isign__functions_"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.transfer_of_sign__isign__functions_" title="Transfer of Sign (isign) functions">Transfer
+ of Sign (isign) functions </a>
+</h3></div></div></div>
+<div class="toc"><dl><dt><span class="section">Synopsis</span></dt></dl></div>
<p>
- Sets the bit <code class="computeroutput"><span class="identifier">pos</span></code> inactive
- in <code class="computeroutput"><span class="identifier">data</span></code>.
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" type="disc">
-<li class="listitem">
-<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">pos</span></code>
- must be smaller than the size (in bits) of <code class="computeroutput"><span class="identifier">Type</span></code>
- for <code class="computeroutput"><span class="identifier">static_clear_bit</span><span class="special"><></span></code> and smaller than IC::value_type
- for <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">static_clear_bit</span><span class="special"><></span></code>.
- </li>
-<li class="listitem">
-<span class="bold"><strong>Remarks: </strong></span><div class="itemizedlist"><ul class="itemizedlist" type="circle">
-<li class="listitem">
-<code class="computeroutput"><span class="identifier">T</span></code> must be an integral
- type.
- </li>
-<li class="listitem">
-<code class="computeroutput"><span class="identifier">IC</span></code> must be a <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
- type.
- </li>
-</ul></div>
-</li>
-<li class="listitem"><span class="bold"><strong>Example:</strong></span></li>
-</ul></div>
-<pre class="programlisting"><span class="comment">// `new_value' becomes 1
-</span><span class="keyword">int</span> <span class="identifier">new_value</span> <span class="special">=</span> <span class="identifier">set_bit</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="number">3</span><span class="special">,</span> <span class="number">2</span><span class="special">>::</span><span class="identifier">value</span><span class="special">;</span>
+ isign or transfer of sign function is defined by:
+</p>
+<pre class="programlisting"><span class="identifier">isign</span><span class="special">(</span><span class="identifier">x</span><span class="special">,</span> <span class="identifier">y</span><span class="special">)</span> <span class="special">=</span>
+ <span class="identifier">abs</span><span class="special">(</span><span class="identifier">x</span><span class="special">),</span> <span class="keyword">if</span> <span class="identifier">y</span> <span class="identifier">is</span> <span class="identifier">greater</span> <span class="identifier">than</span> <span class="keyword">or</span> <span class="identifier">equal</span> <span class="number">0</span><span class="special">,</span>
+<span class="special">-</span><span class="identifier">abs</span><span class="special">(</span><span class="identifier">x</span><span class="special">),</span> <span class="keyword">if</span> <span class="identifier">y</span> <span class="identifier">is</span> <span class="identifier">less</span> <span class="identifier">than</span> <span class="number">0</span>
</pre>
-</div>
-<div class="section" title="Template Class mpl::test_bit and static_test_bit<>">
+<p>
+ </p>
+<p>
+ The runtime functions are defined on <boost/integer/isign.hpp>
+ and the static metafunctions are defined on <boost/integer/static_isign.hpp>
+ </p>
+<div class="section" title="Synopsis">
<div class="titlepage"><div><div><h4 class="title">
-<a name="boost_integer.bits_and_ints.bit_utils.template_class__mpl__test_bit__and__static_test_bit___"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.bit_utils.template_class__mpl__test_bit__and__static_test_bit___" title="Template Class mpl::test_bit and static_test_bit<>">Template
- Class <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">test_bit</span></code> and <code class="computeroutput"><span class="identifier">static_test_bit</span><span class="special"><></span></code></a>
+<a name="boost_integer.bits_and_ints.transfer_of_sign__isign__functions_.synopsis"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.transfer_of_sign__isign__functions_.synopsis" title="Synopsis">Synopsis</a>
</h4></div></div></div>
-<p>
- Test if the bit <code class="computeroutput"><span class="identifier">pos</span></code> in
- <code class="computeroutput"><span class="identifier">data</span></code> is active or not.
- </p>
-<div class="itemizedlist"><ul class="itemizedlist" type="disc">
-<li class="listitem">
-<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">pos</span></code>
- must be smaller than the size (in bits) of <code class="computeroutput"><span class="identifier">Type</span></code>
- for <code class="computeroutput"><span class="identifier">static_test_bit</span><span class="special"><></span></code>
- and smaller than IC::value_type for <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">static_test_bit</span><span class="special"><></span></code>.
- </li>
-<li class="listitem">
-<span class="bold"><strong>Remarks: </strong></span><div class="itemizedlist"><ul class="itemizedlist" type="circle">
-<li class="listitem">
-<code class="computeroutput"><span class="identifier">T</span></code> must be an integral
- type.
- </li>
-<li class="listitem">
-<code class="computeroutput"><span class="identifier">IC</span></code> must be a <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
- type.
- </li>
-</ul></div>
-</li>
-<li class="listitem"><span class="bold"><strong>Example:</strong></span></li>
-</ul></div>
-<pre class="programlisting"><span class="comment">// `is_set' becomes true
-</span><span class="keyword">bool</span> <span class="identifier">is_set</span> <span class="special">=</span> <span class="identifier">test_bit</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="number">3982</span><span class="special">,</span> <span class="number">11</span><span class="special">>::</span><span class="identifier">value</span><span class="special">;</span>
+<pre class="programlisting"><span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">></span>
+<span class="identifier">T</span> <span class="identifier">isign</span><span class="special">(</span><span class="identifier">T</span> <span class="identifier">x</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">y</span><span class="special">);</span>
+
+<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">Value1</span><span class="special">,</span> <span class="identifier">T</span> <span class="identifier">Value2</span><span class="special">></span>
+<span class="keyword">struct</span> <span class="identifier">static_isign</span> <span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span> <span class="special">};</span>
+
+<span class="keyword">template</span> <span class="special"><</span><span class="keyword">typename</span> <span class="identifier">IC1</span><span class="special">,</span> <span class="keyword">typename</span> <span class="identifier">IC2</span><span class="special">></span>
+<span class="keyword">struct</span> <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">isign</span> <span class="special">{</span> <span class="keyword">static</span> <span class="keyword">const</span> <span class="keyword">typename</span> <span class="identifier">IC1</span><span class="special">::</span><span class="identifier">value_type</span> <span class="identifier">value</span> <span class="special">=</span> <span class="emphasis"><em>implementation-defined</em></span><span class="special">;</span> <span class="special">};</span>
</pre>
</div>
-<div class="section" title="Template Class mpl::flip_bit<> and static_flip_bit<>">
-<div class="titlepage"><div><div><h4 class="title">
-<a name="boost_integer.bits_and_ints.bit_utils.template_class__mpl__flip_bit____and__static_flip_bit___"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.bit_utils.template_class__mpl__flip_bit____and__static_flip_bit___" title="Template Class mpl::flip_bit<> and static_flip_bit<>">Template
- Class <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">flip_bit</span><span class="special"><></span></code>
- and <code class="computeroutput"><span class="identifier">static_flip_bit</span><span class="special"><></span></code></a>
-</h4></div></div></div>
-<p>
- Invert the value of the bit <code class="computeroutput"><span class="identifier">pos</span></code>
- in <code class="computeroutput"><span class="identifier">data</span></code>
- </p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
-<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">pos</span></code>
- must be smaller than the size (in bits) of <code class="computeroutput"><span class="identifier">Type</span></code>
- for <code class="computeroutput"><span class="identifier">static_flip_bit</span><span class="special"><></span></code>
- and smaller than IC::value_type for <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">static_flip_bit</span><span class="special"><></span></code>.
- </li>
+<span class="bold"><strong>Requires: </strong></span><code class="computeroutput"><span class="identifier">T</span></code>
+ must be an integral type. Both <code class="computeroutput"><span class="identifier">IC1</span></code>
+ and <code class="computeroutput"><span class="identifier">IC2</span></code> must be <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
+ types.
+ </li>
<li class="listitem">
-<span class="bold"><strong>Remarks: </strong></span><div class="itemizedlist"><ul class="itemizedlist" type="circle">
+<span class="bold"><strong>Returns: </strong></span><div class="itemizedlist"><ul class="itemizedlist" type="circle">
<li class="listitem">
-<code class="computeroutput"><span class="identifier">T</span></code> must be an integral
- type.
- </li>
+ Runtime version: returns <code class="computeroutput"><span class="identifier">abs</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code> if <code class="computeroutput"><span class="identifier">y</span></code>
+ is greater than or equal 0 and <code class="computeroutput"><span class="special">-</span><span class="identifier">abs</span><span class="special">(</span><span class="identifier">x</span><span class="special">)</span></code>
+ if <code class="computeroutput"><span class="identifier">y</span></code> is negative.
+ </li>
<li class="listitem">
-<code class="computeroutput"><span class="identifier">IC</span></code> must be a <code class="computeroutput"><span class="identifier">mpl</span><span class="special">::</span><span class="identifier">integral_c</span><span class="special"><></span></code>
- type.
- </li>
+ MPL version: the member <code class="computeroutput"><span class="identifier">value</span></code>
+ will be <code class="computeroutput"><span class="identifier">abs</span><span class="special">(</span><span class="identifier">IC1</span><span class="special">::</span><span class="identifier">value</span><span class="special">)</span></code>
+ if <code class="computeroutput"><span class="identifier">IC2</span></code> holds an value
+ greater than or equal 0, or <code class="computeroutput"><span class="special">-</span><span class="identifier">abs</span><span class="special">(</span><span class="identifier">IC1</span><span class="special">::</span><span class="identifier">value</span><span class="special">)</span></code>
+ if <code class="computeroutput"><span class="identifier">IC2</span></code> holds a negative
+ value.
+ </li>
+<li class="listitem">
+<code class="computeroutput"><span class="identifier">static_isign</span><span class="special"><</span><span class="identifier">T</span><span class="special">,</span> <span class="identifier">Value1</span><span class="special">,</span>
+ <span class="identifier">Value2</span><span class="special">>::</span><span class="identifier">value</span></code> will be <code class="computeroutput"><span class="identifier">abs</span><span class="special">(</span><span class="identifier">Value1</span><span class="special">)</span></code> if Value2 is greater than or equal
+ 0, or <code class="computeroutput"><span class="special">-</span><span class="identifier">abs</span><span class="special">(</span><span class="identifier">Value1</span><span class="special">)</span></code> if Value2 is negative.
+ </li>
</ul></div>
</li>
-<li class="listitem"><span class="bold"><strong>Example:</strong></span></li>
</ul></div>
-<pre class="programlisting"><span class="comment">// `new_value' becomes 14
-</span><span class="keyword">bool</span> <span class="identifier">new_value</span> <span class="special">=</span> <span class="identifier">flip_bit</span><span class="special"><</span><span class="keyword">int</span><span class="special">,</span> <span class="number">10</span><span class="special">,</span> <span class="number">2</span><span class="special">>::</span><span class="identifier">value</span><span class="special">;</span>
-</pre>
-</div>
-<div class="section" title="Runtime version">
-<div class="titlepage"><div><div><h4 class="title">
-<a name="boost_integer.bits_and_ints.bit_utils.runtime_version"></a><a class="link" href="bits_and_ints.html#boost_integer.bits_and_ints.bit_utils.runtime_version" title="Runtime version">Runtime
- version</a>
-</h4></div></div></div>
-<p>
- For all runtime functions, all remarks and requirement are equals to the
- <code class="computeroutput"><span class="identifier">static_</span></code>-prefixed version.
- </p>
-</div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
Modified: sandbox/SOC/2010/bits_and_ints/libs/integer/doc/html/boost_integer/history.html
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/libs/integer/doc/html/boost_integer/history.html (original)
+++ sandbox/SOC/2010/bits_and_ints/libs/integer/doc/html/boost_integer/history.html 2010-07-14 15:03:39 EDT (Wed, 14 Jul 2010)
@@ -26,7 +26,7 @@
<a name="boost_integer.history"></a><a class="link" href="history.html" title="History"> History</a>
</h2></div></div></div>
<a name="boost_integer.history.1_42_0"></a><h5>
-<a name="id36202101"></a>
+<a name="id36202315"></a>
<a class="link" href="history.html#boost_integer.history.1_42_0">1.42.0</a>
</h5>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
@@ -55,7 +55,7 @@
</li>
</ul></div>
<a name="boost_integer.history.1_32_0"></a><h5>
-<a name="id36202222"></a>
+<a name="id36202435"></a>
<a class="link" href="history.html#boost_integer.history.1_32_0">1.32.0</a>
</h5>
<div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
Modified: sandbox/SOC/2010/bits_and_ints/libs/integer/doc/html/index.html
==============================================================================
--- sandbox/SOC/2010/bits_and_ints/libs/integer/doc/html/index.html (original)
+++ sandbox/SOC/2010/bits_and_ints/libs/integer/doc/html/index.html 2010-07-14 15:03:39 EDT (Wed, 14 Jul 2010)
@@ -255,7 +255,7 @@
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
-<td align="left"><p><small>Last revised: July 13, 2010 at 17:26:20 GMT</small></p></td>
+<td align="left"><p><small>Last revised: July 14, 2010 at 19:01:54 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk