Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r68836 - trunk/boost/detail
From: bdawes_at_[hidden]
Date: 2011-02-13 09:48:03


Author: bemandawes
Date: 2011-02-13 09:48:01 EST (Sun, 13 Feb 2011)
New Revision: 68836
URL: http://svn.boost.org/trac/boost/changeset/68836

Log:
Initial commit; bitmask.hpp is needed by upcoming filesystem changes
Added:
   trunk/boost/detail/bitmask.hpp (contents, props changed)

Added: trunk/boost/detail/bitmask.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/detail/bitmask.hpp 2011-02-13 09:48:01 EST (Sun, 13 Feb 2011)
@@ -0,0 +1,47 @@
+// boost/detail/bitmask.hpp ------------------------------------------------//
+
+// Copyright Beman Dawes 2006
+
+// Distributed under the Boost Software License, Version 1.0
+// http://www.boost.org/LICENSE_1_0.txt
+
+// Usage: enum foo { a=1, b=2, c=4 };
+// BOOST_BITMASK( foo );
+//
+// void f( foo arg );
+// ...
+// f( a | c );
+
+#ifndef BOOST_BITMASK_HPP
+#define BOOST_BITMASK_HPP
+
+#include <boost/cstdint.hpp>
+
+#define BOOST_BITMASK(Bitmask) \
+ \
+ inline Bitmask operator| (Bitmask x , Bitmask y ) \
+ { return static_cast<Bitmask>( static_cast<boost::int_least32_t>(x) \
+ | static_cast<boost::int_least32_t>(y)); } \
+ \
+ inline Bitmask operator& (Bitmask x , Bitmask y ) \
+ { return static_cast<Bitmask>( static_cast<boost::int_least32_t>(x) \
+ & static_cast<boost::int_least32_t>(y)); } \
+ \
+ inline Bitmask operator^ (Bitmask x , Bitmask y ) \
+ { return static_cast<Bitmask>( static_cast<boost::int_least32_t>(x) \
+ ^ static_cast<boost::int_least32_t>(y)); } \
+ \
+ inline Bitmask operator~ (Bitmask x ) \
+ { return static_cast<Bitmask>(~static_cast<boost::int_least32_t>(x)); } \
+ \
+ inline Bitmask & operator&=(Bitmask & x , Bitmask y) \
+ { x = x & y ; return x ; } \
+ \
+ inline Bitmask & operator|=(Bitmask & x , Bitmask y) \
+ { x = x | y ; return x ; } \
+ \
+ inline Bitmask & operator^=(Bitmask & x , Bitmask y) \
+ { x = x ^ y ; return x ; }
+
+#endif // BOOST_BITMASK_HPP
+


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