Commit a2ca77dc authored by Nils Kohl's avatar Nils Kohl 🌝
Browse files

Got rid of boost/integer.hpp.

This mainly includes an implementation for boost::uint_t::least.
parent 4974c689
Pipeline #14071 failed with stages
in 16 minutes and 48 seconds
......@@ -120,6 +120,34 @@ inline void static_assert_uint_t() {
!std::numeric_limits<UINT>::is_signed, "Unsigned integer type required/expected!" );
}
template< uint_t size > struct uintFromBitWidth;
template<> struct uintFromBitWidth< 8 > { typedef uint8_t type; };
template<> struct uintFromBitWidth< 16 > { typedef uint16_t type; };
template<> struct uintFromBitWidth< 32 > { typedef uint32_t type; };
template<> struct uintFromBitWidth< 64 > { typedef uint64_t type; };
constexpr uint_t leastUnsignedIntegerBitWidth( uint_t width )
{
if ( width <= 8 ) return 8;
if ( width <= 16 ) return 16;
if ( width <= 32 ) return 32;
if ( width <= 64 ) return 64;
return width;
}
/// \brief Provides the smallest unsigned integer type that has at least minSize bits.
///
/// Example:
///
/// leastUnsignedInteger< 5 >::type a; // a is an 8-bit unsigned integer
/// leastUnsignedInteger< 9 >::type b; // b is a 16-bit unsigned integer
///
template< uint_t minSize >
struct leastUnsignedInteger
{
typedef typename uintFromBitWidth< leastUnsignedIntegerBitWidth( minSize ) >::type type;
};
/// \cond internal
static const uint_t UINT_BITS = static_cast< uint_t >( std::numeric_limits< uint_t >::digits );
static const uint_t UINT_BYTES = static_cast< uint_t >( std::numeric_limits< uint_t >::digits ) >> 3;
......
......@@ -26,7 +26,6 @@
#include "core/debug/Debug.h"
#include <boost/type_traits/is_unsigned.hpp>
#include <boost/integer.hpp>
namespace walberla {
......
......@@ -29,7 +29,6 @@
#include "core/DataTypes.h"
#include "core/Optional.h"
#include <boost/integer.hpp>
#include <boost/uuid/uuid.hpp>
#include <array>
......@@ -276,7 +275,7 @@ template< typename T, // Element type of SendBuffer
GenericSendBuffer<T,G>& packBoolVectorWithoutSize(GenericSendBuffer<T,G> & buf, const std::vector<bool> & bools )
{
// Use an unsigned type at least as large as the SendBuffer base type as container for the bools
typedef typename boost::uint_t<std::numeric_limits<T>::digits>::least ContainerType;
typedef typename leastUnsignedInteger< std::numeric_limits<T>::digits >::type ContainerType;
static const size_t NUM_BITS = std::numeric_limits<ContainerType>::digits;
auto it = bools.begin();
......@@ -297,7 +296,7 @@ template< typename T > // Element type of RecvBuffer
GenericRecvBuffer<T>& unpackBoolVectorWithoutSize(GenericRecvBuffer<T> & buf, std::vector<bool> & bools, size_t size )
{
// Use an unsigned type at least as large as the RecvBuffer base type as container for the bools
typedef typename boost::uint_t<std::numeric_limits<T>::digits>::least ContainerType;
typedef typename leastUnsignedInteger<std::numeric_limits<T>::digits>::type ContainerType;
static const size_t NUM_BITS = std::numeric_limits<ContainerType>::digits;
bools.resize(size);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment