| #pragma once |
| |
| #ifndef TCG_BASE_H |
| #define TCG_BASE_H |
| |
| namespace tcg { |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| struct empty_type {}; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| template <typename B = empty_type> |
| struct noncopyable : public B { |
| noncopyable() {} |
| |
| |
| |
| protected: |
| ~noncopyable() {} |
| |
| private: |
| noncopyable(const noncopyable &); |
| noncopyable &operator=( |
| const noncopyable &); |
| }; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| class polymorphic : noncopyable<> |
| { |
| protected: |
| polymorphic() {} |
| |
| public: |
| virtual ~polymorphic() {} |
| |
| }; |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| template <typename T, typename B = empty_type> |
| |
| class safe_bool : public B |
| { |
| class dummy {}; |
| struct detail { |
| dummy *member; |
| }; |
| |
| public: |
| typedef dummy *detail::*bool_type; |
| |
| public: |
| safe_bool() {} |
| |
| |
| |
| operator bool_type() const { |
| return static_cast<const T *>(this)->operator_bool() ? &detail::member : 0; |
| } |
| |
| protected: |
| ~safe_bool() {} |
| |
| private: |
| bool operator==(const safe_bool &); |
| bool operator!=(const safe_bool &); |
| }; |
| |
| } |
| |
| #endif |