PolyBoRi
BooleConstant.h
Go to the documentation of this file.
00001 // -*- c++ -*-
00002 //*****************************************************************************
00014 //*****************************************************************************
00015 
00016 // include basic definitions
00017 #include "pbori_defs.h"
00018 
00019 #ifndef BooleConstant_h_
00020 #define BooleConstant_h_
00021 
00022 BEGIN_NAMESPACE_PBORI
00023 
00033 class BooleConstant {
00034 
00035 public:
00037   BooleConstant(): m_value(false) {}
00038 
00040   BooleConstant(bool value): m_value(value) {}
00041 
00043   BooleConstant(int value): m_value(value % 2) {}
00044 
00046   BooleConstant(unsigned int value): m_value(value % 2) {}
00047 
00049   operator bool() const { return m_value; }
00050 
00052   BooleConstant operator!() const { return !m_value; }
00053 
00054 protected:
00056   const bool m_value;
00057 };
00058 
00060 inline CTypes::ostream_type& 
00061 operator<<(CTypes::ostream_type& os, const BooleConstant& rhs) {
00062   return (os << (int) rhs);
00063 }
00064 
00065 
00066 END_NAMESPACE_PBORI
00067 
00068 #endif // BooleConstant_h_