libzypp  11.13.5
SafeBool.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_BASE_SAFEBOOL_H
13 #define ZYPP_BASE_SAFEBOOL_H
14 
16 namespace zypp
17 {
18 
19  namespace base
20  {
21 
22  namespace safebool_detail
23  {
25  {
26  protected:
27  typedef void (SafeBoolBase::*bool_type)() const;
28  void theTrueBoolType() const {}
29 
31  SafeBoolBase( const SafeBoolBase & ) {}
33  SafeBoolBase & operator=( const SafeBoolBase & ) { return *this; }
34  };
35  }
36 
38  //
39  // CLASS NAME : SafeBool
40  //
69  template<class _Derived>
71  {
73  operator bool_type() const
74  {
75  return( (static_cast<const _Derived *>(this))->boolTest()
77  : 0 );
78  }
79  protected:
80  ~SafeBool() {}
81  };
83 
85  } // namespace base
88 } // namespace zypp
90 #endif // ZYPP_BASE_SAFEBOOL_H