New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
integer_mask.hpp in vendors/XIOS/current/extern/boost/include/boost/integer – NEMO

source: vendors/XIOS/current/extern/boost/include/boost/integer/integer_mask.hpp @ 3428

Last change on this file since 3428 was 3428, checked in by rblod, 12 years ago

importing initial XIOS vendor drop

File size: 3.1 KB
Line 
1//  Boost integer/integer_mask.hpp header file  ------------------------------//
2
3//  (C) Copyright Daryle Walker 2001.
4//  Distributed under the Boost Software License, Version 1.0. (See
5//  accompanying file LICENSE_1_0.txt or copy at
6//  http://www.boost.org/LICENSE_1_0.txt)
7
8//  See http://www.boost.org for updates, documentation, and revision history.
9
10#ifndef BOOST_INTEGER_INTEGER_MASK_HPP
11#define BOOST_INTEGER_INTEGER_MASK_HPP
12
13#include <boost/integer_fwd.hpp>  // self include
14
15#include <boost/config.hpp>   // for BOOST_STATIC_CONSTANT
16#include <boost/integer.hpp>  // for boost::uint_t
17
18#include <climits>  // for UCHAR_MAX, etc.
19#include <cstddef>  // for std::size_t
20
21#include <boost/limits.hpp>  // for std::numeric_limits
22
23
24namespace boost
25{
26
27
28//  Specified single-bit mask class declaration  -----------------------------//
29//  (Lowest bit starts counting at 0.)
30
31template < std::size_t Bit >
32struct high_bit_mask_t
33{
34    typedef typename uint_t<(Bit + 1)>::least  least;
35    typedef typename uint_t<(Bit + 1)>::fast   fast;
36
37    BOOST_STATIC_CONSTANT( least, high_bit = (least( 1u ) << Bit) );
38    BOOST_STATIC_CONSTANT( fast, high_bit_fast = (fast( 1u ) << Bit) );
39
40    BOOST_STATIC_CONSTANT( std::size_t, bit_position = Bit );
41
42};  // boost::high_bit_mask_t
43
44
45//  Specified bit-block mask class declaration  ------------------------------//
46//  Makes masks for the lowest N bits
47//  (Specializations are needed when N fills up a type.)
48
49template < std::size_t Bits >
50struct low_bits_mask_t
51{
52    typedef typename uint_t<Bits>::least  least;
53    typedef typename uint_t<Bits>::fast   fast;
54
55    BOOST_STATIC_CONSTANT( least, sig_bits = (~( ~(least( 0u )) << Bits )) );
56    BOOST_STATIC_CONSTANT( fast, sig_bits_fast = fast(sig_bits) );
57
58    BOOST_STATIC_CONSTANT( std::size_t, bit_count = Bits );
59
60};  // boost::low_bits_mask_t
61
62
63#define BOOST_LOW_BITS_MASK_SPECIALIZE( Type )                                  \
64  template <  >  struct low_bits_mask_t< std::numeric_limits<Type>::digits >  { \
65      typedef std::numeric_limits<Type>           limits_type;                  \
66      typedef uint_t<limits_type::digits>::least  least;                        \
67      typedef uint_t<limits_type::digits>::fast   fast;                         \
68      BOOST_STATIC_CONSTANT( least, sig_bits = (~( least(0u) )) );              \
69      BOOST_STATIC_CONSTANT( fast, sig_bits_fast = fast(sig_bits) );            \
70      BOOST_STATIC_CONSTANT( std::size_t, bit_count = limits_type::digits );    \
71  }
72
73#ifdef BOOST_MSVC
74#pragma warning(push)
75#pragma warning(disable:4245)  // 'initializing' : conversion from 'int' to 'const boost::low_bits_mask_t<8>::least', signed/unsigned mismatch
76#endif
77
78BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned char );
79
80#if USHRT_MAX > UCHAR_MAX
81BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned short );
82#endif
83
84#if UINT_MAX > USHRT_MAX
85BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned int );
86#endif
87
88#if ULONG_MAX > UINT_MAX
89BOOST_LOW_BITS_MASK_SPECIALIZE( unsigned long );
90#endif
91
92#ifdef BOOST_MSVC
93#pragma warning(pop)
94#endif
95
96#undef BOOST_LOW_BITS_MASK_SPECIALIZE
97
98
99}  // namespace boost
100
101
102#endif  // BOOST_INTEGER_INTEGER_MASK_HPP
Note: See TracBrowser for help on using the repository browser.