libtenum
include/tenum/detail/operator.hpp File Reference
#include <boost/integer.hpp>
#include <tenum/detail/type.hpp>
Include dependency graph for operator.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define TENUM_BIT_FIELD_OPERATORS_DECLARATION(type_m)
 Expands to operators declaration for bit flag type_m (&, |, ^, &=, |= and ^=).
#define TENUM_BIT_FIELD_OPERATORS_DEFINITION(type_m)
 Expands to operators definition for bit flag type_m (&, |, ^, &=, |= and ^=).
#define TENUM_CAST_ENUM(type_m, value_m)   static_cast< TENUM_TYPE(type_m) > (value_m)
 Expands to static_cast of value_m to enum type_m.
#define TENUM_CAST_UINT(value_m)   static_cast< ::boost::uint64_t > (value_m)
 Expands to static_cast of value_m to uint64_t.
#define TENUM_DYNAMIC_ENUM_OPERATORS_DECLARATION(type_m)
 Expands to operators declaration for dynamic enum type_m (+, -, += and -=).
#define TENUM_DYNAMIC_ENUM_OPERATORS_DEFINITION(type_m)
 Expands to operators definition for dynamic enum type_m (+, -, += and -=).
#define TENUM_ENUM_OPERATORS_DECLARATION(type_m)
#define TENUM_ENUM_OPERATORS_DEFINITION(type_m)
#define TENUM_OPERATOR_ADD(type_m, lhs_m, rhs_m)   TENUM_OPERATOR_BINARY(type_m,lhs_m,rhs_m,+)
 Expands to addition operator applied to lhs_m and rhs_m.
#define TENUM_OPERATOR_BINARY(type_m, lhs_m, rhs_m, operator_m)   TENUM_CAST_ENUM(type_m, TENUM_CAST_UINT(lhs_m) operator_m TENUM_CAST_UINT(rhs_m))
 Expands to binary operator operator_m applied to uint-casted lhs_m and rhs_m, then casted back to enum type_m.
#define TENUM_OPERATOR_BIT_AND(type_m, lhs_m, rhs_m)   TENUM_OPERATOR_BINARY(type_m,lhs_m,rhs_m,&)
 Expands to binary bitwise and operator applied to lhs_m and rhs_m.
#define TENUM_OPERATOR_BIT_OR(type_m, lhs_m, rhs_m)   TENUM_OPERATOR_BINARY(type_m,lhs_m,rhs_m,|)
 Expands to binary bitwise or operator applied to lhs_m and rhs_m.
#define TENUM_OPERATOR_BIT_XOR(type_m, lhs_m, rhs_m)   TENUM_OPERATOR_BINARY(type_m,lhs_m,rhs_m,^)
 Expands to binary bitwise xor operator applied to lhs_m and rhs_m.
#define TENUM_OPERATOR_SUB(type_m, lhs_m, rhs_m)   TENUM_OPERATOR_BINARY(type_m,lhs_m,rhs_m,-)
 Expands to subtraction operator applied to lhs_m and rhs_m.

Detailed Description

Distributed under the Boost Software License, Version 1.0. See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt

Definition in file operator.hpp.


Define Documentation

#define TENUM_BIT_FIELD_OPERATORS_DECLARATION (   type_m)
Value:
static inline TENUM_TYPE(type_m) operator&(TENUM_TYPE(type_m) const lhs_in, TENUM_TYPE(type_m) const rhs_in);   \
static inline TENUM_TYPE(type_m) operator|(TENUM_TYPE(type_m) const lhs_in, TENUM_TYPE(type_m) const rhs_in);   \
static inline TENUM_TYPE(type_m) operator^(TENUM_TYPE(type_m) const lhs_in, TENUM_TYPE(type_m) const rhs_in);   \
static inline TENUM_TYPE(type_m)& operator&=(TENUM_TYPE(type_m)& lhs_in, TENUM_TYPE(type_m) const rhs_in);      \
static inline TENUM_TYPE(type_m)& operator|=(TENUM_TYPE(type_m)& lhs_in, TENUM_TYPE(type_m) const rhs_in);      \
static inline TENUM_TYPE(type_m)& operator^=(TENUM_TYPE(type_m)& lhs_in, TENUM_TYPE(type_m) const rhs_in);

Expands to operators declaration for bit flag type_m (&, |, ^, &=, |= and ^=).

Expands to nothing when scoped enums are not available as old-style enums are automatically casted to integers.

Definition at line 222 of file operator.hpp.

