Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:35:27

0001 //  boost/detail/bitmask.hpp  ------------------------------------------------//
0002 
0003 //  Copyright Beman Dawes 2006
0004 
0005 //  Distributed under the Boost Software License, Version 1.0
0006 //  http://www.boost.org/LICENSE_1_0.txt
0007 
0008 //  Usage:  enum foo { a=1, b=2, c=4 };
0009 //          BOOST_BITMASK( foo )
0010 //
0011 //          void f( foo arg );
0012 //          ...
0013 //          f( a | c );
0014 //
0015 //  See [bitmask.types] in the C++ standard for the formal specification
0016 
0017 #ifndef BOOST_BITMASK_HPP
0018 #define BOOST_BITMASK_HPP
0019 
0020 #include <boost/config.hpp>
0021 #include <boost/cstdint.hpp>
0022 
0023 #define BOOST_BITMASK(Bitmask)                                            \
0024                                                                           \
0025   inline BOOST_CONSTEXPR Bitmask operator| (Bitmask x , Bitmask y )       \
0026   { return static_cast<Bitmask>( static_cast<boost::int_least32_t>(x)     \
0027       | static_cast<boost::int_least32_t>(y)); }                          \
0028                                                                           \
0029   inline BOOST_CONSTEXPR Bitmask operator& (Bitmask x , Bitmask y )       \
0030   { return static_cast<Bitmask>( static_cast<boost::int_least32_t>(x)     \
0031       & static_cast<boost::int_least32_t>(y)); }                          \
0032                                                                           \
0033   inline BOOST_CONSTEXPR Bitmask operator^ (Bitmask x , Bitmask y )       \
0034   { return static_cast<Bitmask>( static_cast<boost::int_least32_t>(x)     \
0035       ^ static_cast<boost::int_least32_t>(y)); }                          \
0036                                                                           \
0037   inline BOOST_CONSTEXPR Bitmask operator~ (Bitmask x )                   \
0038   { return static_cast<Bitmask>(~static_cast<boost::int_least32_t>(x)); } \
0039                                                                           \
0040   inline Bitmask & operator&=(Bitmask& x , Bitmask y)                     \
0041   { x = x & y ; return x ; }                                              \
0042                                                                           \
0043   inline Bitmask & operator|=(Bitmask& x , Bitmask y)                     \
0044   { x = x | y ; return x ; }                                              \
0045                                                                           \
0046   inline Bitmask & operator^=(Bitmask& x , Bitmask y)                     \
0047   { x = x ^ y ; return x ; }                                              \
0048                                                                           \
0049   /* Boost extensions to [bitmask.types] */                               \
0050                                                                           \
0051   inline BOOST_CONSTEXPR bool operator!(Bitmask x)                        \
0052   { return !static_cast<int>(x); }                                        \
0053                                                                           \
0054   inline BOOST_CONSTEXPR bool bitmask_set(Bitmask x)                      \
0055   { return !!x; }
0056 
0057 #endif // BOOST_BITMASK_HPP
0058