#define TENUM_BIT_FIELD_OPERATORS_DEFINITION (   type_m)
Value:
static inline TENUM_TYPE(type_m) operator&(TENUM_TYPE(type_m) const lhs_in, TENUM_TYPE(type_m) const rhs_in) {  \
  return TENUM_OPERATOR_BIT_AND(type_m,lhs_in,rhs_in);                                                          \
}                                                                                                               \
static inline TENUM_TYPE(type_m) operator|(TENUM_TYPE(type_m) const lhs_in, TENUM_TYPE(type_m) const rhs_in) {  \
  return TENUM_OPERATOR_BIT_OR(type_m,lhs_in,rhs_in);                                                           \
}                                                                                                               \
static inline TENUM_TYPE(type_m) operator^(TENUM_TYPE(type_m) const lhs_in, TENUM_TYPE(type_m) const rhs_in) {  \
  return TENUM_OPERATOR_BIT_XOR(type_m,lhs_in,rhs_in);                                                          \
}                                                                                                               \
static inline TENUM_TYPE(type_m)& operator&=(TENUM_TYPE(type_m)& lhs_in, TENUM_TYPE(type_m) const rhs_in) {     \
  return lhs_in = lhs_in & rhs_in;                                                                              \
}                                                                                                               \
static inline TENUM_TYPE(type_m)& operator|=(TENUM_TYPE(type_m)& lhs_in, TENUM_TYPE(type_m) const rhs_in) {     \
  return lhs_in = lhs_in | rhs_in;                                                                              \
}                                                                                                               \
static inline TENUM_TYPE(type_m)& operator^=(TENUM_TYPE(type_m)& lhs_in, TENUM_TYPE(type_m) const rhs_in) {     \
  return lhs_in = lhs_in ^ rhs_in;                                                                              \
}

Expands to operators definition for bit flag type_m (&, |, ^, &=, |= and ^=).

Expands to nothing when scoped enums are not available as old-style enums are automatically casted to integers.

Definition at line 230 of file operator.hpp.

#define TENUM_CAST_ENUM (   type_m,
  value_m 
)    static_cast< TENUM_TYPE(type_m) > (value_m)

Expands to static_cast of value_m to enum type_m.

Definition at line 29 of file operator.hpp.

#define TENUM_CAST_UINT (   value_m)    static_cast< ::boost::uint64_t > (value_m)

Expands to static_cast of value_m to uint64_t.

Definition at line 22 of file operator.hpp.

#define TENUM_DYNAMIC_ENUM_OPERATORS_DECLARATION (   type_m)
Value:
template< typename IntegerType >                                                                        \
static inline TENUM_TYPE(type_m) operator+(TENUM_TYPE(type_m) const lhs_in, IntegerType const rhs_in);  \
template< typename IntegerType >                                                                        \
static inline TENUM_TYPE(type_m) operator-(TENUM_TYPE(type_m) const lhs_in, IntegerType const rhs_in);  \
template< typename IntegerType >                                                                        \
static inline TENUM_TYPE(type_m)& operator+=(TENUM_TYPE(type_m)& lhs_in, IntegerType const rhs_in);     \
template< typename IntegerType >                                                                        \
static inline TENUM_TYPE(type_m)& operator-=(TENUM_TYPE(type_m)& lhs_in, IntegerType const rhs_in);

Expands to operators declaration for dynamic enum type_m (+, -, += and -=).

Expands to nothing when scoped enums are not available as old-style enums are automatically casted to integers.

Definition at line 194 of file operator.hpp.

#define TENUM_DYNAMIC_ENUM_OPERATORS_DEFINITION (   type_m)
Value:
template< typename IntegerType >                                                                        \
static inline TENUM_TYPE(type_m) operator+(TENUM_TYPE(type_m) const lhs_in, IntegerType const rhs_in) { \
  return TENUM_OPERATOR_ADD(type_m,lhs_in,rhs_in);                                                      \
}                                                                                                       \
template< typename IntegerType >                                                                        \
static inline TENUM_TYPE(type_m) operator-(TENUM_TYPE(type_m) const lhs_in, IntegerType const rhs_in) { \
  return TENUM_OPERATOR_SUB(type_m,lhs_in,rhs_in);                                                      \
}                                                                                                       \
template< typename IntegerType >                                                                        \
static inline TENUM_TYPE(type_m)& operator+=(TENUM_TYPE(type_m)& lhs_in, IntegerType const rhs_in) {    \
  return lhs_in = lhs_in + rhs_in;                                                                      \
}                                                                                                       \
template< typename IntegerType >                                                                        \
static inline TENUM_TYPE(type_m)& operator-=(TENUM_TYPE(type_m)& lhs_in, IntegerType const rhs_in) {    \
  return lhs_in = lhs_in - rhs_in;                                                                      \
}

Expands to operators definition for dynamic enum type_m (+, -, += and -=).

Expands to nothing when scoped enums are not available as old-style enums are automatically casted to integers.

Definition at line 204 of file operator.hpp.

#define TENUM_ENUM_OPERATORS_DECLARATION (   type_m)
Value:
template< typename IntegerType >                                                                \
static inline bool operator!=(IntegerType const lhs_in, TENUM_TYPE(type_m) const& rhs_in);      \
template< typename IntegerType >                                                                \
static inline bool operator!=(TENUM_TYPE(type_m) const& lhs_in, IntegerType const rhs_in);      \
template< typename IntegerType >                                                                \
static inline bool operator==(IntegerType const lhs_in, TENUM_TYPE(type_m) const& rhs_in);      \
template< typename IntegerType >                                                                \
static inline bool operator==(TENUM_TYPE(type_m) const& lhs_in, IntegerType const rhs_in);      \
template< typename IntegerType >                                                                \
static inline IntegerType operator&(IntegerType const lhs_in, TENUM_TYPE(type_m) const rhs_in); \
template< typename IntegerType >                                                                \
static inline IntegerType operator&(TENUM_TYPE(type_m) const lhs_in, IntegerType const rhs_in); \
template< typename IntegerType >                                                                \
static inline IntegerType operator|(IntegerType const lhs_in, TENUM_TYPE(type_m) const rhs_in); \
template< typename IntegerType >                                                                \
static inline IntegerType operator|(TENUM_TYPE(type_m) const lhs_in, IntegerType const rhs_in); \
template< typename IntegerType >                                                                \
static inline IntegerType operator^(IntegerType const lhs_in, TENUM_TYPE(type_m) const rhs_in); \
template< typename IntegerType >                                                                \
static inline IntegerType operator^(TENUM_TYPE(type_m) const lhs_in, IntegerType const rhs_in); \
template< typename IntegerType >                                                                \
static inline IntegerType& operator&=(IntegerType& lhs_in, TENUM_TYPE(type_m) const rhs_in);    \
template< typename IntegerType >                                                                \
static inline IntegerType& operator|=(IntegerType& lhs_in, TENUM_TYPE(type_m) const rhs_in);    \
template< typename IntegerType >                                                                \
static inline IntegerType& operator^=(IntegerType& lhs_in, TENUM_TYPE(type_m) const rhs_in);    \

Definition at line 112 of file operator.hpp.

#define TENUM_ENUM_OPERATORS_DEFINITION (   type_m)

Definition at line 140 of file operator.hpp.

#define TENUM_OPERATOR_ADD (   type_m,
  lhs_m,
  rhs_m 
)    TENUM_OPERATOR_BINARY(type_m,lhs_m,rhs_m,+)

Expands to addition operator applied to lhs_m and rhs_m.

Definition at line 43 of file operator.hpp.

#define TENUM_OPERATOR_BINARY (   type_m,
  lhs_m,
  rhs_m,
  operator_m 
)    TENUM_CAST_ENUM(type_m, TENUM_CAST_UINT(lhs_m) operator_m TENUM_CAST_UINT(rhs_m))

Expands to binary operator operator_m applied to uint-casted lhs_m and rhs_m, then casted back to enum type_m.

Definition at line 36 of file operator.hpp.

#define TENUM_OPERATOR_BIT_AND (   type_m,
  lhs_m,
  rhs_m 
)    TENUM_OPERATOR_BINARY(type_m,lhs_m,rhs_m,&)

Expands to binary bitwise and operator applied to lhs_m and rhs_m.

Definition at line 64 of file operator.hpp.

#define TENUM_OPERATOR_BIT_OR (   type_m,
  lhs_m,
  rhs_m 
)    TENUM_OPERATOR_BINARY(type_m,lhs_m,rhs_m,|)

Expands to binary bitwise or operator applied to lhs_m and rhs_m.

Definition at line 57 of file operator.hpp.

#define TENUM_OPERATOR_BIT_XOR (   type_m,
  lhs_m,
  rhs_m 
)    TENUM_OPERATOR_BINARY(type_m,lhs_m,rhs_m,^)

Expands to binary bitwise xor operator applied to lhs_m and rhs_m.

Definition at line 71 of file operator.hpp.

#define TENUM_OPERATOR_SUB (   type_m,
  lhs_m,
  rhs_m 
)    TENUM_OPERATOR_BINARY(type_m,lhs_m,rhs_m,-)

Expands to subtraction operator applied to lhs_m and rhs_m.

Definition at line 50 of file operator.hpp.

 All Classes Namespaces Files Functions Defines